@rspack/cli 1.2.5 → 1.2.7-alpha.0

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.
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  exports.ids = [
3
- '737'
3
+ '197'
4
4
  ];
5
5
  exports.modules = {
6
6
  "./src/utils/profile.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
@@ -1,5 +1,5 @@
1
1
  export const ids = [
2
- '737'
2
+ '197'
3
3
  ];
4
4
  export const modules = {
5
5
  "./src/utils/profile.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
package/dist/index.js CHANGED
@@ -135,12 +135,24 @@ var __webpack_exports__ = {};
135
135
  describe: "config file",
136
136
  alias: "c"
137
137
  },
138
+ configName: {
139
+ type: "array",
140
+ string: true,
141
+ describe: "Name of the configuration to use."
142
+ },
143
+ configLoader: {
144
+ type: "string",
145
+ default: "register",
146
+ describe: "Specify the loader to load the config file, can be `native` or `register`."
147
+ }
148
+ });
149
+ const commonOptionsForBuildAndServe = (yargs)=>yargs.options({
138
150
  entry: {
139
151
  type: "array",
140
152
  string: true,
141
153
  describe: "entry file"
142
154
  },
143
- "output-path": {
155
+ outputPath: {
144
156
  type: "string",
145
157
  describe: "output path dir",
146
158
  alias: "o"
@@ -161,7 +173,7 @@ var __webpack_exports__ = {};
161
173
  string: true,
162
174
  describe: "env passed to config function"
163
175
  },
164
- "node-env": {
176
+ nodeEnv: {
165
177
  string: true,
166
178
  describe: "sets process.env.NODE_ENV to be specified value"
167
179
  },
@@ -170,57 +182,11 @@ var __webpack_exports__ = {};
170
182
  default: false,
171
183
  describe: "devtool",
172
184
  alias: "d"
173
- },
174
- configName: {
175
- type: "array",
176
- string: true,
177
- describe: "Name of the configuration to use."
178
- },
179
- "config-loader": {
180
- type: "string",
181
- default: "register",
182
- describe: "Specify the loader to load the config file, can be `native` or `register`."
183
185
  }
184
186
  }).alias({
185
187
  v: "version",
186
188
  h: "help"
187
189
  });
188
- const previewOptions = (yargs)=>yargs.positional("dir", {
189
- type: "string",
190
- describe: "directory want to preview"
191
- }).options({
192
- publicPath: {
193
- type: "string",
194
- describe: "static resource server path"
195
- },
196
- config: {
197
- g: true,
198
- type: "string",
199
- describe: "config file",
200
- alias: "c"
201
- },
202
- port: {
203
- type: "number",
204
- describe: "preview server port"
205
- },
206
- host: {
207
- type: "string",
208
- describe: "preview server host"
209
- },
210
- open: {
211
- type: "boolean",
212
- describe: "open browser"
213
- },
214
- server: {
215
- type: "string",
216
- describe: "Configuration items for the server."
217
- },
218
- configName: {
219
- type: "array",
220
- string: true,
221
- describe: "Name of the configuration to use."
222
- }
223
- });
224
190
  function normalizeEnv(argv) {
225
191
  function parseValue(previous, value) {
226
192
  const [allKeys, val] = value.split(/=(.+)/, 2);
@@ -263,7 +229,8 @@ var __webpack_exports__ = {};
263
229
  "$0",
264
230
  "bundle",
265
231
  "b"
266
- ], "run the rspack build", (yargs)=>commonOptions(yargs).options({
232
+ ], "run the rspack build", (yargs)=>{
233
+ commonOptionsForBuildAndServe(commonOptions(yargs)).options({
267
234
  analyze: {
268
235
  type: "boolean",
269
236
  default: false,
@@ -277,7 +244,8 @@ var __webpack_exports__ = {};
277
244
  default: false,
278
245
  describe: "capture timing information for each module"
279
246
  }
280
- }), async (options)=>{
247
+ });
248
+ }, async (options)=>{
281
249
  const env = ensureEnvObject(options);
282
250
  if (options.watch) setBuiltinEnvArg(env, "WATCH", true);
283
251
  else {
@@ -332,6 +300,34 @@ var __webpack_exports__ = {};
332
300
  });
333
301
  }
334
302
  }
