@rspack/cli 1.6.0-beta.1 → 1.6.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/index.js CHANGED
@@ -259,9 +259,9 @@ var __webpack_exports__ = {};
259
259
  "use strict";
260
260
  __webpack_require__.r(__webpack_exports__);
261
261
  __webpack_require__.d(__webpack_exports__, {
262
- defineConfig: ()=>defineConfig,
263
262
  definePlugin: ()=>definePlugin,
264
- RspackCLI: ()=>RspackCLI
263
+ RspackCLI: ()=>RspackCLI,
264
+ defineConfig: ()=>defineConfig
265
265
  });
266
266
  var external_node_path_ = __webpack_require__("node:path");
267
267
  var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_);
@@ -847,9 +847,13 @@ ${section.body}` : section.body).join("\n\n"));
847
847
  }
848
848
  if (stats?.hasErrors()) process.exitCode = 1;
849
849
  if (!compiler || !stats) return;
850
- const statsOptions = cli.isMultipleCompiler(compiler) ? {
851
- children: compiler.compilers.map((item)=>item.options ? item.options.stats : void 0)
852
- } : compiler.options?.stats;
850
+ const getStatsOptions = ()=>{
851
+ if (cli.isMultipleCompiler(compiler)) return {
852
+ children: compiler.compilers.map((item)=>item.options ? item.options.stats : void 0)
853
+ };
854
+ return compiler.options?.stats;
855
+ };
856
+ const statsOptions = getStatsOptions();
853
857
  if (options.json && createJsonStringifyStream) {
854
858
  const handleWriteError = (error)=>{
855
859
  logger.error(error);
@@ -1032,16 +1036,14 @@ ${section.body}` : section.body).join("\n\n"));
1032
1036
  }
1033
1037
  };
1034
1038
  const utils_readPackageUp = readPackageUp;
