@rspack/cli 1.7.1 → 2.0.0-canary-20260116
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 +24 -0
- package/bin/rspack.js +2 -2
- package/dist/{131.mjs → 131.js} +32 -26
- package/dist/{1~274.mjs → 274.js} +1 -1
- package/dist/index.js +1 -1375
- package/dist/utils/options.d.ts +0 -2
- package/package.json +15 -12
- package/dist/0~274.js +0 -42
- package/dist/index.mjs +0 -1
- package/dist/utils/rspackCore.d.ts +0 -2
- /package/dist/{rslib-runtime.mjs → rslib-runtime.js} +0 -0
package/README.md
CHANGED
|
@@ -6,6 +6,30 @@
|
|
|
6
6
|
|
|
7
7
|
Command-line interface for rspack.
|
|
8
8
|
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
pnpm add -D @rspack/cli
|
|
13
|
+
# or
|
|
14
|
+
npm install -D @rspack/cli
|
|
15
|
+
# or
|
|
16
|
+
yarn add -D @rspack/cli
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Required dependencies
|
|
20
|
+
|
|
21
|
+
The `rspack dev` and `rspack preview` commands require [@rspack/dev-server](https://www.npmjs.com/package/@rspack/dev-server) to be installed as a peer dependency:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
pnpm add -D @rspack/dev-server
|
|
25
|
+
# or
|
|
26
|
+
npm install -D @rspack/dev-server
|
|
27
|
+
# or
|
|
28
|
+
yarn add -D @rspack/dev-server
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
If you try to use these commands without installing `@rspack/dev-server`, you will see a helpful error message with installation instructions.
|
|
32
|
+
|
|
9
33
|
## Wasm test
|
|
10
34
|
|
|
11
35
|
See [@rspack/test-tools](../rspack-test-tools) for details.
|
package/bin/rspack.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
2
|
+
import nodeModule from 'node:module';
|
|
3
3
|
|
|
4
4
|
// enable on-disk code caching of all modules loaded by Node.js
|
|
5
5
|
// requires Nodejs >= 22.8.0
|
|
@@ -15,7 +15,7 @@ if (enableCompileCache) {
|
|
|
15
15
|
// make it easier to identify the process via activity monitor or other tools
|
|
16
16
|
process.title = 'rspack-node';
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
import { RspackCLI } from '../dist/index.js';
|
|
19
19
|
|
|
20
20
|
async function runCLI() {
|
|
21
21
|
const cli = new RspackCLI();
|
package/dist/{131.mjs → 131.js}
RENAMED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
import * as __rspack_external_module from "module";
|
|
3
2
|
import * as __rspack_external_path from "path";
|
|
4
|
-
import { __webpack_require__ } from "./rslib-runtime.
|
|
3
|
+
import { __webpack_require__ } from "./rslib-runtime.js";
|
|
5
4
|
import node_path from "node:path";
|
|
6
5
|
import node_util from "node:util";
|
|
6
|
+
import { rspack } from "@rspack/core";
|
|
7
7
|
import { EventEmitter } from "events";
|
|
8
8
|
import node_fs from "node:fs";
|
|
9
9
|
import { createRequire } from "node:module";
|
|
@@ -668,12 +668,12 @@ const normalizeCommonOptions = (options, action)=>{
|
|
|
668
668
|
}
|
|
669
669
|
if ('devtool' in options) options.devtool = normalizeDevtoolOption(options.devtool);
|
|
670
670
|
};
|
|
671
|
-
const commonOptionsForBuildAndServe = (command)=>command.option('
|
|
671
|
+
const commonOptionsForBuildAndServe = (command)=>command.option('-d, --devtool <value>', 'specify a developer tool for debugging. Defaults to `cheap-module-source-map` in development and `source-map` in production.').option('--entry <entry>', 'entry file', {
|
|
672
672
|
type: [
|
|
673
673
|
String
|
|
674
674
|
],
|
|
675
675
|
default: []
|
|
676
|
-
}).option('-m, --mode <mode>', 'mode').option('-o, --output-path <dir>', 'output path dir').option('
|
|
676
|
+
}).option('-m, --mode <mode>', 'mode').option('-o, --output-path <dir>', 'output path dir').option('-w, --watch', 'watch');
|
|
677
677
|
function setBuiltinEnvArg(env, envNameSuffix, value) {
|
|
678
678
|
const envName = `RSPACK_${envNameSuffix}`;
|
|
679
679
|
if (!(envName in env)) env[envName] = value;
|
|
@@ -758,8 +758,6 @@ class BuildCommand {
|
|
|
758
758
|
});
|
|
759
759
|
}
|
|
760
760
|
}
|
|
761
|
-
const rspackCore_require = createRequire(import.meta.url);
|
|
762
|
-
const rspack = rspackCore_require('@rspack/core');
|
|
763
761
|
class PreviewCommand {
|
|
764
762
|
async apply(cli) {
|
|
765
763
|
const command = cli.program.command('preview [dir]', 'run the Rspack server for build output').alias('p');
|
|
@@ -767,7 +765,16 @@ class PreviewCommand {
|
|
|
767
765
|
command.action(async (dir, options)=>{
|
|
768
766
|
setDefaultNodeEnv(options, 'production');
|
|
769
767
|
normalizeCommonOptions(options, 'preview');
|
|
770
|
-
|
|
768
|
+
let RspackDevServer;
|
|
769
|
+
try {
|
|
770
|
+
const devServerModule = await import("@rspack/dev-server");
|
|
771
|
+
RspackDevServer = devServerModule.RspackDevServer;
|
|
772
|
+
} catch (error) {
|
|
773
|
+
const logger = cli.getLogger();
|
|
774
|
+
if (error?.code === 'MODULE_NOT_FOUND' || error?.code === 'ERR_MODULE_NOT_FOUND') logger.error('The "@rspack/dev-server" package is required to use the preview command.\nPlease install it by running:\n pnpm add -D @rspack/dev-server\n or\n npm install -D @rspack/dev-server');
|
|
775
|
+
else logger.error('Failed to load "@rspack/dev-server":\n' + (error?.message || String(error)));
|
|
776
|
+
process.exit(1);
|
|
777
|
+
}
|
|
771
778
|
let { config } = await cli.loadConfig(options);
|
|
772
779
|
config = await getPreviewConfig(config, options, dir);
|
|
773
780
|
if (!Array.isArray(config)) config = [
|
|
@@ -823,7 +830,16 @@ class ServeCommand {
|
|
|
823
830
|
setDefaultNodeEnv(cliOptions, 'development');
|
|
824
831
|
normalizeCommonOptions(cliOptions, 'serve');
|
|
825
832
|
cliOptions.hot = normalizeHotOption(cliOptions.hot);
|
|
826
|
-
|
|
833
|
+
let RspackDevServer;
|
|
834
|
+
try {
|
|
835
|
+
const devServerModule = await import("@rspack/dev-server");
|
|
836
|
+
RspackDevServer = devServerModule.RspackDevServer;
|
|
837
|
+
} catch (error) {
|
|
838
|
+
const logger = cli.getLogger();
|
|
839
|
+
if (error?.code === 'MODULE_NOT_FOUND' || error?.code === 'ERR_MODULE_NOT_FOUND') logger.error('The "@rspack/dev-server" package is required to use the serve command.\nPlease install it by running:\n pnpm add -D @rspack/dev-server\n or\n npm install -D @rspack/dev-server');
|
|
840
|
+
else logger.error('Failed to load "@rspack/dev-server":\n' + (error?.message || String(error)));
|
|
841
|
+
process.exit(1);
|
|
842
|
+
}
|
|
827
843
|
const userConfig = await cli.buildCompilerConfig(cliOptions, 'serve');
|
|
828
844
|
const compiler = await cli.createCompiler(userConfig);
|
|
829
845
|
if (!compiler) return;
|
|
@@ -923,13 +939,14 @@ const isEsmFile = (filePath)=>{
|
|
|
923
939
|
const packageJson = utils_readPackageUp(node_path.dirname(filePath));
|
|
924
940
|
return packageJson?.type === 'module';
|
|
925
941
|
};
|
|
942
|
+
const crossImport_require = createRequire(import.meta.url);
|
|
926
943
|
const crossImport = async (path)=>{
|
|
927
944
|
if (isEsmFile(path)) {
|
|
928
945
|
const url = pathToFileURL(path).href;
|
|
929
946
|
const { default: config } = await import(url);
|
|
930
947
|
return config;
|
|
931
948
|
}
|
|
932
|
-
let result =
|
|
949
|
+
let result = crossImport_require(path);
|
|
933
950
|
if (result && 'object' == typeof result && 'default' in result) result = result.default || {};
|
|
934
951
|
return result;
|
|
935
952
|
};
|
|
@@ -954,6 +971,7 @@ const isTsFile = (configPath)=>{
|
|
|
954
971
|
};
|
|
955
972
|
const utils_isTsFile = isTsFile;
|
|
956
973
|
const lib = __webpack_require__("../../node_modules/.pnpm/pirates@4.0.7/node_modules/pirates/lib/index.js");
|
|
974
|
+
const loadConfig_require = createRequire(import.meta.url);
|
|
957
975
|
const injectInlineSourceMap = ({ code, map })=>{
|
|
958
976
|
if (map) {
|
|
959
977
|
const base64Map = Buffer.from(map, 'utf8').toString('base64');
|
|
@@ -1040,7 +1058,7 @@ async function loadExtendedConfig(config, configPath, cwd, options) {
|
|
|
1040
1058
|
else throw new Error(`Extended configuration file "${resolvedPath}" not found.`);
|
|
1041
1059
|
}
|
|
1042
1060
|
} else try {
|
|
1043
|
-
resolvedPath =
|
|
1061
|
+
resolvedPath = loadConfig_require.resolve(extendPath, {
|
|
1044
1062
|
paths: [
|
|
1045
1063
|
baseDir,
|
|
1046
1064
|
cwd
|
|
@@ -1086,6 +1104,7 @@ async function loadRspackConfig(options, cwd = process.cwd()) {
|
|
|
1086
1104
|
configPath
|
|
1087
1105
|
};
|
|
1088
1106
|
}
|
|
1107
|
+
const picocolors = __webpack_require__("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
|
|
1089
1108
|
class RspackCLI {
|
|
1090
1109
|
colors;
|
|
1091
1110
|
program;
|
|
@@ -1094,7 +1113,7 @@ class RspackCLI {
|
|
|
1094
1113
|
this.colors = this.createColors();
|
|
1095
1114
|
this.program = program;
|
|
1096
1115
|
program.help();
|
|
1097
|
-
program.version("
|
|
1116
|
+
program.version("2.0.0-canary-20260116");
|
|
1098
1117
|
}
|
|
1099
1118
|
async buildCompilerConfig(options, rspackCommand) {
|
|
1100
1119
|
let { config, pathMap } = await this.loadConfig(options);
|
|
@@ -1158,20 +1177,8 @@ class RspackCLI {
|
|
|
1158
1177
|
};
|
|
1159
1178
|
item.output = item.output || {};
|
|
1160
1179
|
if (options.outputPath) item.output.path = node_path.resolve(process.cwd(), options.outputPath);
|
|
1161
|
-
if (options.analyze) {
|
|
1162
|
-
const { BundleAnalyzerPlugin } = await import("webpack-bundle-analyzer");
|
|
1163
|
-
(item.plugins ??= []).push({
|
|
1164
|
-
name: 'rspack-bundle-analyzer',
|
|
1165
|
-
apply (compiler) {
|
|
1166
|
-
new BundleAnalyzerPlugin({
|
|
1167
|
-
generateStatsFile: true
|
|
1168
|
-
}).apply(compiler);
|
|
1169
|
-
}
|
|
1170
|
-
});
|
|
1171
|
-
}
|
|
1172
|
-
if (options.profile) item.profile = true;
|
|
1173
1180
|
if (process.env.RSPACK_PROFILE) {
|
|
1174
|
-
const { applyProfile } = await import("./
|
|
1181
|
+
const { applyProfile } = await import("./274.js").then((mod)=>({
|
|
1175
1182
|
applyProfile: mod.applyProfile
|
|
1176
1183
|
}));
|
|
1177
1184
|
await applyProfile(process.env.RSPACK_PROFILE, process.env.RSPACK_TRACE_LAYER, process.env.RSPACK_TRACE_OUTPUT);
|
|
@@ -1185,7 +1192,7 @@ class RspackCLI {
|
|
|
1185
1192
|
const installed = (item.plugins ||= []).find((item)=>item instanceof rspack.ProgressPlugin);
|
|
1186
1193
|
if (!installed) (item.plugins ??= []).push(new rspack.ProgressPlugin());
|
|
1187
1194
|
}
|
|
1188
|
-
const cacheOptions = item.
|
|
1195
|
+
const cacheOptions = item.cache;
|
|
1189
1196
|
if ('object' == typeof cacheOptions && 'persistent' === cacheOptions.type) {
|
|
1190
1197
|
const configPaths = pathMap.get(item);
|
|
1191
1198
|
if (configPaths) cacheOptions.buildDependencies = [
|
|
@@ -1258,5 +1265,4 @@ function defineConfig(config) {
|
|
|
1258
1265
|
function definePlugin(plugin) {
|
|
1259
1266
|
return plugin;
|
|
1260
1267
|
}
|
|
1261
|
-
const picocolors = __webpack_require__("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
|
|
1262
1268
|
export { RspackCLI, defineConfig, definePlugin, node_fs, node_path, rspack };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { node_fs, node_path, rspack } from "./131.
|
|
1
|
+
import { node_fs, node_path, rspack } from "./131.js";
|
|
2
2
|
const DEFAULT_RUST_TRACE_LAYER = 'perfetto';
|
|
3
3
|
async function applyProfile(filterValue, traceLayer = DEFAULT_RUST_TRACE_LAYER, traceOutput) {
|
|
4
4
|
const { asyncExitHook } = await import("exit-hook");
|