react-client 1.0.30 ā 1.0.32
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 +32 -44
- package/dist/cli/commands/dev.js +437 -457
- package/dist/cli/commands/init.js +60 -71
- package/dist/cli/commands/preview.js +110 -122
- package/dist/cli/index.js +33 -34
- package/dist/server/broadcastManager.js +1 -1
- package/dist/utils/loadConfig.js +55 -66
- package/package.json +2 -2
|
@@ -1,50 +1,38 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
1
|
import esbuild from 'esbuild';
|
|
11
2
|
import path from 'path';
|
|
12
3
|
import fs from 'fs-extra';
|
|
13
4
|
import chalk from 'chalk';
|
|
14
5
|
import { loadReactClientConfig } from '../../utils/loadConfig';
|
|
15
|
-
export default function build() {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
process.exit(1);
|
|
48
|
-
}
|
|
49
|
-
});
|
|
6
|
+
export default async function build() {
|
|
7
|
+
const root = process.cwd();
|
|
8
|
+
const config = await loadReactClientConfig(root);
|
|
9
|
+
const appRoot = path.resolve(root, config.root || '.');
|
|
10
|
+
const outDir = path.join(appRoot, config.build?.outDir || '.react-client/build');
|
|
11
|
+
console.log(chalk.cyan(`\nšļø Building project...`));
|
|
12
|
+
console.log(chalk.gray(`Root: ${appRoot}`));
|
|
13
|
+
console.log(chalk.gray(`Output: ${outDir}\n`));
|
|
14
|
+
const entry = path.join(appRoot, 'src', 'main.tsx');
|
|
15
|
+
if (!fs.existsSync(entry)) {
|
|
16
|
+
console.error(chalk.red('ā Entry not found: src/main.tsx'));
|
|
17
|
+
process.exit(1);
|
|
18
|
+
}
|
|
19
|
+
await fs.ensureDir(outDir);
|
|
20
|
+
try {
|
|
21
|
+
await esbuild.build({
|
|
22
|
+
entryPoints: [entry],
|
|
23
|
+
bundle: true,
|
|
24
|
+
minify: true,
|
|
25
|
+
sourcemap: true,
|
|
26
|
+
outdir: outDir,
|
|
27
|
+
define: { 'process.env.NODE_ENV': '"production"' },
|
|
28
|
+
loader: { '.ts': 'ts', '.tsx': 'tsx', '.js': 'jsx', '.jsx': 'jsx' },
|
|
29
|
+
});
|
|
30
|
+
console.log(chalk.green(`ā
Build completed successfully!`));
|
|
31
|
+
console.log(chalk.gray(`Output directory: ${outDir}`));
|
|
32
|
+
}
|
|
33
|
+
catch (err) {
|
|
34
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
35
|
+
console.error('ā Build failed:', msg);
|
|
36
|
+
process.exit(1);
|
|
37
|
+
}
|
|
50
38
|
}
|