react-client 1.0.6 → 1.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/README.md +125 -2
  2. package/dist/cli/commands/init.js +19 -0
  3. package/package.json +6 -7
  4. package/templates/react/index.html +1 -0
  5. package/templates/react/package.json +14 -0
  6. package/templates/react/src/App.jsx +1 -0
  7. package/templates/react/src/main.jsx +1 -0
  8. package/templates/react-ssr/index.html +1 -0
  9. package/templates/react-ssr/package.json +14 -0
  10. package/templates/react-ssr/src/entry-client.jsx +1 -0
  11. package/templates/react-ssr/src/entry-server.jsx +1 -0
  12. package/templates/react-ssr/src/pages/index.jsx +1 -0
  13. package/templates/react-ssr-ts/index.html +1 -0
  14. package/templates/react-ssr-ts/package.json +21 -0
  15. package/templates/react-ssr-ts/src/entry-client.js +5 -0
  16. package/templates/react-ssr-ts/src/entry-client.tsx +6 -0
  17. package/templates/react-ssr-ts/src/entry-server.js +4 -0
  18. package/templates/react-ssr-ts/src/entry-server.tsx +5 -0
  19. package/templates/react-ssr-ts/src/pages/index.js +2 -0
  20. package/templates/react-ssr-ts/src/pages/index.tsx +3 -0
  21. package/templates/react-ssr-ts/tsconfig.json +15 -0
  22. package/templates/react-tailwind/index.html +1 -0
  23. package/templates/react-tailwind/package.json +20 -0
  24. package/templates/react-tailwind/postcss.config.cjs +1 -0
  25. package/templates/react-tailwind/src/App.jsx +1 -0
  26. package/templates/react-tailwind/src/main.jsx +1 -0
  27. package/templates/react-tailwind/tailwind.config.cjs +1 -0
  28. package/templates/react-tailwind-ts/index.html +1 -0
  29. package/templates/react-tailwind-ts/package.json +24 -0
  30. package/templates/react-tailwind-ts/postcss.config.cjs +1 -0
  31. package/templates/react-tailwind-ts/src/App.js +2 -0
  32. package/templates/react-tailwind-ts/src/App.tsx +2 -0
  33. package/templates/react-tailwind-ts/src/index.css +1 -0
  34. package/templates/react-tailwind-ts/src/main.js +7 -0
  35. package/templates/react-tailwind-ts/src/main.tsx +8 -0
  36. package/templates/react-tailwind-ts/tailwind.config.cjs +1 -0
  37. package/templates/react-tailwind-ts/tsconfig.json +14 -0
  38. package/templates/react-ts/index.html +1 -0
  39. package/templates/react-ts/package.json +20 -0
  40. package/templates/react-ts/src/App.tsx +1 -0
  41. package/templates/react-ts/src/main.tsx +1 -0
package/README.md CHANGED
@@ -32,6 +32,7 @@ To install the latest stable version, run the following command:
32
32
  npm install -g react-client
33
33
  react-client init myapp --template react-ts
34
34
  cd myapp
35
+ npm install
35
36
  npm run dev
