Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/create-rstack/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ npx create-rstack -d my-project -t app-vanilla-ts
- `lib-react-ts` - TypeScript React library
- `lib-vue-js` - JavaScript Vue library
- `lib-vue-ts` - TypeScript Vue library
- `lib-solid-js` - JavaScript Solid library
- `lib-solid-ts` - TypeScript Solid library

## Documentation

Expand Down
3 changes: 3 additions & 0 deletions packages/create-rstack/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ const getTemplateName = async ({ template }: Argv): Promise<string> => {
{ value: 'node', label: 'Node.js' },
{ value: 'react', label: 'React' },
{ value: 'vue', label: 'Vue' },
{ value: 'solid', label: 'Solid' },
],
}),
);
Expand Down Expand Up @@ -87,6 +88,8 @@ await create({
'lib-react-ts',
'lib-vue-js',
'lib-vue-ts',
'lib-solid-js',
'lib-solid-ts',
],
builtinTools: [],
getTemplateName,
Expand Down
14 changes: 14 additions & 0 deletions packages/create-rstack/template-lib-solid-js/AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# AGENTS.md

## Commands

- `{{ packageManager }} run build` - Build the library for production
- `{{ packageManager }} run dev` - Rebuild the library when source files change
- `{{ packageManager }} run test` - Run tests
- `{{ packageManager }} run test:watch` - Run tests in watch mode

## Docs

- Rslib: https://rslib.rs/llms.txt
- Rspack: https://rspack.rs/llms.txt
- Rstest: https://rstest.rs/llms.txt
40 changes: 40 additions & 0 deletions packages/create-rstack/template-lib-solid-js/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Rstack library

## Setup

Install the dependencies:

```bash
{{ packageManager }} install
```

## Get started

Build the library:

```bash
{{ packageManager }} run build
```

Build the library in watch mode:

```bash
{{ packageManager }} run dev
```

Run tests:

```bash
{{ packageManager }} run test
```

Run tests in watch mode:

```bash
{{ packageManager }} run test:watch
```

## Learn more

- [Rstack documentation](https://rstack.rs)
- [Rslib documentation](https://rslib.rs)
39 changes: 39 additions & 0 deletions packages/create-rstack/template-lib-solid-js/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"name": "rstack-lib-solid-js",
"version": "0.0.0",
"type": "module",
"exports": {
".": {
"solid": "./dist/index.jsx",
"default": "./dist/index.js"
}
},
"files": [
"dist",
"README.md"
],
"scripts": {
"build": "rs lib",
"dev": "rs lib --watch",
"format": "rs fmt",
"lint": "rs lint",
"test": "rs test",
"test:watch": "rs test --watch"
},
"devDependencies": {
"@rsbuild/plugin-babel": "^2.0.1",
"@rsbuild/plugin-solid": "^1.2.2",
"@solidjs/testing-library": "^0.8.10",
"@testing-library/dom": "^10.4.1",
"@testing-library/jest-dom": "^7.0.0",
"happy-dom": "^20.11.1",
"rstack": "^0.3.5",
"solid-js": "^1.9.14"
},
"peerDependencies": {
"solid-js": ">=1.8.0"
},
"publishConfig": {
"access": "public"
}
}
82 changes: 82 additions & 0 deletions packages/create-rstack/template-lib-solid-js/rstack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
// @ts-check
// Rstack configuration guide: https://rstack.rs/config
import { define } from 'rstack';

define.lib(async () => {
const { pluginBabel } = await import('@rsbuild/plugin-babel');
const { pluginSolid } = await import('@rsbuild/plugin-solid');

return {
lib: [
{
id: 'compiled',
bundle: false,
plugins: [
pluginBabel({
include: /\.(?:jsx|tsx)$/,
}),
pluginSolid(),
],
},
{
id: 'source',
bundle: false,
output: {
filename: {
js: '[name].jsx',
},
},
tools: {
swc: {
detectSyntax: 'auto',
jsc: {
transform: {
react: {
runtime: 'preserve',
},
},
},
},
rspack: {
module: {
parser: {
javascript: {
jsx: true,
},
},
},
},
},
},
],
source: {
entry: {
index: ['./src/**'],
},
},
output: {
target: 'web',
},
};
});

define.test(async () => {
const { pluginBabel } = await import('@rsbuild/plugin-babel');
const { pluginSolid } = await import('@rsbuild/plugin-solid');

return {
setupFiles: ['./tests/rstest.setup.js'],
plugins: [
pluginBabel({
include: /\.(?:jsx|tsx)$/,
}),
pluginSolid(),
],
};
});

define.lint(async () => {
const { js } = await import('rstack/lint');

return [js.configs.recommended];
});
17 changes: 17 additions & 0 deletions packages/create-rstack/template-lib-solid-js/src/Button.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import './button.css';

export function Button(props) {
const mode = () => (props.primary ? 'demo-button--primary' : 'demo-button--secondary');
const size = () => props.size ?? 'medium';

return (
<button
type="button"
class={`demo-button demo-button--${size()} ${mode()}`}
style={{ 'background-color': props.backgroundColor }}
onClick={props.onClick}
>
{props.label}
</button>
);
}
34 changes: 34 additions & 0 deletions packages/create-rstack/template-lib-solid-js/src/button.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
.demo-button {
font-weight: 700;
border: 0;
border-radius: 3em;
cursor: pointer;
display: inline-block;
line-height: 1;
}

.demo-button--primary {
color: white;
background-color: #1ea7fd;
}

.demo-button--secondary {
color: #333;
background-color: transparent;
box-shadow: rgba(0, 0, 0, 0.15) 0 0 0 1px inset;
}

.demo-button--small {
font-size: 12px;
padding: 10px 16px;
}

.demo-button--medium {
font-size: 14px;
padding: 11px 20px;
}

.demo-button--large {
font-size: 16px;
padding: 12px 24px;
}
1 change: 1 addition & 0 deletions packages/create-rstack/template-lib-solid-js/src/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { Button } from './Button';
11 changes: 11 additions & 0 deletions packages/create-rstack/template-lib-solid-js/tests/index.test.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { render, screen } from '@solidjs/testing-library';
import { expect, test } from 'rstack/test';
import { Button } from '../src/Button';

test('The button should have correct background color', async () => {
render(() => <Button backgroundColor="#ccc" label="Demo Button" />);
const button = screen.getByText('Demo Button');
expect(button).toHaveStyle({
'background-color': '#ccc',
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { expect } from 'rstack/test';
import * as jestDomMatchers from '@testing-library/jest-dom/matchers';

expect.extend(jestDomMatchers);
14 changes: 14 additions & 0 deletions packages/create-rstack/template-lib-solid-ts/AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# AGENTS.md

## Commands

- `{{ packageManager }} run build` - Build the library for production
- `{{ packageManager }} run dev` - Rebuild the library when source files change
- `{{ packageManager }} run test` - Run tests
- `{{ packageManager }} run test:watch` - Run tests in watch mode

## Docs

- Rslib: https://rslib.rs/llms.txt
- Rspack: https://rspack.rs/llms.txt
- Rstest: https://rstest.rs/llms.txt
40 changes: 40 additions & 0 deletions packages/create-rstack/template-lib-solid-ts/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Rstack library

## Setup

Install the dependencies:

```bash
{{ packageManager }} install
```

## Get started

Build the library:

```bash
{{ packageManager }} run build
```

Build the library in watch mode:

```bash
{{ packageManager }} run dev
```

Run tests:

```bash
{{ packageManager }} run test
```

Run tests in watch mode:

```bash
{{ packageManager }} run test:watch
```

## Learn more

- [Rstack documentation](https://rstack.rs)
- [Rslib documentation](https://rslib.rs)
43 changes: 43 additions & 0 deletions packages/create-rstack/template-lib-solid-ts/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"name": "rstack-lib-solid-ts",
"version": "0.0.0",
"type": "module",
"exports": {
".": {
"solid": "./dist/index.jsx",
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
}
},
"types": "./dist/index.d.ts",
"files": [
"dist",
"README.md"
],
"scripts": {
"build": "rs lib",
"dev": "rs lib --watch",
"format": "rs fmt",
"lint": "rs lint",
"test": "rs test",
"test:watch": "rs test --watch"
},
"devDependencies": {
"@rsbuild/plugin-babel": "^2.0.1",
"@rsbuild/plugin-solid": "^1.2.2",
"@solidjs/testing-library": "^0.8.10",
"@testing-library/dom": "^10.4.1",
"@testing-library/jest-dom": "^7.0.0",
"@types/node": "^24.13.3",
"happy-dom": "^20.11.1",
"rstack": "^0.3.5",
"solid-js": "^1.9.14",
"typescript": "^7.0.2"
},
"peerDependencies": {
"solid-js": ">=1.8.0"
},
"publishConfig": {
"access": "public"
}
}
Loading