303
+ const previewOptions = (yargs)=>{
304
+ yargs.positional("dir", {
305
+ type: "string",
306
+ describe: "directory want to preview"
307
+ });
308
+ return commonOptions(yargs).options({
309
+ publicPath: {
310
+ type: "string",
311
+ describe: "static resource server path"
312
+ },
313
+ port: {
314
+ type: "number",
315
+ describe: "preview server port"
316
+ },
317
+ host: {
318
+ type: "string",
319
+ describe: "preview server host"
320
+ },
321
+ open: {
322
+ type: "boolean",
323
+ describe: "open browser"
324
+ },
325
+ server: {
326
+ type: "string",
327
+ describe: "Configuration items for the server."
328
+ }
329
+ });
330
+ };
335
331
  const defaultRoot = "dist";
336
332
  class PreviewCommand {
337
333
  async apply(cli) {
@@ -341,8 +337,7 @@ var __webpack_exports__ = {};
341
337
  "p"
342
338
  ], "run the rspack server for build output", previewOptions, async (options)=>{
343
339
  const rspackOptions = {
344
- config: options.config,
345
- configName: options.configName,
340
+ ...options,
346
341
  argv: {
347
342
  ...options
348
343
  }
@@ -397,7 +392,7 @@ var __webpack_exports__ = {};
397
392
  "server",
398
393
  "s",
399
394
  "dev"
400
- ], "run the rspack dev server.", (yargs)=>commonOptions(yargs).options({
395
+ ], "run the rspack dev server.", (yargs)=>commonOptionsForBuildAndServe(commonOptions(yargs)).options({
401
396
  hot: {
402
397
  coerce: (arg)=>{
403
398
  if ("boolean" == typeof arg || "only" === arg) return arg;
@@ -554,12 +549,12 @@ var __webpack_exports__ = {};
554
549
  if (options.config) {
555
550
  const configPath = external_node_path_default().resolve(cwd, options.config);
556
551
  if (!external_node_fs_default().existsSync(configPath)) throw new Error(`config file "${configPath}" not found.`);
557
- if (isTsFile(configPath) && "register" === options["config-loader"]) await registerLoader(configPath);
552
+ if (isTsFile(configPath) && "register" === options.configLoader) await registerLoader(configPath);
558
553
  return crossImport(configPath, cwd);
559
554
  }
560
555
  const defaultConfig = utils_findConfig(external_node_path_default().resolve(cwd, loadConfig_DEFAULT_CONFIG_NAME));
561
556
  if (defaultConfig) {
562
- if (isTsFile(defaultConfig) && "register" === options["config-loader"]) await registerLoader(defaultConfig);
557
+ if (isTsFile(defaultConfig) && "register" === options.configLoader) await registerLoader(defaultConfig);
563
558
  return crossImport(defaultConfig, cwd);
564
559
  }
565
560
  return {};
@@ -647,7 +642,7 @@ var __webpack_exports__ = {};
647
642
  main: options.entry.map((x)=>external_node_path_default().resolve(process.cwd(), x))[0]
648
643
  };
649
644
  item.output = item.output || {};
650
- if (options["output-path"]) item.output.path = external_node_path_default().resolve(process.cwd(), options["output-path"]);
645
+ if (options.outputPath) item.output.path = external_node_path_default().resolve(process.cwd(), options.outputPath);
651
646
  if (options.analyze) {
652
647
  const { BundleAnalyzerPlugin } = await Promise.resolve().then(__webpack_require__.bind(__webpack_require__, "webpack-bundle-analyzer"));
653
648
  (item.plugins ??= []).push({
@@ -661,7 +656,7 @@ var __webpack_exports__ = {};
661
656
  }
662
657
  if (options.profile) item.profile = true;
663
658
  if (process.env.RSPACK_PROFILE) {
664
- const { applyProfile } = await __webpack_require__.e("737").then(__webpack_require__.bind(__webpack_require__, "./src/utils/profile.ts"));
659
+ const { applyProfile } = await __webpack_require__.e("197").then(__webpack_require__.bind(__webpack_require__, "./src/utils/profile.ts"));
665
660
  await applyProfile(process.env.RSPACK_PROFILE, item);
666
661
  }
667
662
  if (options.watch) item.watch = options.watch;
package/dist/index.mjs CHANGED
@@ -111,12 +111,24 @@ const commonOptions = (yargs)=>yargs.options({
111
111
  describe: "config file",
112
112
  alias: "c"
113
113
  },
114
+ configName: {
115
+ type: "array",
116
+ string: true,
117
+ describe: "Name of the configuration to use."
118
+ },
119
+ configLoader: {
120
+ type: "string",
121
+ default: "register",
122
+ describe: "Specify the loader to load the config file, can be `native` or `register`."
123
+ }
124
+ });
125
+ const commonOptionsForBuildAndServe = (yargs)=>yargs.options({
114
126
  entry: {
115
127
  type: "array",
116
128
  string: true,
117
129
  describe: "entry file"
118
130
  },
119
- "output-path": {
131
+ outputPath: {
120
132
  type: "string",
121
133
  describe: "output path dir",
122
134
  alias: "o"
@@ -137,7 +149,7 @@ const commonOptions = (yargs)=>yargs.options({
137
149
  string: true,
138
150
  describe: "env passed to config function"
139
151
  },
140
- "node-env": {
152
+ nodeEnv: {
141
153
  string: true,
142
154
  describe: "sets process.env.NODE_ENV to be specified value"
143
155
  },
@@ -146,57 +158,11 @@ const commonOptions = (yargs)=>yargs.options({
146
158
  default: false,
147
159
  describe: "devtool",
148
160
  alias: "d"
149
- },
150
- configName: {
151
- type: "array",
152
- string: true,
153
- describe: "Name of the configuration to use."
154
- },
155
- "config-loader": {
156
- type: "string",
157
- default: "register",
158
- describe: "Specify the loader to load the config file, can be `native` or `register`."
159
161
  }
160
162
  }).alias({
161
163
  v: "version",
162
164
  h: "help"
163
165
  });
164
- const previewOptions = (yargs)=>yargs.positional("dir", {
165
- type: "string",
166
- describe: "directory want to preview"
167
- }).options({
168
- publicPath: {
169
- type: "string",
170
- describe: "static resource server path"
171
- },
172
- config: {
173
- g: true,
174
- type: "string",
175
- describe: "config file",
176
- alias: "c"
177
- },
178
- port: {
179
- type: "number",
180
- describe: "preview server port"
181
- },
182
- host: {
183
- type: "string",
184
- describe: "preview server host"
185
- },
186
- open: {
187
- type: "boolean",
188
- describe: "open browser"
189
- },
190
- server: {
191
- type: "string",
192
- describe: "Configuration items for the server."
193
- },
194
- configName: {
195
- type: "array",
196
- string: true,
197
- describe: "Name of the configuration to use."
198
- }
199
- });
200
166
  function normalizeEnv(argv) {
201
167
  function parseValue(previous, value) {
202
168
  const [allKeys, val] = value.split(/=(.+)/, 2);
@@ -239,7 +205,8 @@ class BuildCommand {
239
205
  "$0",
240
206
  "bundle",
241
207
  "b"
242
- ], "run the rspack build", (yargs)=>commonOptions(yargs).options({
208
+ ], "run the rspack build", (yargs)=>{
209
+ commonOptionsForBuildAndServe(commonOptions(yargs)).options({
243
210
  analyze: {
244
211
  type: "boolean",
245
212
  default: false,
@@ -253,7 +220,8 @@ class BuildCommand {
253
220
  default: false,
254
221
  describe: "capture timing information for each module"
255
222
  }
256
- }), async (options)=>{
223
+ });
224
+ }, async (options)=>{
257
225
  const env = ensureEnvObject(options);
258
226
  if (options.watch) setBuiltinEnvArg(env, "WATCH", true);
259
227
  else {
@@ -308,6 +276,34 @@ class BuildCommand {
308
276
  });
309
277
  }
310
278
  }
279
+ const previewOptions = (yargs)=>{
280
+ yargs.positional("dir", {
281
+ type: "string",
282
+ describe: "directory want to preview"
283
+ });
284
+ return commonOptions(yargs).options({
285
+ publicPath: {
286
+ type: "string",
287
+ describe: "static resource server path"
288
+ },
289
+ port: {
290
+ type: "number",
291
+ describe: "preview server port"
292
+ },
293
+ host: {
294
+ type: "string",
295
+ describe: "preview server host"
296
+ },
297
+ open: {
298
+ type: "boolean",
299
+ describe: "open browser"
300
+ },
301
+ server: {
302
+ type: "string",
303
+ describe: "Configuration items for the server."
304
+ }
305
+ });
306
+ };
311
307
  const defaultRoot = "dist";
312
308
  class PreviewCommand {
313
309
  async apply(cli) {
@@ -317,8 +313,7 @@ class PreviewCommand {
317
313
  "p"
318
314
  ], "run the rspack server for build output", previewOptions, async (options)=>{
319
315
  const rspackOptions = {
320
- config: options.config,
321
- configName: options.configName,
316
+ ...options,
322
317
  argv: {
323
318
  ...options
324
319
  }
@@ -373,7 +368,7 @@ class ServeCommand {
373
368
  "server",
374
369
  "s",
375
370
  "dev"
376
- ], "run the rspack dev server.", (yargs)=>commonOptions(yargs).options({
371
+ ], "run the rspack dev server.", (yargs)=>commonOptionsForBuildAndServe(commonOptions(yargs)).options({
377
372
  hot: {
378
373
  coerce: (arg)=>{
379
374
  if ("boolean" == typeof arg || "only" === arg) return arg;
@@ -530,12 +525,12 @@ async function loadRspackConfig(options, cwd = process.cwd()) {
530
525
  if (options.config) {
531
526
  const configPath = external_node_path_["default"].resolve(cwd, options.config);
532
527
  if (!external_node_fs_["default"].existsSync(configPath)) throw new Error(`config file "${configPath}" not found.`);
533
- if (isTsFile(configPath) && "register" === options["config-loader"]) await registerLoader(configPath);
528
+ if (isTsFile(configPath) && "register" === options.configLoader) await registerLoader(configPath);
534
529
  return crossImport(configPath, cwd);
535
530
  }
536
531
  const defaultConfig = utils_findConfig(external_node_path_["default"].resolve(cwd, loadConfig_DEFAULT_CONFIG_NAME));
537
532
  if (defaultConfig) {
538
- if (isTsFile(defaultConfig) && "register" === options["config-loader"]) await registerLoader(defaultConfig);
533
+ if (isTsFile(defaultConfig) && "register" === options.configLoader) await registerLoader(defaultConfig);
539
534
  return crossImport(defaultConfig, cwd);
540
535
  }
541
536
  return {};
@@ -623,7 +618,7 @@ class RspackCLI {
623
618
  main: options.entry.map((x)=>external_node_path_["default"].resolve(process.cwd(), x))[0]
624
619
  };
625
620
  item.output = item.output || {};
626
- if (options["output-path"]) item.output.path = external_node_path_["default"].resolve(process.cwd(), options["output-path"]);
621
+ if (options.outputPath) item.output.path = external_node_path_["default"].resolve(process.cwd(), options.outputPath);
627
622
  if (options.analyze) {
628
623
  const { BundleAnalyzerPlugin } = await import("webpack-bundle-analyzer");
629
624
  (item.plugins ??= []).push({
@@ -637,7 +632,7 @@ class RspackCLI {
637
632
  }
638
633
  if (options.profile) item.profile = true;
639
634
  if (process.env.RSPACK_PROFILE) {
640
- const { applyProfile } = await __webpack_require__.e("737").then(__webpack_require__.bind(__webpack_require__, "./src/utils/profile.ts"));
635
+ const { applyProfile } = await __webpack_require__.e("197").then(__webpack_require__.bind(__webpack_require__, "./src/utils/profile.ts"));
641
636
  await applyProfile(process.env.RSPACK_PROFILE, item);
642
637
  }
643
638
  if (options.watch) item.watch = options.watch;
package/dist/types.d.ts CHANGED
@@ -21,7 +21,7 @@ export interface RspackCLIOptions {
21
21
  config?: string;
22
22
  argv?: Record<string, any>;
23
23
  configName?: string[];
24
- "config-loader"?: string;
24
+ configLoader?: string;
25
25
  }
26
26
  export interface RspackBuildCLIOptions extends RspackCLIOptions {
27
27
  entry?: string[];
@@ -32,7 +32,7 @@ export interface RspackBuildCLIOptions extends RspackCLIOptions {
32
32
  profile?: boolean;
33
33
  env?: Record<string, any>;
34
34
  nodeEnv?: string;
35
- "output-path"?: string;
35
+ outputPath?: string;
36
36
  }
37
37
  export interface RspackPreviewCLIOptions extends RspackCLIOptions {
38
38
  dir?: string;
@@ -1,17 +1,35 @@
1
1
  import type yargs from "yargs";
2
- export declare const commonOptions: (yargs: yargs.Argv) => yargs.Argv<yargs.Omit<{}, "entry" | "devtool" | "mode" | "watch" | "env" | "output-path" | "config" | "node-env" | "configName" | "config-loader"> & yargs.InferredOptionTypes<{
2
+ /**
3
+ * Apply common options for all commands
4
+ */
5
+ export declare const commonOptions: (yargs: yargs.Argv) => yargs.Argv<yargs.Omit<{}, "config" | "configName" | "configLoader"> & yargs.InferredOptionTypes<{
3
6
  config: {
4
7
  g: boolean;
5
8
  type: "string";
6
9
  describe: string;
7
10
  alias: string;
8
11
  };
12
+ configName: {
13
+ type: "array";
14
+ string: true;
15
+ describe: string;
16
+ };
17
+ configLoader: {
18
+ type: "string";
19
+ default: string;
20
+ describe: string;
21
+ };
22
+ }>>;
23
+ /**
24
+ * Apply common options for `build` and `serve` commands
25
+ */
26
+ export declare const commonOptionsForBuildAndServe: (yargs: yargs.Argv) => yargs.Argv<yargs.Omit<{}, "entry" | "devtool" | "mode" | "watch" | "env" | "nodeEnv" | "outputPath"> & yargs.InferredOptionTypes<{
9
27
  entry: {
10
28
  type: "array";
11
29
  string: true;
12
30
  describe: string;
13
31
  };
14
- "output-path": {
32
+ outputPath: {
15
33
  type: "string";
16
34
  describe: string;
17
35
  alias: string;
@@ -32,7 +50,7 @@ export declare const commonOptions: (yargs: yargs.Argv) => yargs.Argv<yargs.Omit
32
50
  string: true;
33
51
  describe: string;
34
52
  };
35
- "node-env": {
53
+ nodeEnv: {
36
54
  string: true;
37
55
  describe: string;
38
56
  };
@@ -42,51 +60,6 @@ export declare const commonOptions: (yargs: yargs.Argv) => yargs.Argv<yargs.Omit
42
60
  describe: string;
43
61
  alias: string;
44
62
  };
45
- configName: {
46
- type: "array";
47
- string: true;
48
- describe: string;
49
- };
50
- "config-loader": {
51
- type: "string";
52
- default: string;
53
- describe: string;
54
- };
55
- }>>;
56
- export declare const previewOptions: (yargs: yargs.Argv) => yargs.Argv<yargs.Omit<{
57
- dir: string | undefined;
58
- }, "port" | "host" | "open" | "server" | "publicPath" | "config" | "configName"> & yargs.InferredOptionTypes<{
59
- publicPath: {
60
- type: "string";
61
- describe: string;
62
- };
63
- config: {
64
- g: boolean;
65
- type: "string";
66
- describe: string;
67
- alias: string;
68
- };
69
- port: {
70
- type: "number";
71
- describe: string;
72
- };
73
- host: {
74
- type: "string";
75
- describe: string;
76
- };
77
- open: {
78
- type: "boolean";
79
- describe: string;
80
- };
81
- server: {
82
- type: "string";
83
- describe: string;
84
- };
85
- configName: {
86
- type: "array";
87
- string: true;
88
- describe: string;
89
- };
90
63
  }>>;
91
64
  export declare function normalizeEnv(argv: yargs.Arguments): void;
92
65
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rspack/cli",
3
- "version": "1.2.5",
3
+ "version": "1.2.7-alpha.0",
4
4
  "description": "CLI for rspack",
5
5
  "homepage": "https://rspack.dev",
6
6
  "bugs": "https://github.com/web-infra-dev/rspack/issues",
@@ -30,7 +30,7 @@
30
30
  "dependencies": {
31
31
  "@discoveryjs/json-ext": "^0.5.7",
32
32
  "@rspack/dev-server": "1.0.10",
33
- "colorette": "2.0.19",
33
+ "colorette": "2.0.20",
34
34
  "exit-hook": "^4.0.0",
35
35
  "interpret": "^3.1.1",
36
36
  "rechoir": "^0.8.0",
@@ -38,18 +38,18 @@
38
38
  "yargs": "17.7.2"
39
39
  },
40
40
  "devDependencies": {
41
- "@rslib/core": "0.4.0",
41
+ "@rslib/core": "0.5.2",
42
42
  "@types/interpret": "^1.1.3",
43
- "@types/rechoir": "^0.6.1",
44
- "@types/webpack-bundle-analyzer": "^4.6.0",
43
+ "@types/rechoir": "^0.6.4",
44
+ "@types/webpack-bundle-analyzer": "^4.7.0",
45
45
  "@types/yargs": "17.0.33",
46
46
  "concat-stream": "^2.0.0",
47
47
  "cross-env": "^7.0.3",
48
- "execa": "^5.0.0",
48
+ "execa": "^5.1.1",
49
49
  "ts-node": "^10.9.2",
50
50
  "typescript": "^5.7.3",
51
- "@rspack/core": "1.2.5",
52
- "@rspack/tracing": "1.2.5"
51
+ "@rspack/core": "1.2.7-alpha.0",
52
+ "@rspack/tracing": "1.2.7-alpha.0"
53
53
  },
54
54
  "peerDependencies": {
55
55
  "@rspack/core": "^1.0.0-alpha || ^1.x",