@rspack/cli 0.3.13 → 0.3.14
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/commands/build.js
CHANGED
|
@@ -39,14 +39,12 @@ class BuildCommand {
|
|
|
39
39
|
}
|
|
40
40
|
}), async (options) => {
|
|
41
41
|
const logger = cli.getLogger();
|
|
42
|
-
// @ts-expect-error
|
|
43
42
|
let createJsonStringifyStream;
|
|
44
43
|
if (options.json) {
|
|
45
44
|
const jsonExt = await import("@discoveryjs/json-ext");
|
|
46
45
|
createJsonStringifyStream = jsonExt.default.stringifyStream;
|
|
47
46
|
}
|
|
48
|
-
|
|
49
|
-
const callback = (error, stats) => {
|
|
47
|
+
const errorHandler = (error, stats) => {
|
|
50
48
|
if (error) {
|
|
51
49
|
logger.error(error);
|
|
52
50
|
process.exit(2);
|
|
@@ -61,15 +59,11 @@ class BuildCommand {
|
|
|
61
59
|
? {
|
|
62
60
|
children: compiler.compilers.map(compiler => compiler.options ? compiler.options.stats : undefined)
|
|
63
61
|
}
|
|
64
|
-
:
|
|
65
|
-
compiler.options
|
|
66
|
-
|
|
67
|
-
compiler.options.stats
|
|
68
|
-
: undefined;
|
|
69
|
-
// @ts-expect-error
|
|
62
|
+
: compiler.options
|
|
63
|
+
? compiler.options.stats
|
|
64
|
+
: undefined;
|
|
70
65
|
if (options.json && createJsonStringifyStream) {
|
|
71
|
-
|
|
72
|
-
const handleWriteError = error => {
|
|
66
|
+
const handleWriteError = (error) => {
|
|
73
67
|
logger.error(error);
|
|
74
68
|
process.exit(2);
|
|
75
69
|
};
|
|
@@ -100,10 +94,6 @@ class BuildCommand {
|
|
|
100
94
|
}
|
|
101
95
|
};
|
|
102
96
|
const rspackOptions = { ...options, argv: { ...options } };
|
|
103
|
-
// @ts-expect-error
|
|
104
|
-
const errorHandler = (err, Stats) => {
|
|
105
|
-
callback(err, Stats);
|
|
106
|
-
};
|
|
107
97
|
const compiler = await cli.createCompiler(rspackOptions, "build", errorHandler);
|
|
108
98
|
if (!compiler)
|
|
109
99
|
return;
|
package/dist/rspack-cli.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export declare class RspackCLI {
|
|
|
7
7
|
colors: RspackCLIColors;
|
|
8
8
|
program: yargs.Argv;
|
|
9
9
|
constructor();
|
|
10
|
-
createCompiler(options: RspackBuildCLIOptions, rspackCommand: Command, callback?: (e: Error, res?: Stats | MultiStats) => void): Promise<MultiCompiler
|
|
10
|
+
createCompiler(options: RspackBuildCLIOptions, rspackCommand: Command, callback?: (e: Error | null, res?: Stats | MultiStats) => void): Promise<MultiCompiler | Compiler | null>;
|
|
11
11
|
createColors(useColor?: boolean): RspackCLIColors;
|
|
12
12
|
getLogger(): RspackCLILogger;
|
|
13
13
|
run(argv: string[]): Promise<void>;
|
package/dist/rspack-cli.js
CHANGED
|
@@ -62,7 +62,6 @@ class RspackCLI {
|
|
|
62
62
|
const isWatch = Array.isArray(config)
|
|
63
63
|
? config.some(i => i.watch)
|
|
64
64
|
: config.watch;
|
|
65
|
-
// @ts-expect-error
|
|
66
65
|
return (0, core_1.rspack)(config, isWatch ? callback : undefined);
|
|
67
66
|
}
|
|
68
67
|
createColors(useColor) {
|
|
@@ -90,7 +89,6 @@ class RspackCLI {
|
|
|
90
89
|
};
|
|
91
90
|
}
|
|
92
91
|
async run(argv) {
|
|
93
|
-
// @ts-expect-error
|
|
94
92
|
if (semver_1.default.lt(semver_1.default.clean(process.version), "14.0.0")) {
|
|
95
93
|
this.getLogger().warn(`Minimum recommended Node.js version is 14.0.0, current version is ${process.version}`);
|
|
96
94
|
}
|
|
@@ -220,10 +218,9 @@ class RspackCLI {
|
|
|
220
218
|
}
|
|
221
219
|
async loadConfig(options) {
|
|
222
220
|
var _a;
|
|
223
|
-
let loadedConfig = await (0, loadConfig_1.loadRspackConfig)(options);
|
|
221
|
+
let loadedConfig = (await (0, loadConfig_1.loadRspackConfig)(options));
|
|
224
222
|
if (options.configName) {
|
|
225
223
|
const notFoundConfigNames = [];
|
|
226
|
-
// @ts-expect-error
|
|
227
224
|
loadedConfig = options.configName.map((configName) => {
|
|
228
225
|
let found;
|
|
229
226
|
if (Array.isArray(loadedConfig)) {
|
|
@@ -238,6 +235,8 @@ class RspackCLI {
|
|
|
238
235
|
if (!found) {
|
|
239
236
|
notFoundConfigNames.push(configName);
|
|
240
237
|
}
|
|
238
|
+
// WARNING: if config is not found, the program will exit
|
|
239
|
+
// so assert here is okay to avoid runtime filtering
|
|
241
240
|
return found;
|
|
242
241
|
});
|
|
243
242
|
if (notFoundConfigNames.length > 0) {
|
|
@@ -248,14 +247,12 @@ class RspackCLI {
|
|
|
248
247
|
}
|
|
249
248
|
}
|
|
250
249
|
if (typeof loadedConfig === "function") {
|
|
251
|
-
// @ts-expect-error
|
|
252
250
|
loadedConfig = loadedConfig((_a = options.argv) === null || _a === void 0 ? void 0 : _a.env, options.argv);
|
|
253
251
|
// if return promise we should await its result
|
|
254
252
|
if (typeof loadedConfig.then === "function") {
|
|
255
253
|
loadedConfig = await loadedConfig;
|
|
256
254
|
}
|
|
257
255
|
}
|
|
258
|
-
// @ts-expect-error
|
|
259
256
|
return loadedConfig;
|
|
260
257
|
}
|
|
261
258
|
isMultipleCompiler(compiler) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { RspackCLIOptions } from "../types";
|
|
2
2
|
import { RspackOptions, MultiRspackOptions } from "@rspack/core";
|
|
3
|
-
export type LoadedRspackConfig = undefined | RspackOptions | MultiRspackOptions | ((env: Record<string, any>, argv
|
|
3
|
+
export type LoadedRspackConfig = undefined | RspackOptions | MultiRspackOptions | ((env: Record<string, any>, argv?: Record<string, any>) => RspackOptions | MultiRspackOptions);
|
|
4
4
|
export declare function loadRspackConfig(options: RspackCLIOptions, cwd?: string): Promise<LoadedRspackConfig>;
|
package/dist/utils/options.d.ts
CHANGED
package/dist/utils/options.js
CHANGED
|
@@ -84,15 +84,12 @@ const previewOptions = (yargs) => {
|
|
|
84
84
|
});
|
|
85
85
|
};
|
|
86
86
|
exports.previewOptions = previewOptions;
|
|
87
|
-
// @ts-expect-error
|
|
88
87
|
function normalizeEnv(argv) {
|
|
89
88
|
var _a;
|
|
90
|
-
// @ts-expect-error
|
|
91
89
|
function parseValue(previous, value) {
|
|
92
90
|
const [allKeys, val] = value.split(/=(.+)/, 2);
|
|
93
91
|
const splitKeys = allKeys.split(/\.(?!$)/);
|
|
94
92
|
let prevRef = previous;
|
|
95
|
-
// @ts-expect-error
|
|
96
93
|
splitKeys.forEach((someKey, index) => {
|
|
97
94
|
// https://github.com/webpack/webpack-cli/issues/3284
|
|
98
95
|
if (someKey.endsWith("=")) {
|
package/dist/utils/profile.js
CHANGED
|
@@ -131,15 +131,12 @@ class RspackProfileJSCPUProfilePlugin {
|
|
|
131
131
|
constructor(output) {
|
|
132
132
|
this.output = output;
|
|
133
133
|
}
|
|
134
|
-
// @ts-expect-error
|
|
135
134
|
apply(compiler) {
|
|
136
135
|
const session = new inspector_1.default.Session();
|
|
137
136
|
session.connect();
|
|
138
137
|
session.post("Profiler.enable");
|
|
139
138
|
session.post("Profiler.start");
|
|
140
|
-
compiler.hooks.done.tapAsync(RspackProfileJSCPUProfilePlugin.name,
|
|
141
|
-
// @ts-expect-error
|
|
142
|
-
(stats, callback) => {
|
|
139
|
+
compiler.hooks.done.tapAsync(RspackProfileJSCPUProfilePlugin.name, (_stats, callback) => {
|
|
143
140
|
if (compiler.watchMode)
|
|
144
141
|
return callback();
|
|
145
142
|
session.post("Profiler.stop", (error, param) => {
|
|
@@ -157,11 +154,8 @@ class RspackProfileLoggingPlugin {
|
|
|
157
154
|
constructor(output) {
|
|
158
155
|
this.output = output;
|
|
159
156
|
}
|
|
160
|
-
// @ts-expect-error
|
|
161
157
|
apply(compiler) {
|
|
162
|
-
compiler.hooks.done.tapAsync(RspackProfileLoggingPlugin.name,
|
|
163
|
-
// @ts-expect-error
|
|
164
|
-
(stats, callback) => {
|
|
158
|
+
compiler.hooks.done.tapAsync(RspackProfileLoggingPlugin.name, (stats, callback) => {
|
|
165
159
|
if (compiler.watchMode)
|
|
166
160
|
return callback();
|
|
167
161
|
const logging = stats.toJson({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rspack/cli",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.14",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "CLI for rspack",
|
|
6
6
|
"bin": {
|
|
@@ -37,8 +37,8 @@
|
|
|
37
37
|
"semver": "6.3.1",
|
|
38
38
|
"webpack-bundle-analyzer": "4.6.1",
|
|
39
39
|
"yargs": "17.6.2",
|
|
40
|
-
"@rspack/
|
|
41
|
-
"@rspack/
|
|
40
|
+
"@rspack/dev-server": "0.3.14",
|
|
41
|
+
"@rspack/core": "0.3.14"
|
|
42
42
|
},
|
|
43
43
|
"scripts": {
|
|
44
44
|
"build": "rimraf dist/ && tsc -b ./tsconfig.build.json --force",
|