@gravity-ui/app-builder 0.30.0 → 0.30.1
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.js +20 -15
- package/dist/commands/build/build-lib.js +8 -5
- package/dist/commands/build/build-service/client.js +6 -3
- package/dist/commands/build/build-service/index.js +7 -4
- package/dist/commands/build/build-service/server.js +17 -11
- package/dist/commands/build/index.js +6 -3
- package/dist/commands/dev/client.js +63 -34
- package/dist/commands/dev/index.js +50 -21
- package/dist/commands/dev/server.js +42 -13
- package/dist/common/babel/index.js +4 -1
- package/dist/common/babel/ui-preset.d.ts +1 -1
- package/dist/common/babel/ui-preset.js +1 -0
- package/dist/common/child-process/controllable-script.js +32 -5
- package/dist/common/child-process/utils.js +30 -4
- package/dist/common/command.js +2 -1
- package/dist/common/config.js +49 -19
- package/dist/common/env.js +5 -3
- package/dist/common/library/babel-plugin-replace-paths.js +4 -2
- package/dist/common/library/index.js +95 -66
- package/dist/common/logger/colors.js +8 -2
- package/dist/common/logger/index.js +24 -17
- package/dist/common/logger/log-config.js +6 -3
- package/dist/common/logger/pretty-time.js +6 -2
- package/dist/common/models/index.d.ts +1 -1
- package/dist/common/models/index.js +8 -3
- package/dist/common/paths.js +28 -3
- package/dist/common/s3-upload/compress.js +12 -8
- package/dist/common/s3-upload/create-plugin.js +30 -4
- package/dist/common/s3-upload/index.js +9 -3
- package/dist/common/s3-upload/s3-client.js +37 -11
- package/dist/common/s3-upload/upload.js +38 -9
- package/dist/common/s3-upload/webpack-plugin.js +9 -5
- package/dist/common/swc/compile.js +12 -9
- package/dist/common/swc/index.js +7 -2
- package/dist/common/swc/utils.js +13 -6
- package/dist/common/swc/watch.js +9 -6
- package/dist/common/typescript/compile.js +14 -11
- package/dist/common/typescript/diagnostic.js +37 -11
- package/dist/common/typescript/transformers.js +29 -3
- package/dist/common/typescript/utils.js +18 -8
- package/dist/common/typescript/watch.js +13 -10
- package/dist/common/utils.js +25 -14
- package/dist/common/webpack/compile.js +22 -16
- package/dist/common/webpack/config.js +113 -80
- package/dist/common/webpack/node-externals.js +34 -5
- package/dist/common/webpack/progress-plugin.js +6 -3
- package/dist/common/webpack/public-path.d.ts +1 -0
- package/dist/common/webpack/public-path.js +1 -0
- package/dist/common/webpack/rspack.js +5 -1
- package/dist/common/webpack/runtime-versioning-plugin.js +3 -1
- package/dist/common/webpack/storybook.js +51 -21
- package/dist/common/webpack/utils.js +36 -9
- package/dist/common/webpack/worker/public-path.worker.d.ts +1 -0
- package/dist/common/webpack/worker/public-path.worker.js +1 -0
- package/dist/common/webpack/worker/worker-loader.js +34 -4
- package/dist/create-cli.js +48 -19
- package/dist/index.js +27 -5
- package/package.json +1 -2
package/dist/cli.js
CHANGED
|
@@ -1,22 +1,27 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
"use strict";
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
const semver_1 = __importDefault(require("semver"));
|
|
8
|
+
const util_1 = __importDefault(require("util"));
|
|
9
|
+
const common_tags_1 = require("common-tags");
|
|
10
|
+
require("./common/env");
|
|
11
|
+
const logger_1 = __importDefault(require("./common/logger"));
|
|
12
|
+
const create_cli_1 = require("./create-cli");
|
|
8
13
|
const MIN_NODE_VERSION = '18.0.0';
|
|
9
14
|
const { version } = process;
|
|
10
|
-
if (!
|
|
15
|
+
if (!semver_1.default.satisfies(version, `>=${MIN_NODE_VERSION}`, {
|
|
11
16
|
includePrerelease: true,
|
|
12
17
|
})) {
|
|
13
|
-
|
|
18
|
+
logger_1.default.panic((0, common_tags_1.stripIndent) `
|
|
14
19
|
App-builder requires Node.js ${MIN_NODE_VERSION} or higher (you have ${version}).
|
|
15
20
|
Upgrade Node to the latest stable release.
|
|
16
21
|
`);
|
|
17
22
|
}
|
|
18
|
-
if (
|
|
19
|
-
|
|
23
|
+
if (semver_1.default.prerelease(version)) {
|
|
24
|
+
logger_1.default.warning((0, common_tags_1.stripIndent) `
|
|
20
25
|
You are currently using a prerelease version of Node (${version}), which is not supported.
|
|
21
26
|
You can use this for testing, but we do not recommend it in production.
|
|
22
27
|
Before reporting any bugs, please test with a supported version of Node (>=${MIN_NODE_VERSION}).
|
|
@@ -27,13 +32,13 @@ process.on('unhandledRejection', (reason) => {
|
|
|
27
32
|
// across versions and crash
|
|
28
33
|
// reason can be anything, it can be a message, an object, ANYTHING!
|
|
29
34
|
// we convert it to an error object
|
|
30
|
-
const error = reason instanceof Error ? reason : new Error(
|
|
31
|
-
|
|
35
|
+
const error = reason instanceof Error ? reason : new Error(util_1.default.format(reason));
|
|
36
|
+
logger_1.default.panic('UNHANDLED REJECTION', error);
|
|
32
37
|
});
|
|
33
38
|
process.on('uncaughtException', (error) => {
|
|
34
|
-
|
|
39
|
+
logger_1.default.panic('UNHANDLED EXCEPTION', error);
|
|
35
40
|
});
|
|
36
41
|
process.on('exit', (code) => {
|
|
37
|
-
|
|
42
|
+
logger_1.default.message(`Exit with code: ${code}`);
|
|
38
43
|
});
|
|
39
|
-
createCli(process.argv);
|
|
44
|
+
(0, create_cli_1.createCli)(process.argv);
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = default_1;
|
|
4
|
+
const signal_exit_1 = require("signal-exit");
|
|
5
|
+
const controllable_script_1 = require("../../common/child-process/controllable-script");
|
|
6
|
+
function default_1(config) {
|
|
4
7
|
return new Promise((resolve, reject) => {
|
|
5
|
-
const build = new ControllableScript(`
|
|
8
|
+
const build = new controllable_script_1.ControllableScript(`
|
|
6
9
|
const {buildLibrary} = require(${JSON.stringify(require.resolve('../../common/library'))});
|
|
7
10
|
buildLibrary({lib: ${JSON.stringify(config.lib)}});
|
|
8
11
|
`, null);
|
|
@@ -23,7 +26,7 @@ export default function (config) {
|
|
|
23
26
|
await build.stop('SIGTERM');
|
|
24
27
|
process.exit(1);
|
|
25
28
|
});
|
|
26
|
-
onExit((_code, signal) => {
|
|
29
|
+
(0, signal_exit_1.onExit)((_code, signal) => {
|
|
27
30
|
build.stop(signal);
|
|
28
31
|
});
|
|
29
32
|
}, (error) => {
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildClient = buildClient;
|
|
4
|
+
const compile_1 = require("../../../common/webpack/compile");
|
|
5
|
+
function buildClient(config) {
|
|
6
|
+
return (0, compile_1.clientCompile)(config.client, config.configPath);
|
|
4
7
|
}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = default_1;
|
|
4
|
+
const utils_1 = require("../../../common/utils");
|
|
5
|
+
function default_1(config) {
|
|
6
|
+
const shouldCompileClient = (0, utils_1.shouldCompileTarget)(config.target, 'client');
|
|
7
|
+
const shouldCompileServer = (0, utils_1.shouldCompileTarget)(config.target, 'server');
|
|
5
8
|
const compilations = [];
|
|
6
9
|
if (shouldCompileClient) {
|
|
7
10
|
compilations.push((async () => {
|
|
@@ -1,7 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.buildServer = buildServer;
|
|
7
|
+
const signal_exit_1 = require("signal-exit");
|
|
8
|
+
const controllable_script_1 = require("../../../common/child-process/controllable-script");
|
|
9
|
+
const paths_1 = __importDefault(require("../../../common/paths"));
|
|
10
|
+
const utils_1 = require("../../../common/utils");
|
|
5
11
|
function createSWCBuildScript(config) {
|
|
6
12
|
return `
|
|
7
13
|
const {Logger} = require(${JSON.stringify(require.resolve('../../../common/logger'))});
|
|
@@ -10,8 +16,8 @@ const {compile} = require(${JSON.stringify(require.resolve('../../../common/swc/
|
|
|
10
16
|
const logger = new Logger('server', ${config.verbose});
|
|
11
17
|
compile({
|
|
12
18
|
logger,
|
|
13
|
-
outputPath: ${JSON.stringify(
|
|
14
|
-
projectPath: ${JSON.stringify(
|
|
19
|
+
outputPath: ${JSON.stringify(paths_1.default.appDist)},
|
|
20
|
+
projectPath: ${JSON.stringify(paths_1.default.appServer)},
|
|
15
21
|
});`;
|
|
16
22
|
}
|
|
17
23
|
function createTypescriptBuildScript(config) {
|
|
@@ -29,12 +35,12 @@ const {Logger} = require(${JSON.stringify(require.resolve('../../../common/logge
|
|
|
29
35
|
const {compile} = require(${JSON.stringify(require.resolve('../../../common/typescript/compile'))});
|
|
30
36
|
|
|
31
37
|
const logger = new Logger('server', ${config.verbose});
|
|
32
|
-
compile(ts, {logger, projectPath: ${JSON.stringify(
|
|
38
|
+
compile(ts, {logger, projectPath: ${JSON.stringify(paths_1.default.appServer)}});`;
|
|
33
39
|
}
|
|
34
|
-
|
|
35
|
-
createRunFolder(config);
|
|
40
|
+
function buildServer(config) {
|
|
41
|
+
(0, utils_1.createRunFolder)(config);
|
|
36
42
|
return new Promise((resolve, reject) => {
|
|
37
|
-
const build = new ControllableScript(config.server.compiler === 'swc'
|
|
43
|
+
const build = new controllable_script_1.ControllableScript(config.server.compiler === 'swc'
|
|
38
44
|
? createSWCBuildScript(config)
|
|
39
45
|
: createTypescriptBuildScript(config), null);
|
|
40
46
|
build.start().then(() => {
|
|
@@ -54,7 +60,7 @@ export function buildServer(config) {
|
|
|
54
60
|
await build.stop('SIGTERM');
|
|
55
61
|
process.exit(1);
|
|
56
62
|
});
|
|
57
|
-
onExit((_code, signal) => {
|
|
63
|
+
(0, signal_exit_1.onExit)((_code, signal) => {
|
|
58
64
|
build.stop(signal);
|
|
59
65
|
});
|
|
60
66
|
}, (error) => {
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = default_1;
|
|
4
|
+
const models_1 = require("../../common/models");
|
|
5
|
+
async function default_1(config) {
|
|
3
6
|
process.env.NODE_ENV = 'production';
|
|
4
7
|
// eslint-disable-next-line security/detect-non-literal-require
|
|
5
|
-
const { default: build } = require(isLibraryConfig(config) ? './build-lib' : './build-service');
|
|
8
|
+
const { default: build } = require((0, models_1.isLibraryConfig)(config) ? './build-lib' : './build-service');
|
|
6
9
|
return build(config);
|
|
7
10
|
}
|
|
@@ -1,17 +1,46 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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 (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.watchClientCompilation = watchClientCompilation;
|
|
30
|
+
const path = __importStar(require("node:path"));
|
|
31
|
+
const fs = __importStar(require("node:fs"));
|
|
32
|
+
const webpack_1 = __importDefault(require("webpack"));
|
|
33
|
+
const webpack_dev_server_1 = __importDefault(require("webpack-dev-server"));
|
|
34
|
+
const webpack_manifest_plugin_1 = require("webpack-manifest-plugin");
|
|
35
|
+
const webpack_assets_manifest_1 = __importDefault(require("webpack-assets-manifest"));
|
|
36
|
+
const utils_1 = require("../../common/utils");
|
|
37
|
+
const rspack_manifest_plugin_1 = require("rspack-manifest-plugin");
|
|
38
|
+
const core_1 = require("@rspack/core");
|
|
39
|
+
const dev_server_1 = require("@rspack/dev-server");
|
|
40
|
+
const paths_1 = __importDefault(require("../../common/paths"));
|
|
41
|
+
const logger_1 = require("../../common/logger");
|
|
42
|
+
const config_1 = require("../../common/webpack/config");
|
|
43
|
+
async function watchClientCompilation(config, onManifestReady) {
|
|
15
44
|
const clientCompilation = await buildDevServer(config);
|
|
16
45
|
const compiler = clientCompilation.compiler;
|
|
17
46
|
subscribeToManifestReadyEvent(compiler, onManifestReady);
|
|
@@ -19,7 +48,7 @@ export async function watchClientCompilation(config, onManifestReady) {
|
|
|
19
48
|
}
|
|
20
49
|
async function buildDevServer(config) {
|
|
21
50
|
const bundler = config.client.bundler;
|
|
22
|
-
const logger = new Logger('client', config.verbose);
|
|
51
|
+
const logger = new logger_1.Logger('client', config.verbose);
|
|
23
52
|
const { publicPath } = config.client;
|
|
24
53
|
const { webSocketPath = path.normalize(`/${publicPath}/sockjs-node`), writeToDisk, ...devServer } = config.client.devServer || {};
|
|
25
54
|
const normalizedConfig = { ...config.client, devServer: { ...devServer, webSocketPath } };
|
|
@@ -28,7 +57,7 @@ async function buildDevServer(config) {
|
|
|
28
57
|
let rspackConfigs = [];
|
|
29
58
|
if (bundler === 'webpack') {
|
|
30
59
|
webpackConfigs = [
|
|
31
|
-
await webpackConfigFactory({
|
|
60
|
+
await (0, config_1.webpackConfigFactory)({
|
|
32
61
|
webpackMode: "development" /* WebpackMode.Dev */,
|
|
33
62
|
config: normalizedConfig,
|
|
34
63
|
configPath: config.configPath,
|
|
@@ -36,8 +65,8 @@ async function buildDevServer(config) {
|
|
|
36
65
|
}),
|
|
37
66
|
];
|
|
38
67
|
if (isSsr) {
|
|
39
|
-
const ssrLogger = new Logger('client(SSR)', config.verbose);
|
|
40
|
-
webpackConfigs.push(await webpackConfigFactory({
|
|
68
|
+
const ssrLogger = new logger_1.Logger('client(SSR)', config.verbose);
|
|
69
|
+
webpackConfigs.push(await (0, config_1.webpackConfigFactory)({
|
|
41
70
|
webpackMode: "development" /* WebpackMode.Dev */,
|
|
42
71
|
config: normalizedConfig,
|
|
43
72
|
configPath: config.configPath,
|
|
@@ -48,7 +77,7 @@ async function buildDevServer(config) {
|
|
|
48
77
|
}
|
|
49
78
|
else {
|
|
50
79
|
rspackConfigs = [
|
|
51
|
-
await rspackConfigFactory({
|
|
80
|
+
await (0, config_1.rspackConfigFactory)({
|
|
52
81
|
webpackMode: "development" /* WebpackMode.Dev */,
|
|
53
82
|
config: normalizedConfig,
|
|
54
83
|
configPath: config.configPath,
|
|
@@ -56,8 +85,8 @@ async function buildDevServer(config) {
|
|
|
56
85
|
}),
|
|
57
86
|
];
|
|
58
87
|
if (isSsr) {
|
|
59
|
-
const ssrLogger = new Logger('client(SSR)', config.verbose);
|
|
60
|
-
rspackConfigs.push(await rspackConfigFactory({
|
|
88
|
+
const ssrLogger = new logger_1.Logger('client(SSR)', config.verbose);
|
|
89
|
+
rspackConfigs.push(await (0, config_1.rspackConfigFactory)({
|
|
61
90
|
webpackMode: "development" /* WebpackMode.Dev */,
|
|
62
91
|
config: normalizedConfig,
|
|
63
92
|
configPath: config.configPath,
|
|
@@ -69,14 +98,14 @@ async function buildDevServer(config) {
|
|
|
69
98
|
// Rspack multicompiler dont work with lazy compilation.
|
|
70
99
|
// Pass a single config to avoid multicompiler when SSR disabled.
|
|
71
100
|
const compiler = bundler === 'rspack'
|
|
72
|
-
? rspack(isSsr ? rspackConfigs : rspackConfigs[0])
|
|
73
|
-
:
|
|
74
|
-
const staticFolder = path.resolve(
|
|
101
|
+
? (0, core_1.rspack)(isSsr ? rspackConfigs : rspackConfigs[0])
|
|
102
|
+
: (0, webpack_1.default)(webpackConfigs);
|
|
103
|
+
const staticFolder = path.resolve(paths_1.default.appDist, 'public');
|
|
75
104
|
const options = {
|
|
76
105
|
static: staticFolder,
|
|
77
106
|
setupMiddlewares(middlewares) {
|
|
78
107
|
if (config.client.lazyCompilation && bundler === 'rspack') {
|
|
79
|
-
const lazyCompilationMiddleware = rspack.experiments.lazyCompilationMiddleware(compiler, rspackConfigs[0]?.experiments?.lazyCompilation);
|
|
108
|
+
const lazyCompilationMiddleware = core_1.rspack.experiments.lazyCompilationMiddleware(compiler, rspackConfigs[0]?.experiments?.lazyCompilation);
|
|
80
109
|
return [lazyCompilationMiddleware, ...middlewares];
|
|
81
110
|
}
|
|
82
111
|
return middlewares;
|
|
@@ -88,7 +117,7 @@ async function buildDevServer(config) {
|
|
|
88
117
|
if (writeToDisk === true) {
|
|
89
118
|
return true;
|
|
90
119
|
}
|
|
91
|
-
if (isSsr && target.startsWith(
|
|
120
|
+
if (isSsr && target.startsWith(paths_1.default.appSsrBuild)) {
|
|
92
121
|
return true;
|
|
93
122
|
}
|
|
94
123
|
if (typeof writeToDisk === 'function') {
|
|
@@ -123,7 +152,7 @@ async function buildDevServer(config) {
|
|
|
123
152
|
};
|
|
124
153
|
const listenOn = options.port || options.ipc;
|
|
125
154
|
if (!listenOn) {
|
|
126
|
-
options.ipc = path.resolve(getAppRunPath(config), 'client.sock');
|
|
155
|
+
options.ipc = path.resolve((0, utils_1.getAppRunPath)(config), 'client.sock');
|
|
127
156
|
}
|
|
128
157
|
const proxy = options.proxy || [];
|
|
129
158
|
if (config.client.lazyCompilation && bundler !== 'rspack') {
|
|
@@ -155,10 +184,10 @@ async function buildDevServer(config) {
|
|
|
155
184
|
options.proxy = proxy;
|
|
156
185
|
let server;
|
|
157
186
|
if (bundler === 'rspack') {
|
|
158
|
-
server = new RspackDevServer(options, compiler);
|
|
187
|
+
server = new dev_server_1.RspackDevServer(options, compiler);
|
|
159
188
|
}
|
|
160
189
|
else {
|
|
161
|
-
server = new
|
|
190
|
+
server = new webpack_dev_server_1.default(options, compiler);
|
|
162
191
|
}
|
|
163
192
|
try {
|
|
164
193
|
await server.start();
|
|
@@ -185,21 +214,21 @@ function subscribeToManifestReadyEvent(compiler, onManifestReady) {
|
|
|
185
214
|
throw new Error('Something goes wrong!');
|
|
186
215
|
}
|
|
187
216
|
if (!isRspackCompiler(currentCompiler)) {
|
|
188
|
-
const assetsManifestPlugin = config.plugins.find((plugin) => plugin instanceof
|
|
217
|
+
const assetsManifestPlugin = config.plugins.find((plugin) => plugin instanceof webpack_assets_manifest_1.default);
|
|
189
218
|
if (assetsManifestPlugin) {
|
|
190
|
-
const assetsManifestReady = deferredPromise();
|
|
219
|
+
const assetsManifestReady = (0, utils_1.deferredPromise)();
|
|
191
220
|
promises.push(assetsManifestReady.promise);
|
|
192
221
|
assetsManifestPlugin.hooks.done.tap('app-builder', assetsManifestReady.resolve);
|
|
193
222
|
}
|
|
194
223
|
}
|
|
195
|
-
const manifestReady = deferredPromise();
|
|
224
|
+
const manifestReady = (0, utils_1.deferredPromise)();
|
|
196
225
|
promises.push(manifestReady.promise);
|
|
197
226
|
if (isRspackCompiler(currentCompiler)) {
|
|
198
|
-
const { afterEmit } =
|
|
227
|
+
const { afterEmit } = (0, rspack_manifest_plugin_1.getCompilerHooks)(currentCompiler);
|
|
199
228
|
afterEmit.tap('app-builder', manifestReady.resolve);
|
|
200
229
|
}
|
|
201
230
|
else {
|
|
202
|
-
const { afterEmit } = getCompilerHooks(currentCompiler);
|
|
231
|
+
const { afterEmit } = (0, webpack_manifest_plugin_1.getCompilerHooks)(currentCompiler);
|
|
203
232
|
afterEmit.tap('app-builder', manifestReady.resolve);
|
|
204
233
|
}
|
|
205
234
|
}
|
|
@@ -1,40 +1,69 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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 (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.default = default_1;
|
|
30
|
+
const path = __importStar(require("node:path"));
|
|
31
|
+
const fs = __importStar(require("node:fs"));
|
|
32
|
+
const nodemon_1 = __importDefault(require("nodemon"));
|
|
33
|
+
const signal_exit_1 = require("signal-exit");
|
|
34
|
+
const rimraf_1 = require("rimraf");
|
|
35
|
+
const utils_1 = require("../../common/utils");
|
|
36
|
+
const logger_1 = __importDefault(require("../../common/logger"));
|
|
37
|
+
const paths_1 = __importDefault(require("../../common/paths"));
|
|
38
|
+
async function default_1(config) {
|
|
10
39
|
process.env.NODE_ENV = 'development';
|
|
11
|
-
const shouldCompileClient = shouldCompileTarget(config.target, 'client');
|
|
12
|
-
const shouldCompileServer = shouldCompileTarget(config.target, 'server');
|
|
13
|
-
const appRunPath = getAppRunPath(config);
|
|
40
|
+
const shouldCompileClient = (0, utils_1.shouldCompileTarget)(config.target, 'client');
|
|
41
|
+
const shouldCompileServer = (0, utils_1.shouldCompileTarget)(config.target, 'server');
|
|
42
|
+
const appRunPath = (0, utils_1.getAppRunPath)(config);
|
|
14
43
|
if (shouldCompileClient && shouldCompileServer) {
|
|
15
44
|
try {
|
|
16
45
|
fs.accessSync(appRunPath, fs.constants.W_OK | fs.constants.X_OK); // eslint-disable-line no-bitwise
|
|
17
|
-
rimraf.sync(appRunPath);
|
|
46
|
+
rimraf_1.rimraf.sync(appRunPath);
|
|
18
47
|
}
|
|
19
48
|
catch (error) {
|
|
20
|
-
|
|
49
|
+
logger_1.default.warning(`Failed to remove appRun path [${appRunPath}]: ${error}`);
|
|
21
50
|
}
|
|
22
51
|
}
|
|
23
52
|
let clientCompiled = !shouldCompileClient;
|
|
24
53
|
let serverCompiled = !shouldCompileServer;
|
|
25
54
|
let needToStartNodemon = shouldCompileServer;
|
|
26
|
-
const serverPath = path.resolve(
|
|
55
|
+
const serverPath = path.resolve(paths_1.default.appDist, 'server');
|
|
27
56
|
const { inspect, inspectBrk } = config.server;
|
|
28
57
|
const startNodemon = () => {
|
|
29
58
|
if (needToStartNodemon && serverCompiled && clientCompiled) {
|
|
30
|
-
|
|
59
|
+
logger_1.default.message('Starting application at', serverPath);
|
|
31
60
|
const nodeArgs = ['--enable-source-maps'];
|
|
32
61
|
if (inspect || inspectBrk) {
|
|
33
62
|
nodeArgs.push(`--${inspect ? 'inspect' : 'inspect-brk'}=:::${inspect || inspectBrk}`);
|
|
34
63
|
}
|
|
35
64
|
const serverWatch = config.server.watch ?? [];
|
|
36
65
|
const delay = config.server.watchThrottle;
|
|
37
|
-
const nodemonInstance =
|
|
66
|
+
const nodemonInstance = (0, nodemon_1.default)({
|
|
38
67
|
ext: 'js json',
|
|
39
68
|
script: `${serverPath}/index.js`,
|
|
40
69
|
args: ['--dev', config.server.port ? `--port=${config.server.port}` : ''],
|
|
@@ -64,24 +93,24 @@ export default async function (config) {
|
|
|
64
93
|
if (shouldCompileClient) {
|
|
65
94
|
const { watchClientCompilation } = await import('./client.js');
|
|
66
95
|
clientCompilation = await watchClientCompilation(config, () => {
|
|
67
|
-
|
|
96
|
+
logger_1.default.success('Manifest was compiled successfully');
|
|
68
97
|
clientCompiled = true;
|
|
69
98
|
startNodemon();
|
|
70
99
|
});
|
|
71
100
|
}
|
|
72
101
|
process.on('SIGINT', async () => {
|
|
73
|
-
|
|
102
|
+
logger_1.default.success('\nCleaning up...');
|
|
74
103
|
await serverCompilation?.stop('SIGINT');
|
|
75
104
|
await clientCompilation?.stop();
|
|
76
105
|
process.exit(1);
|
|
77
106
|
});
|
|
78
107
|
process.on('SIGTERM', async () => {
|
|
79
|
-
|
|
108
|
+
logger_1.default.success('\nCleaning up...');
|
|
80
109
|
await serverCompilation?.stop('SIGTERM');
|
|
81
110
|
await clientCompilation?.stop();
|
|
82
111
|
process.exit(1);
|
|
83
112
|
});
|
|
84
|
-
onExit((_code, signal) => {
|
|
113
|
+
(0, signal_exit_1.onExit)((_code, signal) => {
|
|
85
114
|
serverCompilation?.stop(signal);
|
|
86
115
|
clientCompilation?.stop();
|
|
87
116
|
});
|
|
@@ -1,8 +1,37 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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 (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.watchServerCompilation = watchServerCompilation;
|
|
30
|
+
const path = __importStar(require("node:path"));
|
|
31
|
+
const rimraf_1 = require("rimraf");
|
|
32
|
+
const controllable_script_1 = require("../../common/child-process/controllable-script");
|
|
33
|
+
const utils_1 = require("../../common/utils");
|
|
34
|
+
const paths_1 = __importDefault(require("../../common/paths"));
|
|
6
35
|
function createTypescriptBuildScript(config) {
|
|
7
36
|
return `
|
|
8
37
|
let ts;
|
|
@@ -20,7 +49,7 @@ const {watch} = require(${JSON.stringify(require.resolve('../../common/typescrip
|
|
|
20
49
|
const logger = new Logger('server', ${config.verbose});
|
|
21
50
|
watch(
|
|
22
51
|
ts,
|
|
23
|
-
${JSON.stringify(
|
|
52
|
+
${JSON.stringify(paths_1.default.appServer)},
|
|
24
53
|
{
|
|
25
54
|
logger,
|
|
26
55
|
onAfterFilesEmitted: () => {
|
|
@@ -37,9 +66,9 @@ const {watch} = require(${JSON.stringify(require.resolve('../../common/swc/watch
|
|
|
37
66
|
|
|
38
67
|
const logger = new Logger('server', ${config.verbose});
|
|
39
68
|
watch(
|
|
40
|
-
${JSON.stringify(
|
|
69
|
+
${JSON.stringify(paths_1.default.appServer)},
|
|
41
70
|
{
|
|
42
|
-
outputPath: ${JSON.stringify(
|
|
71
|
+
outputPath: ${JSON.stringify(paths_1.default.appDist)},
|
|
43
72
|
logger,
|
|
44
73
|
onAfterFilesEmitted: () => {
|
|
45
74
|
process.send({type: 'Emitted'});
|
|
@@ -47,11 +76,11 @@ watch(
|
|
|
47
76
|
}
|
|
48
77
|
);`;
|
|
49
78
|
}
|
|
50
|
-
|
|
51
|
-
const serverPath = path.resolve(
|
|
52
|
-
rimraf.sync(serverPath);
|
|
53
|
-
createRunFolder(config);
|
|
54
|
-
const build = new ControllableScript(config.server.compiler === 'swc'
|
|
79
|
+
async function watchServerCompilation(config) {
|
|
80
|
+
const serverPath = path.resolve(paths_1.default.appDist, 'server');
|
|
81
|
+
rimraf_1.rimraf.sync(serverPath);
|
|
82
|
+
(0, utils_1.createRunFolder)(config);
|
|
83
|
+
const build = new controllable_script_1.ControllableScript(config.server.compiler === 'swc'
|
|
55
84
|
? createSWCBuildScript(config)
|
|
56
85
|
: createTypescriptBuildScript(config), null);
|
|
57
86
|
await build.start();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export {};
|
|
@@ -1,7 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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 (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.ControllableScript = void 0;
|
|
27
|
+
const utils_1 = require("./utils");
|
|
28
|
+
const fs = __importStar(require("fs-extra"));
|
|
29
|
+
const utils_2 = require("../utils");
|
|
30
|
+
class ControllableScript {
|
|
5
31
|
isRunning = false;
|
|
6
32
|
process;
|
|
7
33
|
script = '';
|
|
@@ -12,7 +38,7 @@ export class ControllableScript {
|
|
|
12
38
|
}
|
|
13
39
|
async start() {
|
|
14
40
|
const args = [];
|
|
15
|
-
const tmpFileName = tmpNameSync(await getCacheDir());
|
|
41
|
+
const tmpFileName = (0, utils_1.tmpNameSync)(await (0, utils_2.getCacheDir)());
|
|
16
42
|
fs.outputFileSync(tmpFileName, this.script);
|
|
17
43
|
this.isRunning = true;
|
|
18
44
|
// Passing --inspect isn't necessary for the child process to launch a port, but it allows some editors to automatically attach
|
|
@@ -97,3 +123,4 @@ export class ControllableScript {
|
|
|
97
123
|
this.process.send(msg);
|
|
98
124
|
}
|
|
99
125
|
}
|
|
126
|
+
exports.ControllableScript = ControllableScript;
|