react-client 1.0.7 → 1.0.9
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.
- package/README.md +141 -185
- package/dist/cli/commands/build.js +30 -47
- package/dist/cli/commands/build.ssr.js +31 -54
- package/dist/cli/commands/dev.js +221 -6
- package/dist/cli/commands/init.js +79 -48
- package/dist/cli/commands/preview.js +44 -16
- package/dist/cli/index.js +104 -18
- package/dist/utils/loadConfig.js +109 -0
- package/package.json +77 -34
- package/templates/react/index.html +1 -1
- package/templates/react-ssr/index.html +1 -1
- package/templates/react-ssr-ts/index.html +1 -1
- package/templates/react-tailwind/index.html +1 -1
- package/templates/react-tailwind-ts/index.html +1 -1
- package/templates/react-ts/index.html +1 -1
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.loadReactClientConfig = loadReactClientConfig;
|
|
40
|
+
const path_1 = __importDefault(require("path"));
|
|
41
|
+
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
42
|
+
const url_1 = require("url");
|
|
43
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
44
|
+
const esbuild_1 = require("esbuild");
|
|
45
|
+
/**
|
|
46
|
+
* Dynamically loads react-client.config.(ts|js|mjs)
|
|
47
|
+
* Compiles .ts and .js configs to .mjs temporarily for import.
|
|
48
|
+
*/
|
|
49
|
+
async function loadReactClientConfig(cwd) {
|
|
50
|
+
let projectRoot = cwd;
|
|
51
|
+
try {
|
|
52
|
+
// Detect if running inside react-client repo for local testing
|
|
53
|
+
const pkgPath = path_1.default.join(cwd, 'package.json');
|
|
54
|
+
if (await fs_extra_1.default.pathExists(pkgPath)) {
|
|
55
|
+
const pkg = JSON.parse(await fs_extra_1.default.readFile(pkgPath, 'utf8'));
|
|
56
|
+
if (pkg.name === 'react-client' && (await fs_extra_1.default.pathExists(path_1.default.join(cwd, 'myapp')))) {
|
|
57
|
+
console.log(chalk_1.default.gray('🧩 Detected local CLI environment, using ./myapp as root.'));
|
|
58
|
+
projectRoot = path_1.default.join(cwd, 'myapp');
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
const filenames = [
|
|
62
|
+
'react-client.config.ts',
|
|
63
|
+
'react-client.config.mjs',
|
|
64
|
+
'react-client.config.js',
|
|
65
|
+
];
|
|
66
|
+
let configFile = null;
|
|
67
|
+
for (const name of filenames) {
|
|
68
|
+
const file = path_1.default.join(projectRoot, name);
|
|
69
|
+
if (await fs_extra_1.default.pathExists(file)) {
|
|
70
|
+
configFile = file;
|
|
71
|
+
break;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
if (!configFile) {
|
|
75
|
+
console.log(chalk_1.default.gray('ℹ️ No react-client.config found, using defaults.'));
|
|
76
|
+
return {};
|
|
77
|
+
}
|
|
78
|
+
const ext = path_1.default.extname(configFile);
|
|
79
|
+
const tempFile = path_1.default.join(projectRoot, `.react-client.temp-${Date.now()}.mjs`);
|
|
80
|
+
// 🧠 Always compile .ts or .js → .mjs for safe ESM import
|
|
81
|
+
if (ext === '.ts' || ext === '.js') {
|
|
82
|
+
await (0, esbuild_1.build)({
|
|
83
|
+
entryPoints: [configFile],
|
|
84
|
+
outfile: tempFile,
|
|
85
|
+
platform: 'node',
|
|
86
|
+
format: 'esm',
|
|
87
|
+
target: 'node18',
|
|
88
|
+
bundle: true,
|
|
89
|
+
write: true,
|
|
90
|
+
logLevel: 'silent',
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
await fs_extra_1.default.copyFile(configFile, tempFile);
|
|
95
|
+
}
|
|
96
|
+
// Import via file:// URL
|
|
97
|
+
const fileUrl = (0, url_1.pathToFileURL)(tempFile).href;
|
|
98
|
+
const mod = await Promise.resolve(`${fileUrl}`).then(s => __importStar(require(s)));
|
|
99
|
+
await fs_extra_1.default.remove(tempFile);
|
|
100
|
+
const config = mod.default || mod;
|
|
101
|
+
console.log(chalk_1.default.green(`🧩 Loaded config from ${path_1.default.basename(configFile)}`));
|
|
102
|
+
return config;
|
|
103
|
+
}
|
|
104
|
+
catch (err) {
|
|
105
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
106
|
+
console.error(chalk_1.default.red(`❌ Could not load config (${path_1.default.join(cwd, 'react-client.config.js')}): ${msg}`));
|
|
107
|
+
return {};
|
|
108
|
+
}
|
|
109
|
+
}
|
package/package.json
CHANGED
|
@@ -1,63 +1,82 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-client",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "react-client is a lightweight CLI and runtime for building React apps with fast iteration.
|
|
3
|
+
"version": "1.0.9",
|
|
4
|
+
"description": "react-client is a lightweight CLI and runtime for building React apps with fast iteration. Esbuild-based, Node-native, and modular like Vite/Next.js with SSR, HMR, Tailwind, CSS Modules, and generators.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "Venkatesh Sundaram",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/venkateshsundaram/react-client.git"
|
|
10
|
+
},
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/venkateshsundaram/react-client/issues"
|
|
13
|
+
},
|
|
14
|
+
"homepage": "https://github.com/venkateshsundaram/react-client#readme",
|
|
15
|
+
"bin": {
|
|
16
|
+
"react-client": "dist/cli/index.js"
|
|
17
|
+
},
|
|
5
18
|
"main": "dist/index.js",
|
|
6
19
|
"types": "dist/index.d.ts",
|
|
20
|
+
"exports": {
|
|
21
|
+
".": {
|
|
22
|
+
"types": "./dist/index.d.ts",
|
|
23
|
+
"require": "./dist/index.js",
|
|
24
|
+
"import": "./dist/index.js"
|
|
25
|
+
},
|
|
26
|
+
"./config": {
|
|
27
|
+
"types": "./dist/config.d.ts",
|
|
28
|
+
"require": "./dist/config.js",
|
|
29
|
+
"import": "./dist/config.js"
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"typesVersions": {
|
|
33
|
+
"*": {
|
|
34
|
+
"config": [
|
|
35
|
+
"dist/config.d.ts"
|
|
36
|
+
]
|
|
37
|
+
}
|
|
38
|
+
},
|
|
7
39
|
"sideEffects": false,
|
|
8
40
|
"files": [
|
|
9
41
|
"dist",
|
|
10
42
|
"templates"
|
|
11
43
|
],
|
|
12
|
-
"
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
"url": "https://github.com/venkateshsundaram/react-client.git"
|
|
16
|
-
},
|
|
44
|
+
"workspaces": [
|
|
45
|
+
"templates/*"
|
|
46
|
+
],
|
|
17
47
|
"keywords": [
|
|
18
48
|
"react",
|
|
19
|
-
"javascript",
|
|
20
49
|
"typescript",
|
|
21
50
|
"cli",
|
|
22
51
|
"react-cli",
|
|
23
|
-
"
|
|
52
|
+
"framework",
|
|
53
|
+
"hmr",
|
|
24
54
|
"ssr",
|
|
25
55
|
"esbuild",
|
|
56
|
+
"tooling",
|
|
57
|
+
"vite-alternative",
|
|
58
|
+
"fast-refresh",
|
|
59
|
+
"react-refresh",
|
|
26
60
|
"tailwind",
|
|
27
|
-
"
|
|
28
|
-
"hmr",
|
|
29
|
-
"framework",
|
|
30
|
-
"tooling"
|
|
31
|
-
],
|
|
32
|
-
"author": "venkateshsundaram",
|
|
33
|
-
"license": "MIT",
|
|
34
|
-
"workspaces": [
|
|
35
|
-
"templates/*"
|
|
61
|
+
"developer-experience"
|
|
36
62
|
],
|
|
37
|
-
"bugs": {
|
|
38
|
-
"url": "https://github.com/venkateshsundaram/react-client/issues"
|
|
39
|
-
},
|
|
40
63
|
"scripts": {
|
|
41
|
-
"clean": "rm -rf dist",
|
|
64
|
+
"clean": "rm -rf dist .turbo .react-client.temp.config*",
|
|
42
65
|
"compile": "tsc -p tsconfig.build.json",
|
|
43
66
|
"build": "npm run clean && npm run compile",
|
|
44
67
|
"build:cli": "node dist/cli/index.js build",
|
|
45
68
|
"build:ssr": "node dist/cli/index.js build:ssr",
|
|
46
69
|
"dev": "node dist/cli/index.js dev",
|
|
47
70
|
"prepare": "npm run compile",
|
|
48
|
-
"lint": "eslint . --ext .ts",
|
|
71
|
+
"lint": "eslint . --ext .ts --max-warnings 0",
|
|
49
72
|
"format": "prettier --write \"src/**/*.ts\"",
|
|
50
73
|
"format:check": "prettier --check \"src/**/*.ts\"",
|
|
51
74
|
"release": "standard-version",
|
|
52
75
|
"postrelease": "git push --follow-tags",
|
|
53
|
-
"prepublishOnly": "npm run
|
|
76
|
+
"prepublishOnly": "npm run lint && npm run format:check && npm run build && npm test",
|
|
54
77
|
"test": "jest",
|
|
55
|
-
"typecheck": "tsc --noEmit"
|
|
56
|
-
|
|
57
|
-
"husky": {
|
|
58
|
-
"hooks": {
|
|
59
|
-
"pre-commit": "lint-staged"
|
|
60
|
-
}
|
|
78
|
+
"typecheck": "tsc --noEmit",
|
|
79
|
+
"verify": "bash scripts/local-verify.sh"
|
|
61
80
|
},
|
|
62
81
|
"lint-staged": {
|
|
63
82
|
"*.ts": [
|
|
@@ -65,18 +84,44 @@
|
|
|
65
84
|
"prettier --write"
|
|
66
85
|
]
|
|
67
86
|
},
|
|
87
|
+
"husky": {
|
|
88
|
+
"hooks": {
|
|
89
|
+
"pre-commit": "lint-staged",
|
|
90
|
+
"pre-push": "npm run lint && npm run typecheck"
|
|
91
|
+
}
|
|
92
|
+
},
|
|
68
93
|
"commitlint": {
|
|
69
94
|
"extends": [
|
|
70
95
|
"@commitlint/config-conventional"
|
|
71
96
|
]
|
|
72
97
|
},
|
|
98
|
+
"dependencies": {
|
|
99
|
+
"@jridgewell/trace-mapping": "^0.3.31",
|
|
100
|
+
"chalk": "^4.1.2",
|
|
101
|
+
"chokidar": "^4.0.3",
|
|
102
|
+
"commander": "^14.0.2",
|
|
103
|
+
"connect": "^3.7.0",
|
|
104
|
+
"detect-port": "^2.1.0",
|
|
105
|
+
"esbuild": "^0.25.12",
|
|
106
|
+
"fs-extra": "^11.3.2",
|
|
107
|
+
"open": "^8.4.2",
|
|
108
|
+
"prismjs": "^1.30.0",
|
|
109
|
+
"prompts": "^2.4.2",
|
|
110
|
+
"react-refresh": "^0.14.0",
|
|
111
|
+
"serve-static": "^1.15.0",
|
|
112
|
+
"ws": "^8.18.3"
|
|
113
|
+
},
|
|
73
114
|
"devDependencies": {
|
|
74
115
|
"@commitlint/cli": "^19.8.0",
|
|
75
116
|
"@commitlint/config-conventional": "^19.8.0",
|
|
76
117
|
"@types/commander": "^2.12.0",
|
|
118
|
+
"@types/connect": "^3.4.38",
|
|
77
119
|
"@types/fs-extra": "^9.0.13",
|
|
78
120
|
"@types/jest": "^29.0.0",
|
|
79
121
|
"@types/node": "^18.0.0",
|
|
122
|
+
"@types/prompts": "^2.4.9",
|
|
123
|
+
"@types/serve-static": "^1.15.5",
|
|
124
|
+
"@types/ws": "^8.18.1",
|
|
80
125
|
"@typescript-eslint/eslint-plugin": "^8.46.3",
|
|
81
126
|
"@typescript-eslint/parser": "^8.46.3",
|
|
82
127
|
"eslint": "^8.0.0",
|
|
@@ -91,9 +136,7 @@
|
|
|
91
136
|
"ts-jest": "^29.0.0",
|
|
92
137
|
"typescript": "^5.3.0"
|
|
93
138
|
},
|
|
94
|
-
"
|
|
95
|
-
"
|
|
96
|
-
"esbuild": "^0.25.12",
|
|
97
|
-
"fs-extra": "^11.3.2"
|
|
139
|
+
"engines": {
|
|
140
|
+
"node": ">=18.0.0"
|
|
98
141
|
}
|
|
99
142
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<!doctype html><html><head><meta charset='utf-8'></head><body><div id='root'></div><script type='module' src='/
|
|
1
|
+
<!doctype html><html><head><meta charset='utf-8'></head><body><div id='root'></div><script type='module' src='/main.js'></script></body></html>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<!doctype html><html><head><meta charset='utf-8'></head><body><div id='root'></div><script type='module' src='/
|
|
1
|
+
<!doctype html><html><head><meta charset='utf-8'></head><body><div id='root'></div><script type='module' src='/main.js'></script></body></html>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<!doctype html><html><head><meta charset='utf-8' /></head><body><div id='root'></div><script type='module' src='/
|
|
1
|
+
<!doctype html><html><head><meta charset='utf-8' /></head><body><div id='root'></div><script type='module' src='/main.js'></script></body></html>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<!doctype html><html><head><meta charset='utf-8'></head><body><div id='root'></div><script type='module' src='/
|
|
1
|
+
<!doctype html><html><head><meta charset='utf-8'></head><body><div id='root'></div><script type='module' src='/main.js'></script></body></html>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<!doctype html><html><head><meta charset='utf-8'></head><body><div id='root'></div><script type='module' src='/
|
|
1
|
+
<!doctype html><html><head><meta charset='utf-8'></head><body><div id='root'></div><script type='module' src='/main.js'></script></body></html>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<!doctype html><html><head><meta charset='utf-8'></head><body><div id='root'></div><script type='module' src='/
|
|
1
|
+
<!doctype html><html><head><meta charset='utf-8'></head><body><div id='root'></div><script type='module' src='/main.js'></script></body></html>
|