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 @@ -25,6 +25,8 @@ npx create-rstack -d my-project -t app-vanilla-ts
- `app-vanilla-ts` - TypeScript Vanilla application
- `app-react-js` - JavaScript React application
- `app-react-ts` - TypeScript React application
- `app-preact-js` - JavaScript Preact application
- `app-preact-ts` - TypeScript Preact application
- `app-vue-js` - JavaScript Vue application
- `app-vue-ts` - TypeScript Vue application
- `app-svelte-js` - JavaScript Svelte application
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 @@ -74,6 +74,7 @@ const getTemplateName = async ({ template }: Argv): Promise<string> => {
? [
{ value: 'vanilla', label: 'Vanilla' },
{ value: 'react', label: 'React' },
{ value: 'preact', label: 'Preact' },
{ value: 'vue', label: 'Vue' },
{ value: 'svelte', label: 'Svelte' },
{ value: 'solid', label: 'Solid' },
Expand Down Expand Up @@ -108,6 +109,8 @@ await create({
'app-vanilla-ts',
'app-react-js',
'app-react-ts',
'app-preact-js',
'app-preact-ts',
Comment thread
chenjiahan marked this conversation as resolved.
'app-vue-js',
'app-vue-ts',
'app-svelte-js',
Expand Down
15 changes: 15 additions & 0 deletions packages/create-rstack/template-app-preact-js/AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# AGENTS.md

## Commands

- `{{ packageManager }} run dev` - Start the development server
- `{{ packageManager }} run build` - Build the app for production
- `{{ packageManager }} run preview` - Preview the production build locally
- `{{ packageManager }} run test` - Run tests
- `{{ packageManager }} run test:watch` - Run tests in watch mode

## Docs

- Rsbuild: https://rsbuild.rs/llms.txt
- Rspack: https://rspack.rs/llms.txt
- Rstest: https://rstest.rs/llms.txt
25 changes: 25 additions & 0 deletions packages/create-rstack/template-app-preact-js/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"name": "rstack-app-preact-js",
"version": "1.0.0",
"private": true,
"type": "module",
"scripts": {
"build": "rs build",
"dev": "rs dev",
"format": "rs fmt",
"lint": "rs lint",
"preview": "rs preview",
"test": "rs test",
"test:watch": "rs test --watch"
},
"dependencies": {
"preact": "^10.29.8"
},
"devDependencies": {
"@rsbuild/plugin-preact": "^2.0.0",
"@testing-library/jest-dom": "^7.0.0",
"@testing-library/preact": "^3.2.4",
"happy-dom": "^20.11.1",
"rstack": "^0.3.5"
}
}
25 changes: 25 additions & 0 deletions packages/create-rstack/template-app-preact-js/rstack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// @ts-check
// Rstack configuration guide: https://rstack.rs/config
import { define } from 'rstack';

define.app(async () => {
const { pluginPreact } = await import('@rsbuild/plugin-preact');

return {
plugins: [pluginPreact()],
};
});

define.test({
setupFiles: ['./tests/rstest.setup.js'],
});

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

return [
js.configs.recommended,
reactPlugin.configs.recommended,
reactHooksPlugin.configs.recommended,
];
});
26 changes: 26 additions & 0 deletions packages/create-rstack/template-app-preact-js/src/App.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
body {
margin: 0;
color: #fff;
font-family: Inter, Avenir, Helvetica, Arial, sans-serif;
background-image: linear-gradient(to bottom, #020917, #101725);
}

.content {
display: flex;
min-height: 100vh;
line-height: 1.1;
text-align: center;
flex-direction: column;
justify-content: center;
}

.content h1 {
font-size: 3.6rem;
font-weight: 700;
}

.content p {
font-size: 1.2rem;
font-weight: 400;
opacity: 0.5;
}
12 changes: 12 additions & 0 deletions packages/create-rstack/template-app-preact-js/src/App.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import './App.css';

const App = () => {
return (
<div className="content">
<h1>Rstack with Preact</h1>
<p>Start building amazing things with Rstack.</p>
</div>
);
};

export default App;
4 changes: 4 additions & 0 deletions packages/create-rstack/template-app-preact-js/src/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { render } from 'preact';
import App from './App';

render(<App />, document.getElementById('root'));
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { render, screen } from '@testing-library/preact';
import { expect, test } from 'rstack/test';
import App from '../src/App';

test('renders the main page', () => {
render(<App />);
expect(screen.getByText('Rstack with Preact')).toBeInTheDocument();
});
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);
15 changes: 15 additions & 0 deletions packages/create-rstack/template-app-preact-ts/AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# AGENTS.md

## Commands

- `{{ packageManager }} run dev` - Start the development server
- `{{ packageManager }} run build` - Build the app for production
- `{{ packageManager }} run preview` - Preview the production build locally
- `{{ packageManager }} run test` - Run tests
- `{{ packageManager }} run test:watch` - Run tests in watch mode

## Docs

- Rsbuild: https://rsbuild.rs/llms.txt
- Rspack: https://rspack.rs/llms.txt
- Rstest: https://rstest.rs/llms.txt
27 changes: 27 additions & 0 deletions packages/create-rstack/template-app-preact-ts/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "rstack-app-preact-ts",
"version": "1.0.0",
"private": true,
"type": "module",
"scripts": {
"build": "rs build",
"dev": "rs dev",
"format": "rs fmt",
"lint": "rs lint",
"preview": "rs preview",
"test": "rs test",
"test:watch": "rs test --watch"
},
"dependencies": {
"preact": "^10.29.8"
},
"devDependencies": {
"@rsbuild/plugin-preact": "^2.0.0",
"@testing-library/jest-dom": "^7.0.0",
"@testing-library/preact": "^3.2.4",
"@types/node": "^24.13.3",
"happy-dom": "^20.11.1",
"rstack": "^0.3.5",
"typescript": "^7.0.2"
}
}
25 changes: 25 additions & 0 deletions packages/create-rstack/template-app-preact-ts/rstack.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Rstack configuration guide: https://rstack.rs/config
import { define } from 'rstack';