1035
- const isEsmFile = (filePath, cwd = process.cwd())=>{
1036
- const ext = external_node_path_default().extname(filePath);
1037
- if (/\.(mjs|mts)$/.test(ext)) return true;
1038
- if (/\.(cjs|cts)/.test(ext)) return false;
1039
+ const isEsmFile = (filePath)=>{
1040
+ if (/\.(mjs|mts)$/.test(filePath)) return true;
1041
+ if (/\.(cjs|cts)$/.test(filePath)) return false;
1039
1042
  const packageJson = utils_readPackageUp(external_node_path_default().dirname(filePath));
1040
1043
  return packageJson?.type === "module";
1041
1044
  };
1042
- const utils_isEsmFile = isEsmFile;
1043
- const crossImport = async (path, cwd = process.cwd())=>{
1044
- if (utils_isEsmFile(path, cwd)) {
1045
+ const crossImport = async (path)=>{
1046
+ if (isEsmFile(path)) {
1045
1047
  const url = (0, external_node_url_namespaceObject.pathToFileURL)(path).href;
1046
1048
  const { default: config } = await import(url);
1047
1049
  return config;
@@ -1065,11 +1067,11 @@ ${section.body}` : section.body).join("\n\n"));
1065
1067
  ".cts",
1066
1068
  ".mts"
1067
1069
  ];
1068
- const isTsFile_isTsFile = (configPath)=>{
1070
+ const isTsFile = (configPath)=>{
1069
1071
  const ext = external_node_path_default().extname(configPath);
1070
1072
  return TS_EXTENSION.includes(ext);
1071
1073
  };
1072
- const isTsFile = isTsFile_isTsFile;
1074
+ const utils_isTsFile = isTsFile;
1073
1075
  const injectInlineSourceMap = ({ code, map })=>{
1074
1076
  if (map) {
1075
1077
  const base64Map = Buffer.from(map, "utf8").toString("base64");
@@ -1102,8 +1104,8 @@ ${section.body}` : section.body).join("\n\n"));
1102
1104
  }
1103
1105
  const loadConfig_DEFAULT_CONFIG_NAME = "rspack.config";
1104
1106
  const registerLoader = (configPath)=>{
1105
- if (utils_isEsmFile(configPath) && isTsFile(configPath)) return;
1106
- if (!isTsFile(configPath)) throw new Error(`config file "${configPath}" is not supported.`);
1107
+ if (isEsmFile(configPath) && utils_isTsFile(configPath)) return;
1108
+ if (!utils_isTsFile(configPath)) throw new Error(`config file "${configPath}" is not supported.`);
1107
1109
  (0, lib.addHook)((code, filename)=>{
1108
1110
  try {
1109
1111
  return compile(code, filename);
@@ -1166,8 +1168,8 @@ ${section.body}` : section.body).join("\n\n"));
1166
1168
  throw new Error(`Cannot find module '${extendPath}' to extend from.`);
1167
1169
  }
1168
1170
  if (!external_node_fs_default().existsSync(resolvedPath)) throw new Error(`Extended configuration file "${resolvedPath}" not found.`);
1169
- if (isTsFile(resolvedPath) && "register" === options.configLoader) registerLoader(resolvedPath);
1170
- let loadedConfig = await crossImport(resolvedPath, cwd);
1171
+ if (utils_isTsFile(resolvedPath) && "register" === options.configLoader) registerLoader(resolvedPath);
1172
+ let loadedConfig = await crossImport(resolvedPath);
1171
1173
  if ("function" == typeof loadedConfig) {
1172
1174
  loadedConfig = loadedConfig(options.env, options);
1173
1175
  if ("function" == typeof loadedConfig.then) loadedConfig = await loadedConfig;
@@ -1195,8 +1197,8 @@ ${section.body}` : section.body).join("\n\n"));
1195
1197
  if (!defaultConfig) return null;
1196
1198
  configPath = defaultConfig;
1197
1199
  }
1198
- if (isTsFile(configPath) && "register" === options.configLoader) registerLoader(configPath);
1199
- const loadedConfig = await crossImport(configPath, cwd);
1200
+ if (utils_isTsFile(configPath) && "register" === options.configLoader) registerLoader(configPath);
1201
+ const loadedConfig = await crossImport(configPath);
1200
1202
  return {
1201
1203
  loadedConfig,
1202
1204
  configPath
@@ -1210,7 +1212,7 @@ ${section.body}` : section.body).join("\n\n"));
1210
1212
  this.colors = this.createColors();
1211
1213
  this.program = program;
1212
1214
  program.help();
1213
- program.version("1.6.0-beta.1");
1215
+ program.version("1.6.1");
1214
1216
  }
1215
1217
  async createCompiler(options, rspackCommand, callback) {
1216
1218
  let { config, pathMap } = await this.loadConfig(options);
package/dist/index.mjs CHANGED
@@ -811,9 +811,13 @@ async function runBuild(cli, options) {
811
811
  }
812
812
  if (stats?.hasErrors()) process.exitCode = 1;
813
813
  if (!compiler || !stats) return;
814
- const statsOptions = cli.isMultipleCompiler(compiler) ? {
815
- children: compiler.compilers.map((item)=>item.options ? item.options.stats : void 0)
816
- } : compiler.options?.stats;
814
+ const getStatsOptions = ()=>{
815
+ if (cli.isMultipleCompiler(compiler)) return {
816
+ children: compiler.compilers.map((item)=>item.options ? item.options.stats : void 0)
817
+ };
818
+ return compiler.options?.stats;
819
+ };
820
+ const statsOptions = getStatsOptions();
817
821
  if (options.json && createJsonStringifyStream) {
818
822
  const handleWriteError = (error)=>{
819
823
  logger.error(error);
@@ -995,16 +999,14 @@ const readPackageUp = (cwd = process.cwd())=>{
995
999
  }
996
1000
  };
997
1001
  const utils_readPackageUp = readPackageUp;
998
- const isEsmFile = (filePath, cwd = process.cwd())=>{
999
- const ext = external_node_path_["default"].extname(filePath);
1000
- if (/\.(mjs|mts)$/.test(ext)) return true;
1001
- if (/\.(cjs|cts)/.test(ext)) return false;
1002
+ const isEsmFile = (filePath)=>{
1003
+ if (/\.(mjs|mts)$/.test(filePath)) return true;
1004
+ if (/\.(cjs|cts)$/.test(filePath)) return false;
1002
1005
  const packageJson = utils_readPackageUp(external_node_path_["default"].dirname(filePath));
1003
1006
  return packageJson?.type === "module";
1004
1007
  };
1005
- const utils_isEsmFile = isEsmFile;
1006
- const crossImport = async (path, cwd = process.cwd())=>{
1007
- if (utils_isEsmFile(path, cwd)) {
1008
+ const crossImport = async (path)=>{
1009
+ if (isEsmFile(path)) {
1008
1010
  const url = (0, __WEBPACK_EXTERNAL_MODULE_node_url_e96de089__.pathToFileURL)(path).href;
1009
1011
  const { default: config } = await import(url);
1010
1012
  return config;
@@ -1028,11 +1030,11 @@ const TS_EXTENSION = [
1028
1030
  ".cts",
1029
1031
  ".mts"
1030
1032
  ];
1031
- const isTsFile_isTsFile = (configPath)=>{
1033
+ const isTsFile = (configPath)=>{
1032
1034
  const ext = external_node_path_["default"].extname(configPath);
1033
1035
  return TS_EXTENSION.includes(ext);
1034
1036
  };
1035
- const isTsFile = isTsFile_isTsFile;
1037
+ const utils_isTsFile = isTsFile;
1036
1038
  const injectInlineSourceMap = ({ code, map })=>{
1037
1039
  if (map) {
1038
1040
  const base64Map = Buffer.from(map, "utf8").toString("base64");
@@ -1065,8 +1067,8 @@ function compile(sourcecode, filename) {
1065
1067
  }
1066
1068
  const loadConfig_DEFAULT_CONFIG_NAME = "rspack.config";
1067
1069
  const registerLoader = (configPath)=>{
1068
- if (utils_isEsmFile(configPath) && isTsFile(configPath)) return;
1069
- if (!isTsFile(configPath)) throw new Error(`config file "${configPath}" is not supported.`);
1070
+ if (isEsmFile(configPath) && utils_isTsFile(configPath)) return;
1071
+ if (!utils_isTsFile(configPath)) throw new Error(`config file "${configPath}" is not supported.`);
1070
1072
  (0, lib.addHook)((code, filename)=>{
1071
1073
  try {
1072
1074
  return compile(code, filename);
@@ -1129,8 +1131,8 @@ async function loadExtendedConfig(config, configPath, cwd, options) {
1129
1131
  throw new Error(`Cannot find module '${extendPath}' to extend from.`);
1130
1132
  }
1131
1133
  if (!external_node_fs_["default"].existsSync(resolvedPath)) throw new Error(`Extended configuration file "${resolvedPath}" not found.`);
1132
- if (isTsFile(resolvedPath) && "register" === options.configLoader) registerLoader(resolvedPath);
1133
- let loadedConfig = await crossImport(resolvedPath, cwd);
1134
+ if (utils_isTsFile(resolvedPath) && "register" === options.configLoader) registerLoader(resolvedPath);
1135
+ let loadedConfig = await crossImport(resolvedPath);
1134
1136
  if ("function" == typeof loadedConfig) {
1135
1137
  loadedConfig = loadedConfig(options.env, options);
1136
1138
  if ("function" == typeof loadedConfig.then) loadedConfig = await loadedConfig;
@@ -1158,8 +1160,8 @@ async function loadRspackConfig(options, cwd = process.cwd()) {
1158
1160
  if (!defaultConfig) return null;
1159
1161
  configPath = defaultConfig;
1160
1162
  }
1161
- if (isTsFile(configPath) && "register" === options.configLoader) registerLoader(configPath);
1162
- const loadedConfig = await crossImport(configPath, cwd);
1163
+ if (utils_isTsFile(configPath) && "register" === options.configLoader) registerLoader(configPath);
1164
+ const loadedConfig = await crossImport(configPath);
1163
1165
  return {
1164
1166
  loadedConfig,
1165
1167
  configPath
@@ -1173,7 +1175,7 @@ class RspackCLI {
1173
1175
  this.colors = this.createColors();
1174
1176
  this.program = program;
1175
1177
  program.help();
1176
- program.version("1.6.0-beta.1");
1178
+ program.version("1.6.1");
1177
1179
  }
1178
1180
  async createCompiler(options, rspackCommand, callback) {
1179
1181
  let { config, pathMap } = await this.loadConfig(options);
@@ -1 +1 @@
1
- export declare const crossImport: <T = any>(path: string, cwd?: string) => Promise<T>;
1
+ export declare const crossImport: <T = any>(path: string) => Promise<T>;
@@ -1,2 +1 @@
1
- declare const isEsmFile: (filePath: string, cwd?: string) => boolean;
2
- export default isEsmFile;
1
+ export declare const isEsmFile: (filePath: string) => boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rspack/cli",
3
- "version": "1.6.0-beta.1",
3
+ "version": "1.6.1",
4
4
  "description": "CLI for rspack",
5
5
  "homepage": "https://rspack.rs",
6
6
  "bugs": "https://github.com/web-infra-dev/rspack/issues",
@@ -34,7 +34,7 @@
34
34
  "webpack-bundle-analyzer": "4.10.2"
35
35
  },
36
36
  "devDependencies": {
37
- "@rslib/core": "0.15.1",
37
+ "@rslib/core": "0.17.0",
38
38
  "@types/webpack-bundle-analyzer": "^4.7.0",
39
39
  "cac": "^6.7.14",
40
40
  "concat-stream": "^2.0.0",
@@ -44,8 +44,8 @@
44
44
  "pirates": "^4.0.7",
45
45
  "ts-node": "^10.9.2",
46
46
  "typescript": "^5.9.3",
47
- "@rspack/core": "1.6.0-beta.1",
48
- "@rspack/test-tools": "1.6.0-beta.1"
47
+ "@rspack/core": "1.6.1",
48
+ "@rspack/test-tools": "1.6.1"
49
49
  },
50
50
  "peerDependencies": {
51
51
  "@rspack/core": "^1.0.0-alpha || ^1.x"
@@ -57,6 +57,6 @@
57
57
  "scripts": {
58
58
  "build": "rslib build",
59
59
  "dev": "rslib build -w",
60
- "test": "cross-env RUST_BACKTRACE=full jest --colors"
60
+ "test": "rstest"
61
61
  }
62
62
  }