react-client 1.0.28 → 1.0.31
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/dist/cli/commands/build.js +19 -25
- package/dist/cli/commands/dev.js +289 -205
- package/dist/cli/commands/init.js +34 -40
- package/dist/cli/commands/preview.js +41 -47
- package/dist/cli/index.js +49 -50
- package/dist/cli/types.js +1 -3
- package/dist/index.js +2 -20
- package/dist/server/broadcastManager.js +8 -15
- package/dist/utils/loadConfig.js +24 -63
- package/dist/utils/string.js +1 -4
- package/package.json +7 -6
package/dist/utils/loadConfig.js
CHANGED
|
@@ -1,61 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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");
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import fs from 'fs-extra';
|
|
3
|
+
import { pathToFileURL } from 'url';
|
|
4
|
+
import chalk from 'chalk';
|
|
5
|
+
import { build } from 'esbuild';
|
|
45
6
|
/**
|
|
46
7
|
* Dynamically loads react-client.config.(ts|js|mjs)
|
|
47
8
|
* Compiles .ts and .js configs to .mjs temporarily for import.
|
|
48
9
|
*/
|
|
49
|
-
async function loadReactClientConfig(cwd) {
|
|
10
|
+
export async function loadReactClientConfig(cwd) {
|
|
50
11
|
let projectRoot = cwd;
|
|
51
12
|
try {
|
|
52
13
|
// Detect if running inside react-client repo for local testing
|
|
53
|
-
const pkgPath =
|
|
54
|
-
if (await
|
|
55
|
-
const pkg = JSON.parse(await
|
|
56
|
-
if (pkg.name === 'react-client' && (await
|
|
57
|
-
console.log(
|
|
58
|
-
projectRoot =
|
|
14
|
+
const pkgPath = path.join(cwd, 'package.json');
|
|
15
|
+
if (await fs.pathExists(pkgPath)) {
|
|
16
|
+
const pkg = JSON.parse(await fs.readFile(pkgPath, 'utf8'));
|
|
17
|
+
if (pkg.name === 'react-client' && (await fs.pathExists(path.join(cwd, 'myapp')))) {
|
|
18
|
+
console.log(chalk.gray('🧩 Detected local CLI environment, using ./myapp as root.'));
|
|
19
|
+
projectRoot = path.join(cwd, 'myapp');
|
|
59
20
|
}
|
|
60
21
|
}
|
|
61
22
|
const filenames = [
|
|
@@ -65,21 +26,21 @@ async function loadReactClientConfig(cwd) {
|
|
|
65
26
|
];
|
|
66
27
|
let configFile = null;
|
|
67
28
|
for (const name of filenames) {
|
|
68
|
-
const file =
|
|
69
|
-
if (await
|
|
29
|
+
const file = path.join(projectRoot, name);
|
|
30
|
+
if (await fs.pathExists(file)) {
|
|
70
31
|
configFile = file;
|
|
71
32
|
break;
|
|
72
33
|
}
|
|
73
34
|
}
|
|
74
35
|
if (!configFile) {
|
|
75
|
-
console.log(
|
|
36
|
+
console.log(chalk.gray('ℹ️ No react-client.config found, using defaults.'));
|
|
76
37
|
return {};
|
|
77
38
|
}
|
|
78
|
-
const ext =
|
|
79
|
-
const tempFile =
|
|
39
|
+
const ext = path.extname(configFile);
|
|
40
|
+
const tempFile = path.join(projectRoot, `.react-client.temp-${Date.now()}.mjs`);
|
|
80
41
|
// 🧠 Always compile .ts or .js → .mjs for safe ESM import
|
|
81
42
|
if (ext === '.ts' || ext === '.js') {
|
|
82
|
-
await
|
|
43
|
+
await build({
|
|
83
44
|
entryPoints: [configFile],
|
|
84
45
|
outfile: tempFile,
|
|
85
46
|
platform: 'node',
|
|
@@ -91,19 +52,19 @@ async function loadReactClientConfig(cwd) {
|
|
|
91
52
|
});
|
|
92
53
|
}
|
|
93
54
|
else {
|
|
94
|
-
await
|
|
55
|
+
await fs.copyFile(configFile, tempFile);
|
|
95
56
|
}
|
|
96
57
|
// Import via file:// URL
|
|
97
|
-
const fileUrl =
|
|
98
|
-
const mod = await
|
|
99
|
-
await
|
|
58
|
+
const fileUrl = pathToFileURL(tempFile).href;
|
|
59
|
+
const mod = await import(fileUrl);
|
|
60
|
+
await fs.remove(tempFile);
|
|
100
61
|
const config = mod.default || mod;
|
|
101
|
-
console.log(
|
|
62
|
+
console.log(chalk.green(`🧩 Loaded config from ${path.basename(configFile)}`));
|
|
102
63
|
return config;
|
|
103
64
|
}
|
|
104
65
|
catch (err) {
|
|
105
66
|
const msg = err instanceof Error ? err.message : String(err);
|
|
106
|
-
console.error(
|
|
67
|
+
console.error(chalk.red(`❌ Could not load config (${path.join(cwd, 'react-client.config.js')}): ${msg}`));
|
|
107
68
|
return {};
|
|
108
69
|
}
|
|
109
70
|
}
|
package/dist/utils/string.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-client",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.31",
|
|
4
4
|
"description": "react-client is a lightweight CLI and runtime for building React apps with fast iteration.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Venkatesh Sundaram",
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"scripts": {
|
|
63
63
|
"clean": "rm -rf dist .turbo .react-client.temp.config*",
|
|
64
64
|
"compile": "tsc -p tsconfig.build.json",
|
|
65
|
-
"build": "
|
|
65
|
+
"build": "tsc -p tsconfig.build.json && node scripts/fix-extensions.mjs",
|
|
66
66
|
"build:cli": "node dist/cli/index.js build",
|
|
67
67
|
"dev": "node dist/cli/index.js dev",
|
|
68
68
|
"prepare": "npm run compile",
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
"release": "standard-version",
|
|
73
73
|
"postrelease": "git push --follow-tags",
|
|
74
74
|
"prepublishOnly": "npm run lint && npm run format:check && npm run build && npm test",
|
|
75
|
-
"test": "jest",
|
|
75
|
+
"test": "jest --passWithNoTests",
|
|
76
76
|
"typecheck": "tsc --noEmit",
|
|
77
77
|
"verify": "bash scripts/local-verify.sh"
|
|
78
78
|
},
|
|
@@ -113,7 +113,7 @@
|
|
|
113
113
|
"@types/commander": "^2.12.0",
|
|
114
114
|
"@types/connect": "^3.4.38",
|
|
115
115
|
"@types/fs-extra": "^9.0.13",
|
|
116
|
-
"@types/jest": "^29.
|
|
116
|
+
"@types/jest": "^29.5.14",
|
|
117
117
|
"@types/node": "^18.0.0",
|
|
118
118
|
"@types/prompts": "^2.4.9",
|
|
119
119
|
"@types/serve-static": "^1.15.5",
|
|
@@ -125,13 +125,14 @@
|
|
|
125
125
|
"eslint-plugin-prettier": "^4.0.0",
|
|
126
126
|
"eslint-plugin-react": "^7.32.2",
|
|
127
127
|
"husky": "^9.1.7",
|
|
128
|
-
"jest": "^29.
|
|
128
|
+
"jest": "^29.7.0",
|
|
129
129
|
"lint-staged": "^15.4.3",
|
|
130
130
|
"prettier": "^2.8.8",
|
|
131
131
|
"standard-version": "^9.5.0",
|
|
132
|
-
"ts-jest": "^29.
|
|
132
|
+
"ts-jest": "^29.4.5",
|
|
133
133
|
"typescript": "^5.3.0"
|
|
134
134
|
},
|
|
135
|
+
"type": "module",
|
|
135
136
|
"engines": {
|
|
136
137
|
"node": ">=18.0.0"
|
|
137
138
|
}
|