define.app(async () => {
const { pluginPreact } = await import('@rsbuild/plugin-preact');

return {
plugins: [pluginPreact()],
};
});

define.test({
setupFiles: ['./tests/rstest.setup.ts'],
});

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

return [
js.configs.recommended,
ts.configs.recommended,
reactPlugin.configs.recommended,
reactHooksPlugin.configs.recommended,
];
});
26 changes: 26 additions & 0 deletions packages/create-rstack/template-app-preact-ts/src/App.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
body {
margin: 0;
color: #fff;
font-family: Inter, Avenir, Helvetica, Arial, sans-serif;
background-image: linear-gradient(to bottom, #020917, #101725);
}

.content {
display: flex;
min-height: 100vh;
line-height: 1.1;
text-align: center;
flex-direction: column;
justify-content: center;
}

.content h1 {
font-size: 3.6rem;
font-weight: 700;
}

.content p {
font-size: 1.2rem;
font-weight: 400;
opacity: 0.5;
}
12 changes: 12 additions & 0 deletions packages/create-rstack/template-app-preact-ts/src/App.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import './App.css';

const App = () => {
return (
<div className="content">
<h1>Rstack with Preact</h1>
<p>Start building amazing things with Rstack.</p>
</div>
);
};

export default App;
7 changes: 7 additions & 0 deletions packages/create-rstack/template-app-preact-ts/src/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { render } from 'preact';
import App from './App';

const root = document.getElementById('root');
if (root) {
render(<App />, root);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { render, screen } from '@testing-library/preact';
import { expect, test } from 'rstack/test';
import App from '../src/App';

test('renders the main page', () => {
render(<App />);
expect(screen.getByText('Rstack with Preact')).toBeInTheDocument();
});
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);
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"types": ["rstack/types", "node", "@testing-library/jest-dom"]
},
"include": ["./"]
}
28 changes: 28 additions & 0 deletions packages/create-rstack/template-app-preact-ts/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"compilerOptions": {
"lib": ["DOM", "ES2020"],
"jsx": "react-jsx",
"target": "ES2020",
"noEmit": true,
"skipLibCheck": true,
"types": ["rstack/types", "node"],
"jsxImportSource": "preact",
"useDefineForClassFields": true,

/* modules */
"moduleDetection": "force",
"moduleResolution": "bundler",
"verbatimModuleSyntax": true,
"resolveJsonModule": true,
"allowImportingTsExtensions": true,
"paths": {
"react": ["./node_modules/preact/compat/"],
"react-dom": ["./node_modules/preact/compat/"]
},

/* type checking */
"noUnusedLocals": true,
"noUnusedParameters": true
},
"include": ["src"]
}
14 changes: 14 additions & 0 deletions packages/create-rstack/tests/create.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,20 @@ test.each([
testFile: 'index.test.tsx',
hasTypeScript: true,
},
{
template: 'app-preact-js',
configExtension: 'js',
sourceExtension: 'jsx',
testFile: 'index.test.jsx',
hasTypeScript: false,
},
{
template: 'app-preact-ts',
configExtension: 'ts',
sourceExtension: 'tsx',
testFile: 'index.test.tsx',
hasTypeScript: true,
},
{
template: 'app-vue-js',
configExtension: 'js',
Expand Down