@rspack/cli 2.2.2 → 2.2.4

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.
Files changed (2) hide show
  1. package/dist/index.js +22 -9
  2. package/package.json +6 -6
package/dist/index.js CHANGED
@@ -890,6 +890,10 @@ const loadWithJiti = async (configPath, exportName, fresh)=>{
890
890
  dependencies: []
891
891
  };
892
892
  };
893
+ const CONFIG_META = Symbol.for('@rstackjs/load-config/meta');
894
+ function getConfigMeta(config) {
895
+ if (null !== config && 'object' == typeof config && Object.hasOwn(config, CONFIG_META)) return config[CONFIG_META];
896
+ }
893
897
  const JS_CONFIG_REGEXP = /\.(?:js|mjs|cjs)$/;
894
898
  const loadWithNative = async (configPath, fresh)=>{
895
899
  const configFileURL = pathToFileURL(configPath).href;
@@ -948,20 +952,29 @@ async function loadConfig({ cwd = process.cwd(), path, configFileNames = [], loa
948
952
  }
949
953
  if (!loadedConfig) loadedConfig = await loadWithJiti(configPath, exportName, fresh);
950
954
  const { configExport, dependencies } = loadedConfig;
955
+ let content;
951
956
  if (isConfigFunction(configExport)) {
952
957
  const result = await configExport(...configParams);
953
958
  if (void 0 === result) throw new Error('The config function must return a config object.');
954
- return {
955
- content: result,
956
- filePath: configPath,
957
- dependencies
958
- };
959
- }
960
- return {
961
- content: configExport,
959
+ content = result;
960
+ } else content = configExport;
961
+ const meta = getConfigMeta(content);
962
+ const result = {
963
+ content,
962
964
  filePath: configPath,
963
965
  dependencies
964
966
  };
967
+ if (meta) {
968
+ result.filePath = meta.filePath;
969
+ result.dependencies = [
970
+ ...new Set([
971
+ ...meta.dependencies ?? [],
972
+ configPath,
973
+ ...dependencies
974
+ ])
975
+ ];
976
+ }
977
+ return result;
965
978
  }
966
979
  const DEFAULT_EXTENSIONS = [
967
980
  '.ts',
@@ -1121,7 +1134,7 @@ class RspackCLI {
1121
1134
  this.colors = this.createColors();
1122
1135
  this.program = program;
1123
1136
  program.help();
1124
- program.version("2.2.2");
1137
+ program.version("2.2.4");
1125
1138
  }
1126
1139
  wrapAction(fn) {
1127
1140
  return (...args)=>{
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rspack/cli",
3
- "version": "2.2.2",
3
+ "version": "2.2.4",
4
4
  "description": "CLI for rspack",
5
5
  "homepage": "https://rspack.rs",
6
6
  "bugs": "https://github.com/web-infra-dev/rspack/issues",
@@ -29,8 +29,9 @@
29
29
  ],
30
30
  "devDependencies": {
31
31
  "@discoveryjs/json-ext": "^1.1.0",
32
- "@microsoft/api-extractor": "^7.59.0",
33
- "@rstackjs/load-config": "^0.1.2",
32
+ "@microsoft/api-extractor": "^7.59.1",
33
+ "@rstackjs/load-config": "^1.0.0",
34
+ "@rspack/core": "2.2.4",
34
35
  "@rspack/dev-server": "^2.2.1",
35
36
  "cac": "^7.0.0",
36
37
  "concat-stream": "^2.0.0",
@@ -39,9 +40,8 @@
39
40
  "jiti": "^2.7.0",
40
41
  "prebundle": "^1.6.5",
41
42
  "rspack-merge": "1.0.1",
42
- "rstack": "^0.6.4",
43
- "typescript": "^6.0.3",
44
- "@rspack/core": "2.2.2"
43
+ "rstack": "^0.7.4",
44
+ "typescript": "^6.0.3"
45
45
  },
46
46
  "peerDependencies": {
47
47
  "@rspack/core": "^2.0.0-0",