@rspack/cli 1.2.7 → 1.2.8

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
- '197'
3
+ '390'
4
4
  ];
5
5
  exports.modules = {
6
6
  "./src/utils/profile.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
@@ -1,7 +1,7 @@
1
- export const ids = [
2
- '197'
1
+ export const __webpack_ids__ = [
2
+ '390'
3
3
  ];
4
- export const modules = {
4
+ export const __webpack_modules__ = {
5
5
  "./src/utils/profile.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
6
6
  __webpack_require__.d(__webpack_exports__, {
7
7
  applyProfile: ()=>applyProfile
package/dist/index.js CHANGED
@@ -46,12 +46,8 @@ function __webpack_require__(moduleId) {
46
46
  }
47
47
  __webpack_require__.m = __webpack_modules__;
48
48
  (()=>{
49
- __webpack_require__.n = function(module) {
50
- var getter = module && module.__esModule ? function() {
51
- return module['default'];
52
- } : function() {
53
- return module;
54
- };
49
+ __webpack_require__.n = (module)=>{
50
+ var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
55
51
  __webpack_require__.d(getter, {
56
52
  a: getter
57
53
  });
@@ -59,7 +55,7 @@ __webpack_require__.m = __webpack_modules__;
59
55
  };
60
56
  })();
61
57
  (()=>{
62
- __webpack_require__.d = function(exports1, definition) {
58
+ __webpack_require__.d = (exports1, definition)=>{
63
59
  for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
64
60
  enumerable: true,
65
61
  get: definition[key]
@@ -68,22 +64,16 @@ __webpack_require__.m = __webpack_modules__;
68
64
  })();
69
65
  (()=>{
70
66
  __webpack_require__.f = {};
71
- __webpack_require__.e = function(chunkId) {
72
- return Promise.all(Object.keys(__webpack_require__.f).reduce(function(promises, key) {
67
+ __webpack_require__.e = (chunkId)=>Promise.all(Object.keys(__webpack_require__.f).reduce((promises, key)=>{
73
68
  __webpack_require__.f[key](chunkId, promises);
74
69
  return promises;
75
70
  }, []));
76
- };
77
71
  })();
78
72
  (()=>{
79
- __webpack_require__.u = function(chunkId) {
80
- return "" + chunkId + ".js";
81
- };
73
+ __webpack_require__.u = (chunkId)=>"" + chunkId + ".js";
82
74
  })();
83
75
  (()=>{
84
- __webpack_require__.o = function(obj, prop) {
85
- return Object.prototype.hasOwnProperty.call(obj, prop);
86
- };
76
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
87
77
  })();
88
78
  (()=>{
89
79
  __webpack_require__.r = function(exports1) {
@@ -99,13 +89,13 @@ __webpack_require__.m = __webpack_modules__;
99
89
  var installedChunks = {
100
90
  980: 1
101
91
  };
102
- var installChunk = function(chunk) {
92
+ var installChunk = (chunk)=>{
103
93
  var moreModules = chunk.modules, chunkIds = chunk.ids, runtime = chunk.runtime;
104
94
  for(var moduleId in moreModules)if (__webpack_require__.o(moreModules, moduleId)) __webpack_require__.m[moduleId] = moreModules[moduleId];
105
95
  if (runtime) runtime(__webpack_require__);
106
96
  for(var i = 0; i < chunkIds.length; i++)installedChunks[chunkIds[i]] = 1;
107
97
  };
108
- __webpack_require__.f.require = function(chunkId, promises) {
98
+ __webpack_require__.f.require = (chunkId, promises)=>{
109
99
  if (!installedChunks[chunkId]) installChunk(require("./" + __webpack_require__.u(chunkId)));
110
100
  };
111
101
  })();
@@ -113,9 +103,9 @@ var __webpack_exports__ = {};
113
103
  (()=>{
114
104
  __webpack_require__.r(__webpack_exports__);
115
105
  __webpack_require__.d(__webpack_exports__, {
106
+ definePlugin: ()=>definePlugin,
116
107
  RspackCLI: ()=>RspackCLI,
117
- defineConfig: ()=>defineConfig,
118
- definePlugin: ()=>definePlugin
108
+ defineConfig: ()=>defineConfig
119
109
  });
120
110
  var external_node_path_ = __webpack_require__("node:path");
121
111
  var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_);
@@ -144,6 +134,10 @@ var __webpack_exports__ = {};
144
134
  type: "string",
145
135
  default: "register",
146
136
  describe: "Specify the loader to load the config file, can be `native` or `register`."
137
+ },
138
+ nodeEnv: {
139
+ string: true,
140
+ describe: "sets `process.env.NODE_ENV` to be specified value"
147
141
  }
148
142
  });
149
143
  const commonOptionsForBuildAndServe = (yargs)=>yargs.options({
@@ -173,10 +167,6 @@ var __webpack_exports__ = {};
173
167
  string: true,
174
168
  describe: "env passed to config function"
175
169
  },
176
- nodeEnv: {
177
- string: true,
178
- describe: "sets process.env.NODE_ENV to be specified value"
179
- },
180
170
  devtool: {
181
171
  type: "boolean",
182
172
  default: false,
@@ -222,6 +212,10 @@ var __webpack_exports__ = {};
222
212
  options.env = options.env || {};
223
213
  return options.env;
224
214
  }
215
+ function setDefaultNodeEnv(options, defaultEnv) {
216
+ if (void 0 !== process.env.NODE_ENV) return;
217
+ process.env.NODE_ENV = "string" == typeof options.nodeEnv ? options.nodeEnv : defaultEnv;
218
+ }
225
219
  class BuildCommand {
226
220
  async apply(cli) {
227
221
  cli.program.command([
@@ -246,6 +240,7 @@ var __webpack_exports__ = {};
246
240
  }
247
241
  });
248
242
  }, async (options)=>{
243
+ setDefaultNodeEnv(options, "production");
249
244
  const env = ensureEnvObject(options);
250
245
  if (options.watch) setBuiltinEnvArg(env, "WATCH", true);
251
246
  else {
@@ -336,6 +331,7 @@ var __webpack_exports__ = {};
336
331
  "preview",
337
332
  "p"
338
333
  ], "run the rspack server for build output", previewOptions, async (options)=>{
334
+ setDefaultNodeEnv(options, "production");
339
335
  const rspackOptions = {
340
336
  ...options,
341
337
  argv: {
@@ -411,6 +407,7 @@ var __webpack_exports__ = {};
411
407
  describe: "allows to specify a hostname to use"
412
408
  }
413
409
  }), async (options)=>{
410
+ setDefaultNodeEnv(options, "development");
414
411
  setBuiltinEnvArg(ensureEnvObject(options), "SERVE", true);
415
412
  const rspackOptions = {
416
413
  ...options,
@@ -477,7 +474,7 @@ var __webpack_exports__ = {};
477
474
  }
478
475
  }
479
476
  var external_node_url_ = __webpack_require__("node:url");
480
- const readPackageUp = (cwd = process.cwd())=>{
477
+ const readPackageUp_readPackageUp = (cwd = process.cwd())=>{
481
478
  let currentDir = external_node_path_default().resolve(cwd);
482
479
  let packageJsonPath = external_node_path_default().join(currentDir, "package.json");
483
480
  while(!external_node_fs_default().existsSync(packageJsonPath)){
@@ -492,12 +489,12 @@ var __webpack_exports__ = {};
492
489
  return null;
493
490
  }
494
491
  };
495
- const utils_readPackageUp = readPackageUp;
492
+ const readPackageUp = readPackageUp_readPackageUp;
496
493
  const isEsmFile = (filePath, cwd = process.cwd())=>{
497
494
  const ext = external_node_path_default().extname(filePath);
498
495
  if (/\.(mjs|mts)$/.test(ext)) return true;
499
496
  if (/\.(cjs|cts)/.test(ext)) return false;
500
- const packageJson = utils_readPackageUp(external_node_path_default().dirname(filePath));
497
+ const packageJson = readPackageUp(external_node_path_default().dirname(filePath));
501
498
  return (null == packageJson ? void 0 : packageJson.type) === "module";
502
499
  };
503
500
  const utils_isEsmFile = isEsmFile;
@@ -521,15 +518,15 @@ var __webpack_exports__ = {};
521
518
  ];
522
519
  const findConfig = (basePath)=>DEFAULT_EXTENSIONS.map((ext)=>basePath + ext).find(external_node_fs_default().existsSync);
523
520
  const utils_findConfig = findConfig;
524
- const isTsFile_isTsFile = (configPath)=>{
521
+ const isTsFile = (configPath)=>{
525
522
  const ext = external_node_path_default().extname(configPath);
526
523
  return /\.(c|m)?ts$/.test(ext);
527
524
  };
528
- const isTsFile = isTsFile_isTsFile;
525
+ const utils_isTsFile = isTsFile;
529
526
  const loadConfig_DEFAULT_CONFIG_NAME = "rspack.config";
530
527
  const registerLoader = async (configPath)=>{
531
528
  const ext = external_node_path_default().extname(configPath);
532
- if (utils_isEsmFile(configPath) && isTsFile(configPath)) return;
529
+ if (utils_isEsmFile(configPath) && utils_isTsFile(configPath)) return;
533
530
  const { default: interpret } = await Promise.resolve().then(__webpack_require__.bind(__webpack_require__, "interpret"));
534
531
  const extensions = Object.fromEntries(Object.entries(interpret.extensions).filter(([key])=>key === ext));
535
532
  if (0 === Object.keys(extensions).length) throw new Error(`config file "${configPath}" is not supported.`);
@@ -549,12 +546,12 @@ var __webpack_exports__ = {};
549
546
  if (options.config) {
550
547
  const configPath = external_node_path_default().resolve(cwd, options.config);
551
548
  if (!external_node_fs_default().existsSync(configPath)) throw new Error(`config file "${configPath}" not found.`);
552
- if (isTsFile(configPath) && "register" === options.configLoader) await registerLoader(configPath);
549
+ if (utils_isTsFile(configPath) && "register" === options.configLoader) await registerLoader(configPath);
553
550
  return crossImport(configPath, cwd);
554
551
  }
555
552
  const defaultConfig = utils_findConfig(external_node_path_default().resolve(cwd, loadConfig_DEFAULT_CONFIG_NAME));
556
553
  if (defaultConfig) {
557
- if (isTsFile(defaultConfig) && "register" === options.configLoader) await registerLoader(defaultConfig);
554
+ if (utils_isTsFile(defaultConfig) && "register" === options.configLoader) await registerLoader(defaultConfig);
558
555
  return crossImport(defaultConfig, cwd);
559
556
  }
560
557
  return {};
@@ -571,13 +568,8 @@ var __webpack_exports__ = {};
571
568
  }
572
569
  class RspackCLI {
573
570
  async createCompiler(options, rspackCommand, callback) {
574
- var _process_env, _process;
575
571
  process.env.RSPACK_CONFIG_VALIDATE ??= "loose";
576
572
  process.env.WATCHPACK_WATCHER_LIMIT = process.env.WATCHPACK_WATCHER_LIMIT || "20";
577
- const nodeEnv = null === (_process = process) || void 0 === _process ? void 0 : null === (_process_env = _process.env) || void 0 === _process_env ? void 0 : _process_env.NODE_ENV;
578
- const rspackCommandDefaultEnv = "build" === rspackCommand ? "production" : "development";
579
- if ("string" == typeof options.nodeEnv) process.env.NODE_ENV = nodeEnv || options.nodeEnv;
580
- else process.env.NODE_ENV = nodeEnv || rspackCommandDefaultEnv;
581
573
  let config = await this.loadConfig(options);
582
574
  config = await this.buildConfig(config, options, rspackCommand);
583
575
  const isWatch = Array.isArray(config) ? config.some((i)=>i.watch) : config.watch;
@@ -636,7 +628,6 @@ var __webpack_exports__ = {};
636
628
  async buildConfig(item, options, command) {
637
629
  const isBuild = "build" === command;
638
630
  const isServe = "serve" === command;
639
- const commandDefaultEnv = isBuild ? "production" : "development";
640
631
  const internalBuildConfig = async (item)=>{
641
632
  if (options.entry) item.entry = {
642
633
  main: options.entry.map((x)=>external_node_path_default().resolve(process.cwd(), x))[0]
@@ -656,11 +647,11 @@ var __webpack_exports__ = {};
656
647
  }
657
648
  if (options.profile) item.profile = true;
658
649
  if (process.env.RSPACK_PROFILE) {
659
- const { applyProfile } = await __webpack_require__.e("197").then(__webpack_require__.bind(__webpack_require__, "./src/utils/profile.ts"));
650
+ const { applyProfile } = await __webpack_require__.e("390").then(__webpack_require__.bind(__webpack_require__, "./src/utils/profile.ts"));
660
651
  await applyProfile(process.env.RSPACK_PROFILE, item);
661
652
  }
662
653
  if (options.watch) item.watch = options.watch;
663
- if (!item.mode) item.mode = commandDefaultEnv ?? "none";
654
+ if (!item.mode) item.mode = isBuild ? "production" : "development";
664
655
  if (options.mode) item.mode = options.mode;
665
656
  if (void 0 === item.devtool) item.devtool = isBuild ? "source-map" : "cheap-module-source-map";
666
657
  if (isServe) {
package/dist/index.mjs CHANGED
@@ -36,7 +36,7 @@ function __webpack_require__(moduleId) {
36
36
  }
37
37
  __webpack_require__.m = __webpack_modules__;
38
38
  (()=>{
39
- __webpack_require__.d = function(exports, definition) {
39
+ __webpack_require__.d = (exports, definition)=>{
40
40
  for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) Object.defineProperty(exports, key, {
41
41
  enumerable: true,
42
42
  get: definition[key]
@@ -45,38 +45,32 @@ __webpack_require__.m = __webpack_modules__;
45
45
  })();
46
46
  (()=>{
47
47
  __webpack_require__.f = {};
48
- __webpack_require__.e = function(chunkId) {
49
- return Promise.all(Object.keys(__webpack_require__.f).reduce(function(promises, key) {
48
+ __webpack_require__.e = (chunkId)=>Promise.all(Object.keys(__webpack_require__.f).reduce((promises, key)=>{
50
49
  __webpack_require__.f[key](chunkId, promises);
51
50
  return promises;
52
51
  }, []));
53
- };
54
52
  })();
55
53
  (()=>{
56
- __webpack_require__.u = function(chunkId) {
57
- return "" + chunkId + ".mjs";
58
- };
54
+ __webpack_require__.u = (chunkId)=>"" + chunkId + ".mjs";
59
55
  })();
60
56
  (()=>{
61
- __webpack_require__.o = function(obj, prop) {
62
- return Object.prototype.hasOwnProperty.call(obj, prop);
63
- };
57
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
64
58
  })();
65
59
  (()=>{
66
60
  var installedChunks = {
67
61
  980: 0
68
62
  };
69
- var installChunk = function(data) {
70
- var ids = data.ids;
71
- var modules = data.modules;
72
- var runtime = data.runtime;
63
+ var installChunk = (data)=>{
64
+ var __webpack_ids__ = data.__webpack_ids__;
65
+ var __webpack_modules__ = data.__webpack_modules__;
66
+ var __webpack_runtime__ = data.__webpack_runtime__;
73
67
  var moduleId, chunkId, i = 0;
74
- for(moduleId in modules)if (__webpack_require__.o(modules, moduleId)) __webpack_require__.m[moduleId] = modules[moduleId];
75
- if (runtime) runtime(__webpack_require__);
76
- for(; i < ids.length; i++){
77
- chunkId = ids[i];
68
+ for(moduleId in __webpack_modules__)if (__webpack_require__.o(__webpack_modules__, moduleId)) __webpack_require__.m[moduleId] = __webpack_modules__[moduleId];
69
+ if (__webpack_runtime__) __webpack_runtime__(__webpack_require__);
70
+ for(; i < __webpack_ids__.length; i++){
71
+ chunkId = __webpack_ids__[i];
78
72
  if (__webpack_require__.o(installedChunks, chunkId) && installedChunks[chunkId]) installedChunks[chunkId][0]();
79
- installedChunks[ids[i]] = 0;
73
+ installedChunks[__webpack_ids__[i]] = 0;
80
74
  }
81
75
  };
82
76
  __webpack_require__.f.j = function(chunkId, promises) {
@@ -84,13 +78,13 @@ __webpack_require__.m = __webpack_modules__;
84
78
  if (0 !== installedChunkData) {
85
79
  if (installedChunkData) promises.push(installedChunkData[1]);
86
80
  else {
87
- var promise = import("./" + __webpack_require__.u(chunkId)).then(installChunk, function(e) {
81
+ var promise = import("./" + __webpack_require__.u(chunkId)).then(installChunk, (e)=>{
88
82
  if (0 !== installedChunks[chunkId]) installedChunks[chunkId] = void 0;
89
83
  throw e;
90
84
  });
91
85
  var promise = Promise.race([
92
86
  promise,
93
- new Promise(function(resolve) {
87
+ new Promise((resolve)=>{
94
88
  installedChunkData = installedChunks[chunkId] = [
95
89
  resolve
96
90
  ];
@@ -120,6 +114,10 @@ const commonOptions = (yargs)=>yargs.options({
120
114
  type: "string",
121
115
  default: "register",
122
116
  describe: "Specify the loader to load the config file, can be `native` or `register`."
117
+ },
118
+ nodeEnv: {
119
+ string: true,
120
+ describe: "sets `process.env.NODE_ENV` to be specified value"
123
121
  }
124
122
  });
125
123
  const commonOptionsForBuildAndServe = (yargs)=>yargs.options({
@@ -149,10 +147,6 @@ const commonOptionsForBuildAndServe = (yargs)=>yargs.options({
149
147
  string: true,
150
148
  describe: "env passed to config function"
151
149
  },
152
- nodeEnv: {
153
- string: true,
154
- describe: "sets process.env.NODE_ENV to be specified value"
155
- },
156
150
  devtool: {
157
151
  type: "boolean",
158
152
  default: false,
@@ -198,6 +192,10 @@ function ensureEnvObject(options) {
198
192
  options.env = options.env || {};
199
193
  return options.env;
200
194
  }
195
+ function setDefaultNodeEnv(options, defaultEnv) {
196
+ if (void 0 !== process.env.NODE_ENV) return;
197
+ process.env.NODE_ENV = "string" == typeof options.nodeEnv ? options.nodeEnv : defaultEnv;
198
+ }
201
199
  class BuildCommand {
202
200
  async apply(cli) {
203
201
  cli.program.command([
@@ -222,6 +220,7 @@ class BuildCommand {
222
220
  }
223
221
  });
224
222
  }, async (options)=>{
223
+ setDefaultNodeEnv(options, "production");
225
224
  const env = ensureEnvObject(options);
226
225
  if (options.watch) setBuiltinEnvArg(env, "WATCH", true);
227
226
  else {
@@ -312,6 +311,7 @@ class PreviewCommand {
312
311
  "preview",
313
312
  "p"
314
313
  ], "run the rspack server for build output", previewOptions, async (options)=>{
314
+ setDefaultNodeEnv(options, "production");
315
315
  const rspackOptions = {
316
316
  ...options,
317
317
  argv: {
@@ -387,6 +387,7 @@ class ServeCommand {
387
387
  describe: "allows to specify a hostname to use"
388
388
  }
389
389
  }), async (options)=>{
390
+ setDefaultNodeEnv(options, "development");
390
391
  setBuiltinEnvArg(ensureEnvObject(options), "SERVE", true);
391
392
  const rspackOptions = {
392
393
  ...options,
@@ -453,7 +454,7 @@ class ServeCommand {
453
454
  }
454
455
  }
455
456
  var external_node_url_ = __webpack_require__("node:url");
456
- const readPackageUp = (cwd = process.cwd())=>{
457
+ const readPackageUp_readPackageUp = (cwd = process.cwd())=>{
457
458
  let currentDir = external_node_path_["default"].resolve(cwd);
458
459
  let packageJsonPath = external_node_path_["default"].join(currentDir, "package.json");
459
460
  while(!external_node_fs_["default"].existsSync(packageJsonPath)){
@@ -468,12 +469,12 @@ const readPackageUp = (cwd = process.cwd())=>{
468
469
  return null;
469
470
  }
470
471
  };
471
- const utils_readPackageUp = readPackageUp;
472
+ const readPackageUp = readPackageUp_readPackageUp;
472
473
  const isEsmFile = (filePath, cwd = process.cwd())=>{
473
474
  const ext = external_node_path_["default"].extname(filePath);
474
475
  if (/\.(mjs|mts)$/.test(ext)) return true;
475
476
  if (/\.(cjs|cts)/.test(ext)) return false;
476
- const packageJson = utils_readPackageUp(external_node_path_["default"].dirname(filePath));
477
+ const packageJson = readPackageUp(external_node_path_["default"].dirname(filePath));
477
478
  return (null == packageJson ? void 0 : packageJson.type) === "module";
478
479
  };
479
480
  const utils_isEsmFile = isEsmFile;
@@ -497,15 +498,15 @@ const DEFAULT_EXTENSIONS = [
497
498
  ];
498
499
  const findConfig = (basePath)=>DEFAULT_EXTENSIONS.map((ext)=>basePath + ext).find(external_node_fs_["default"].existsSync);
499
500
  const utils_findConfig = findConfig;
500
- const isTsFile_isTsFile = (configPath)=>{
501
+ const isTsFile = (configPath)=>{
501
502
  const ext = external_node_path_["default"].extname(configPath);
502
503
  return /\.(c|m)?ts$/.test(ext);
503
504
  };
504
- const isTsFile = isTsFile_isTsFile;
505
+ const utils_isTsFile = isTsFile;
505
506
  const loadConfig_DEFAULT_CONFIG_NAME = "rspack.config";
506
507
  const registerLoader = async (configPath)=>{
507
508
  const ext = external_node_path_["default"].extname(configPath);
508
- if (utils_isEsmFile(configPath) && isTsFile(configPath)) return;
509
+ if (utils_isEsmFile(configPath) && utils_isTsFile(configPath)) return;
509
510
  const { default: interpret } = await import("interpret");
510
511
  const extensions = Object.fromEntries(Object.entries(interpret.extensions).filter(([key])=>key === ext));
511
512
  if (0 === Object.keys(extensions).length) throw new Error(`config file "${configPath}" is not supported.`);
@@ -525,12 +526,12 @@ async function loadRspackConfig(options, cwd = process.cwd()) {
525
526
  if (options.config) {
526
527
  const configPath = external_node_path_["default"].resolve(cwd, options.config);
527
528
  if (!external_node_fs_["default"].existsSync(configPath)) throw new Error(`config file "${configPath}" not found.`);
528
- if (isTsFile(configPath) && "register" === options.configLoader) await registerLoader(configPath);
529
+ if (utils_isTsFile(configPath) && "register" === options.configLoader) await registerLoader(configPath);
529
530
  return crossImport(configPath, cwd);
530
531
  }
531
532
  const defaultConfig = utils_findConfig(external_node_path_["default"].resolve(cwd, loadConfig_DEFAULT_CONFIG_NAME));
532
533
  if (defaultConfig) {
533
- if (isTsFile(defaultConfig) && "register" === options.configLoader) await registerLoader(defaultConfig);
534
+ if (utils_isTsFile(defaultConfig) && "register" === options.configLoader) await registerLoader(defaultConfig);
534
535
  return crossImport(defaultConfig, cwd);
535
536
  }
536
537
  return {};
@@ -547,13 +548,8 @@ function _define_property(obj, key, value) {
547
548
  }
548
549
  class RspackCLI {
549
550
  async createCompiler(options, rspackCommand, callback) {
550
- var _process_env, _process;
551
551
  process.env.RSPACK_CONFIG_VALIDATE ??= "loose";
552
552
  process.env.WATCHPACK_WATCHER_LIMIT = process.env.WATCHPACK_WATCHER_LIMIT || "20";
553
- const nodeEnv = null === (_process = process) || void 0 === _process ? void 0 : null === (_process_env = _process.env) || void 0 === _process_env ? void 0 : _process_env.NODE_ENV;
554
- const rspackCommandDefaultEnv = "build" === rspackCommand ? "production" : "development";
555
- if ("string" == typeof options.nodeEnv) process.env.NODE_ENV = nodeEnv || options.nodeEnv;
556
- else process.env.NODE_ENV = nodeEnv || rspackCommandDefaultEnv;
557
553
  let config = await this.loadConfig(options);
558
554
  config = await this.buildConfig(config, options, rspackCommand);
559
555
  const isWatch = Array.isArray(config) ? config.some((i)=>i.watch) : config.watch;
@@ -612,7 +608,6 @@ class RspackCLI {
612
608
  async buildConfig(item, options, command) {
613
609
  const isBuild = "build" === command;
614
610
  const isServe = "serve" === command;
615
- const commandDefaultEnv = isBuild ? "production" : "development";
616
611
  const internalBuildConfig = async (item)=>{
617
612
  if (options.entry) item.entry = {
618
613
  main: options.entry.map((x)=>external_node_path_["default"].resolve(process.cwd(), x))[0]
@@ -632,11 +627,11 @@ class RspackCLI {
632
627
  }
633
628
  if (options.profile) item.profile = true;
634
629
  if (process.env.RSPACK_PROFILE) {
635
- const { applyProfile } = await __webpack_require__.e("197").then(__webpack_require__.bind(__webpack_require__, "./src/utils/profile.ts"));
630
+ const { applyProfile } = await __webpack_require__.e("390").then(__webpack_require__.bind(__webpack_require__, "./src/utils/profile.ts"));
636
631
  await applyProfile(process.env.RSPACK_PROFILE, item);
637
632
  }
638
633
  if (options.watch) item.watch = options.watch;
639
- if (!item.mode) item.mode = commandDefaultEnv ?? "none";
634
+ if (!item.mode) item.mode = isBuild ? "production" : "development";
640
635
  if (options.mode) item.mode = options.mode;
641
636
  if (void 0 === item.devtool) item.devtool = isBuild ? "source-map" : "cheap-module-source-map";
642
637
  if (isServe) {
package/dist/types.d.ts CHANGED
@@ -22,6 +22,7 @@ export interface RspackCLIOptions {
22
22
  argv?: Record<string, any>;
23
23
  configName?: string[];
24
24
  configLoader?: string;
25
+ nodeEnv?: string;
25
26
  }
26
27
  export interface RspackBuildCLIOptions extends RspackCLIOptions {
27
28
  entry?: string[];
@@ -31,7 +32,6 @@ export interface RspackBuildCLIOptions extends RspackCLIOptions {
31
32
  analyze?: boolean;
32
33
  profile?: boolean;
33
34
  env?: Record<string, any>;
34
- nodeEnv?: string;
35
35
  outputPath?: string;
36
36
  }
37
37
  export interface RspackPreviewCLIOptions extends RspackCLIOptions {
@@ -2,7 +2,7 @@ import type yargs from "yargs";
2
2
  /**
3
3
  * Apply common options for all commands
4
4
  */
5
- export declare const commonOptions: (yargs: yargs.Argv) => yargs.Argv<yargs.Omit<{}, "config" | "configName" | "configLoader"> & yargs.InferredOptionTypes<{
5
+ export declare const commonOptions: (yargs: yargs.Argv) => yargs.Argv<yargs.Omit<{}, "nodeEnv" | "config" | "configName" | "configLoader"> & yargs.InferredOptionTypes<{
6
6
  config: {
7
7
  g: boolean;
8
8
  type: "string";
@@ -19,11 +19,15 @@ export declare const commonOptions: (yargs: yargs.Argv) => yargs.Argv<yargs.Omit
19
19
  default: string;
20
20
  describe: string;
21
21
  };
22
+ nodeEnv: {
23
+ string: true;
24
+ describe: string;
25
+ };
22
26
  }>>;
23
27
  /**
24
28
  * Apply common options for `build` and `serve` commands
25
29
  */
26
- export declare const commonOptionsForBuildAndServe: (yargs: yargs.Argv) => yargs.Argv<yargs.Omit<{}, "entry" | "devtool" | "mode" | "watch" | "env" | "nodeEnv" | "outputPath"> & yargs.InferredOptionTypes<{
30
+ export declare const commonOptionsForBuildAndServe: (yargs: yargs.Argv) => yargs.Argv<yargs.Omit<{}, "entry" | "devtool" | "mode" | "watch" | "env" | "outputPath"> & yargs.InferredOptionTypes<{
27
31
  entry: {
28
32
  type: "array";
29
33
  string: true;
@@ -50,10 +54,6 @@ export declare const commonOptionsForBuildAndServe: (yargs: yargs.Argv) => yargs
50
54
  string: true;
51
55
  describe: string;
52
56
  };
53
- nodeEnv: {
54
- string: true;
55
- describe: string;
56
- };
57
57
  devtool: {
58
58
  type: "boolean";
59
59
  default: boolean;
@@ -74,3 +74,4 @@ export declare function setBuiltinEnvArg(env: Record<string, any>, envNameSuffix
74
74
  * @returns the reference of `argv.env` object
75
75
  */
76
76
  export declare function ensureEnvObject<T extends Record<string, unknown>>(options: yargs.Arguments): T;
77
+ export declare function setDefaultNodeEnv(options: yargs.Arguments, defaultEnv: string): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rspack/cli",
3
- "version": "1.2.7",
3
+ "version": "1.2.8",
4
4
  "description": "CLI for rspack",
5
5
  "homepage": "https://rspack.dev",
6
6
  "bugs": "https://github.com/web-infra-dev/rspack/issues",
@@ -38,7 +38,7 @@
38
38
  "yargs": "17.7.2"
39
39
  },
40
40
  "devDependencies": {
41
- "@rslib/core": "0.5.2",
41
+ "@rslib/core": "0.5.3",
42
42
  "@types/interpret": "^1.1.3",
43
43
  "@types/rechoir": "^0.6.4",
44
44
  "@types/webpack-bundle-analyzer": "^4.7.0",
@@ -48,8 +48,8 @@
48
48
  "execa": "^5.1.1",
49
49
  "ts-node": "^10.9.2",
50
50
  "typescript": "^5.7.3",
51
- "@rspack/tracing": "1.2.7",
52
- "@rspack/core": "1.2.7"
51
+ "@rspack/core": "1.2.8",
52
+ "@rspack/tracing": "1.2.8"
53
53
  },
54
54
  "peerDependencies": {
55
55
  "@rspack/core": "^1.0.0-alpha || ^1.x",