36
37
  ```
37
38
 
@@ -74,6 +75,72 @@ react-client init myapp --template react-ts --with-config
74
75
 
75
76
  ## Template specifics
76
77
 
78
+ ### react
79
+
80
+ - `src/App.jsx` — main app component
81
+ - `src/main.jsx` — client entry that mounts React to the DOM
82
+ - `index.html` — HTML template used by the bundler
83
+ - `package.json` lists `react` and `react-dom` as dependencies and includes devDependencies (esbuild, scripts) for local testing
84
+
85
+ - `--with-config`: creates `react-client.config.ts` with a minimal `defineConfig({})` stub and helpful comments (dev server port, root) tailored to a client-only app.
86
+
87
+ ```ts
88
+ // react / client-only example
89
+ import { defineConfig } from 'react-client'
90
+
91
+ export default defineConfig({
92
+ root: '.',
93
+ server: { port: 3000 },
94
+ build: { outDir: 'dist/client' }
95
+ })
96
+ ```
97
+
98
+ ### react-ts
99
+
100
+ - `src/App.tsx` — main app component (TypeScript + JSX)
101
+ - `src/main.tsx` — client entry (TypeScript) that mounts the app
102
+ - `tsconfig.json` — minimal TypeScript configuration tailored for the template
103
+ - `index.html` — HTML template used by the bundler
104
+ - `package.json` includes `react`, `react-dom` and `devDependencies` like `typescript` and `@types/react`, `@types/react-dom` for local development
105
+
106
+ - `--with-config`: creates `react-client.config.ts` with a TypeScript-friendly `defineConfig({})` stub (typed imports) and suggested TypeScript-related defaults (e.g., `root`, `esbuild` TS options) comments.
107
+
108
+ ```ts
109
+ // react-ts example (TypeScript-friendly)
110
+ import { defineConfig } from 'react-client'
111
+
112
+ export default defineConfig({
113
+ root: '.',
114
+ server: { port: 3000 },
115
+ build: { outDir: 'dist/client' },
116
+ // TS-specific hints: configure `tsconfig` or esbuild TS options if needed
117
+ })
118
+ ```
119
+
120
+ ### react-ssr
121
+
122
+ - `src/entry-client.jsx` — client hydration entry
123
+ - `src/entry-server.jsx` — server rendering entry (exports `render(url)` or similar API)
124
+ - `src/pages/` — route components used by the SSR renderer
125
+ - `index.html` — base HTML template used by the build system
126
+ - `package.json` lists devDependencies required for local testing (esbuild, react-refresh) and provides scripts for building and running the SSR preview
127
+
128
+ - `--with-config`: the generated `react-client.config.ts` includes an SSR-focused stub with comments for server entry/port and output directories (hints for `ssr` or `server` options) so you can quickly enable SSR-related plugins.
129
+
130
+ ```ts
131
+ // react-ssr example
132
+ import { defineConfig } from 'react-client'
133
+
134
+ export default defineConfig({
135
+ root: '.',
136
+ server: { port: 3000 },
137
+ ssr: {
138
+ entry: 'src/entry-server.jsx', // change to .tsx for TS template
139
+ outDir: 'dist/server'
140
+ }
141
+ })
142
+ ```
143
+
77
144
  ### react-ssr-ts
78
145
 
79
146
  - `src/entry-client.tsx` — client hydration entry
@@ -81,12 +148,68 @@ react-client init myapp --template react-ts --with-config
81
148
  - `src/pages/` — route components
82
149
  - `index.html` — template used by build system
83
150
  - `package.json` lists devDependencies required for local testing (esbuild, react-refresh)
151
+ - `tsconfig.json` and `@types/*` entries are included to support TypeScript development
152
+
153
+ - `--with-config`: creates a typed `react-client.config.ts` stub that includes notes for SSR/TypeScript integration (server entry, `tsconfig` path, and build output locations) to help you customize server-side rendering options.
154
+
155
+ ```ts
156
+ // react-ssr-ts example (typed)
157
+ import { defineConfig } from 'react-client'
158
+
159
+ export default defineConfig({
160
+ root: '.',
161
+ server: { port: 3000 },
162
+ ssr: {
163
+ entry: 'src/entry-server.tsx',
164
+ outDir: 'dist/server'
165
+ },
166
+ // Tip: point to `tsconfig.json` or adjust esbuild TS options if you customize builds
167
+ })
168
+ ```
169
+
170
+ ### react-tailwind
171
+
172
+ - `postcss.config.cjs` and `tailwind.config.cjs` included
173
+ - `src/index.css` with Tailwind directives (`@tailwind base; @tailwind components; @tailwind utilities;`)
174
+ - `index.html` and JS entries (`src/main.jsx`, `src/App.jsx`) wired to import the generated CSS
175
+ - `package.json` includes Tailwind/PostCSS devDependencies (install locally in the app)
176
+
177
+ - `--with-config`: creates `react-client.config.ts` containing a minimal stub plus a Tailwind hint block that shows how to enable/inject PostCSS/Tailwind processing (for example enabling the PostCSS plugin or pointing to `postcss.config.cjs`).
178
+
179
+ ```ts
180
+ // react-tailwind example
181
+ import { defineConfig } from 'react-client'
182
+
183
+ export default defineConfig({
184
+ root: '.',
185
+ server: { port: 3000 },
186
+ css: {
187
+ postcssConfig: 'postcss.config.cjs'
188
+ }
189
+ })
190
+ ```
84
191
 
85
192
  ### react-tailwind-ts
86
193
 
87
194
  - `postcss.config.cjs` and `tailwind.config.cjs` included
88
195
  - `src/index.css` with Tailwind directives
89
- - `package.json` includes tailwind/postcss devDependencies (install locally in the app)
196
+ - `src/App.tsx` / `src/main.tsx` TypeScript entry points that import the CSS
197
+ - `tsconfig.json` provided for TypeScript templates
198
+ - `package.json` includes Tailwind/PostCSS devDependencies (install locally in the app)
199
+
200
+ - `--with-config`: generates a TypeScript `react-client.config.ts` stub that includes comments about wiring PostCSS/Tailwind and TypeScript settings (where to find `postcss.config.cjs` and `tsconfig.json`) to get Tailwind configured quickly.
201
+
202
+ ```ts
203
+ // react-tailwind-ts example
204
+ import { defineConfig } from 'react-client'
205
+
206
+ export default defineConfig({
207
+ root: '.',
208
+ server: { port: 3000 },
209
+ css: { postcssConfig: 'postcss.config.cjs' },
210
+ // TypeScript hint: adjust tsconfig or esbuild options as needed
211
+ })
212
+ ```
90
213
 
91
214
  ## How the CLI wires features
92
215
 
@@ -130,7 +253,7 @@ Development of react-client happens in the open on GitHub, and we are grateful t
130
253
 
131
254
  ## Publishing
132
255
 
133
- Before pushing your changes to Github, make sure that `version` in `package.json` is changed to newest version. Then run `npm install` for synchronize it to `package-lock.json` and `pnpm install` for synchronize it to `pnpm-lock.yaml`
256
+ Before pushing your changes to Github, make sure that `version` in `package.json` is changed to newest version. Then run `npm install` to synchronize `package-lock.json`
134
257
 
135
258
  ## Feedbacks and Issues
136
259
 
@@ -36,6 +36,25 @@ async function init(name, opts = {}) {
36
36
  process.exit(1);
37
37
  }
38
38
  await fs_extra_1.default.copy(tpl, root);
39
+ // If the template contains a package.json, update its name field to the
40
+ // user provided project name so the scaffolded project has the correct
41
+ // package identity.
42
+ const pkgPath = path_1.default.join(root, 'package.json');
43
+ if (fs_extra_1.default.existsSync(pkgPath)) {
44
+ try {
45
+ const raw = await fs_extra_1.default.readFile(pkgPath, 'utf8');
46
+ const pkg = JSON.parse(raw);
47
+ // Use the final directory name as the package name so users can pass
48
+ // either a simple name ("myapp") or a path ("/abs/path/myapp").
49
+ pkg.name = path_1.default.basename(root);
50
+ // If template marks package private, leave it as-is; do not force publish.
51
+ await fs_extra_1.default.writeFile(pkgPath, JSON.stringify(pkg, null, 2) + '\n', 'utf8');
52
+ }
53
+ catch (err) {
54
+ // Non-fatal: log and continue
55
+ console.warn('Warning: could not update package.json name for template:', err);
56
+ }
57
+ }
39
58
  if (opts.withConfig) {
40
59
  const cfg = "import { defineConfig } from 'react-client';\nexport default defineConfig({});\n";
41
60
  await fs_extra_1.default.writeFile(path_1.default.join(root, 'react-client.config.ts'), cfg, 'utf8');
package/package.json CHANGED
@@ -1,16 +1,15 @@
1
1
  {
2
2
  "name": "react-client",
3
- "version": "1.0.6",
3
+ "version": "1.0.7",
4
4
  "description": "react-client is a lightweight CLI and runtime for building React apps with fast iteration. It is designed to be esbuild-based, Node-native, and modular like Vite/Next.js with SSR, HMR, Tailwind, CSS Modules, and generators.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "sideEffects": false,
8
8
  "files": [
9
- "dist"
9
+ "dist",
10
+ "templates"
10
11
  ],
11
- "bin": {
12
- "react-client": "dist/cli/index.js"
13
- },
12
+ "bin": "dist/cli/index.js",
14
13
  "repository": {
15
14
  "type": "git",
16
15
  "url": "https://github.com/venkateshsundaram/react-client.git"
@@ -94,7 +93,7 @@
94
93
  },
95
94
  "dependencies": {
96
95
  "commander": "^14.0.2",
97
- "fs-extra": "^11.1.1",
98
- "esbuild": "^0.25.12"
96
+ "esbuild": "^0.25.12",
97
+ "fs-extra": "^11.3.2"
99
98
  }
100
99
  }
@@ -0,0 +1 @@
1
+ <!doctype html><html><head><meta charset='utf-8'></head><body><div id='root'></div><script type='module' src='/client/bundle.js'></script></body></html>
@@ -0,0 +1,14 @@
1
+ {
2
+ "name": "template-react",
3
+ "version": "0.0.1",
4
+ "private": true,
5
+ "scripts": {
6
+ "dev": "react-client dev",
7
+ "build": "react-client build",
8
+ "preview": "react-client preview"
9
+ },
10
+ "dependencies": {
11
+ "react": "^18.2.0",
12
+ "react-dom": "^18.2.0"
13
+ }
14
+ }
@@ -0,0 +1 @@
1
+ export default ()=> <div>Hello React</div>;
@@ -0,0 +1 @@
1
+ import React from 'react';import { createRoot } from 'react-dom/client';import App from './App';const root = createRoot(document.getElementById('root'));root.render(<App/>);
@@ -0,0 +1 @@
1
+ <!doctype html><html><head><meta charset='utf-8'></head><body><div id='root'></div><script type='module' src='/client/bundle.js'></script></body></html>
@@ -0,0 +1,14 @@
1
+ {
2
+ "name": "template-react-ssr",
3
+ "version": "0.0.1",
4
+ "private": true,
5
+ "scripts": {
6
+ "dev": "react-client dev",
7
+ "build": "react-client build:ssr",
8
+ "preview": "react-client preview"
9
+ },
10
+ "dependencies": {
11
+ "react": "^18.2.0",
12
+ "react-dom": "^18.2.0"
13
+ }
14
+ }
@@ -0,0 +1 @@
1
+ import React from 'react';import { hydrateRoot } from 'react-dom/client';import Home from './pages/index';hydrateRoot(document.getElementById('root'), React.createElement(Home));
@@ -0,0 +1 @@
1
+ import React from 'react';import { renderToString } from 'react-dom/server';import Home from './pages/index';exports.render = function(url){ const Page = Home; return Promise.resolve(renderToString(React.createElement(Page))); };
@@ -0,0 +1 @@
1
+ import React from 'react';export default function Home(){ return <div>Home SSR</div>; }
@@ -0,0 +1 @@
1
+ <!doctype html><html><head><meta charset='utf-8' /></head><body><div id='root'></div><script type='module' src='/client/bundle.js'></script></body></html>
@@ -0,0 +1,21 @@
1
+ {
2
+ "name": "my-react-ssr-ts-app",
3
+ "version": "0.0.1",
4
+ "private": true,
5
+ "scripts": {
6
+ "dev": "react-client dev",
7
+ "build": "react-client build:ssr",
8
+ "preview": "react-client preview"
9
+ },
10
+ "dependencies": {
11
+ "react": "^18.2.0",
12
+ "react-dom": "^18.2.0"
13
+ },
14
+ "devDependencies": {
15
+ "@types/react": "^18.0.0",
16
+ "@types/react-dom": "^18.0.0",
17
+ "esbuild": "^0.25.12",
18
+ "react-refresh": "^0.14.0",
19
+ "typescript": "^5.0.0"
20
+ }
21
+ }
@@ -0,0 +1,5 @@
1
+ import '/@react-refresh-shim';
2
+ import React from 'react';
3
+ import { hydrateRoot } from 'react-dom/client';
4
+ import Home from './pages/index';
5
+ hydrateRoot(document.getElementById('root'), React.createElement(Home));
@@ -0,0 +1,6 @@
1
+
2
+ import '/@react-refresh-shim';
3
+ import React from 'react';
4
+ import { hydrateRoot } from 'react-dom/client';
5
+ import Home from './pages/index';
6
+ hydrateRoot(document.getElementById('root')!, React.createElement(Home));
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import { renderToString } from 'react-dom/server';
3
+ import Home from './pages/index';
4
+ export async function render(url) { const Page = Home; return renderToString(React.createElement(Page)); }
@@ -0,0 +1,5 @@
1
+
2
+ import React from 'react';
3
+ import { renderToString } from 'react-dom/server';
4
+ import Home from './pages/index';
5
+ export async function render(url:string){ const Page = Home; return renderToString(React.createElement(Page)); }
@@ -0,0 +1,2 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ export default function Home() { return _jsxs("div", { style: { padding: 20 }, children: [_jsx("h1", { children: "Home (SSR TS)" }), _jsx("p", { children: "Server-side rendered page." })] }); }
@@ -0,0 +1,3 @@
1
+
2
+ import React from 'react';
3
+ export default function Home(){ return <div style={{padding:20}}><h1>Home (SSR TS)</h1><p>Server-side rendered page.</p></div>; }
@@ -0,0 +1,15 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2020",
4
+ "module": "ES2020",
5
+ "lib": [
6
+ "DOM",
7
+ "ES2020"
8
+ ],
9
+ "jsx": "react-jsx",
10
+ "moduleResolution": "node",
11
+ "strict": true,
12
+ "esModuleInterop": true,
13
+ "skipLibCheck": true
14
+ }
15
+ }
@@ -0,0 +1 @@
1
+ <!doctype html><html><head><meta charset='utf-8'></head><body><div id='root'></div><script type='module' src='/client/bundle.js'></script></body></html>
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "template-react-tailwind",
3
+ "version": "0.0.1",
4
+ "private": true,
5
+ "scripts": {
6
+ "dev": "react-client dev",
7
+ "build": "react-client build",
8
+ "preview": "react-client preview"
9
+ },
10
+ "dependencies": {
11
+ "react": "^18.2.0",
12
+ "react-dom": "^18.2.0"
13
+ },
14
+ "devDependencies": {
15
+ "autoprefixer": "^10.0.0",
16
+ "esbuild": "^0.25.12",
17
+ "postcss": "^8.0.0",
18
+ "tailwindcss": "^3.0.0"
19
+ }
20
+ }
@@ -0,0 +1 @@
1
+ module.exports = { plugins: { tailwindcss: {}, autoprefixer: {} } };
@@ -0,0 +1 @@
1
+ export default ()=> <div className='p-8'><h1 className='text-2xl'>Tailwind</h1></div>;
@@ -0,0 +1 @@
1
+ import React from 'react';import { createRoot } from 'react-dom/client';import App from './App';import './index.css';const root = createRoot(document.getElementById('root'));root.render(<App/>);
@@ -0,0 +1 @@
1
+ module.exports = { content: ['./index.html','./src/**/*.{js,jsx,ts,tsx}'], theme: { extend: {} }, plugins: [] };
@@ -0,0 +1 @@
1
+ <!doctype html><html><head><meta charset='utf-8'></head><body><div id='root'></div><script type='module' src='/client/bundle.js'></script></body></html>
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "template-react-tailwind-ts",
3
+ "version": "0.0.1",
4
+ "private": true,
5
+ "scripts": {
6
+ "dev": "react-client dev",
7
+ "build": "react-client build",
8
+ "preview": "react-client preview"
9
+ },
10
+ "dependencies": {
11
+ "react": "^18.2.0",
12
+ "react-dom": "^18.2.0"
13
+ },
14
+ "devDependencies": {
15
+ "@types/react": "^18.0.0",
16
+ "@types/react-dom": "^18.0.0",
17
+ "autoprefixer": "^10.0.0",
18
+ "esbuild": "^0.25.12",
19
+ "postcss": "^8.0.0",
20
+ "react-refresh": "^0.14.0",
21
+ "tailwindcss": "^3.0.0",
22
+ "typescript": "^5.0.0"
23
+ }
24
+ }
@@ -0,0 +1 @@
1
+ module.exports = { plugins: { tailwindcss: {}, autoprefixer: {} } };
@@ -0,0 +1,2 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ export default function App() { return _jsxs("div", { className: 'p-8', children: [_jsx("h1", { className: 'text-2xl font-bold', children: "Tailwind TS" }), _jsx("p", { children: "Welcome to react-tailwind-ts template." })] }); }
@@ -0,0 +1,2 @@
1
+
2
+ export default function App(){ return <div className='p-8'><h1 className='text-2xl font-bold'>Tailwind TS</h1><p>Welcome to react-tailwind-ts template.</p></div>; }
@@ -0,0 +1 @@
1
+ @tailwind base;@tailwind components;@tailwind utilities;
@@ -0,0 +1,7 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import '/@react-refresh-shim';
3
+ import { createRoot } from 'react-dom/client';
4
+ import App from './App';
5
+ import './index.css';
6
+ const root = createRoot(document.getElementById('root'));
7
+ root.render(_jsx(App, {}));
@@ -0,0 +1,8 @@
1
+
2
+ import '/@react-refresh-shim';
3
+ import React from 'react';
4
+ import { createRoot } from 'react-dom/client';
5
+ import App from './App';
6
+ import './index.css';
7
+ const root = createRoot(document.getElementById('root')!);
8
+ root.render(<App/>);
@@ -0,0 +1 @@
1
+ module.exports = { content: ['./index.html','./src/**/*.{js,jsx,ts,tsx}'], theme: { extend:{} }, plugins: [] };
@@ -0,0 +1,14 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2020",
4
+ "module": "ES2020",
5
+ "lib": [
6
+ "DOM",
7
+ "ES2020"
8
+ ],
9
+ "jsx": "react-jsx",
10
+ "moduleResolution": "node",
11
+ "strict": true,
12
+ "esModuleInterop": true
13
+ }
14
+ }
@@ -0,0 +1 @@
1
+ <!doctype html><html><head><meta charset='utf-8'></head><body><div id='root'></div><script type='module' src='/client/bundle.js'></script></body></html>
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "template-react-ts",
3
+ "version": "0.0.1",
4
+ "private": true,
5
+ "scripts": {
6
+ "dev": "react-client dev",
7
+ "build": "react-client build",
8
+ "preview": "react-client preview"
9
+ },
10
+ "dependencies": {
11
+ "react": "^18.2.0",
12
+ "react-dom": "^18.2.0"
13
+ },
14
+ "devDependencies": {
15
+ "@types/react": "^18.0.0",
16
+ "@types/react-dom": "^18.0.0",
17
+ "esbuild": "^0.25.12",
18
+ "typescript": "^5.0.0"
19
+ }
20
+ }
@@ -0,0 +1 @@
1
+ export default function App(){ return <div>Hello React TS</div>; }
@@ -0,0 +1 @@
1
+ import React from 'react';import { createRoot } from 'react-dom/client';import App from './App';const root = createRoot(document.getElementById('root')!);root.render(<App/>);