@rspack/core 0.7.6-canary-1a0d77d-20240627143904 → 1.0.0-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.
Files changed (64) hide show
  1. package/README.md +2 -2
  2. package/compiled/webpack-sources/index.d.ts +130 -0
  3. package/compiled/webpack-sources/index.js +3520 -0
  4. package/compiled/webpack-sources/license +21 -0
  5. package/compiled/webpack-sources/package.json +1 -0
  6. package/dist/Chunk.d.ts +19 -14
  7. package/dist/Chunk.js +22 -17
  8. package/dist/ChunkGraph.d.ts +1 -1
  9. package/dist/ChunkGraph.js +5 -5
  10. package/dist/ChunkGroup.d.ts +17 -7
  11. package/dist/ChunkGroup.js +12 -2
  12. package/dist/Compilation.d.ts +19 -23
  13. package/dist/Compilation.js +20 -43
  14. package/dist/Compiler.d.ts +1 -1
  15. package/dist/Compiler.js +32 -2
  16. package/dist/Entrypoint.d.ts +1 -1
  17. package/dist/Entrypoint.js +2 -2
  18. package/dist/Module.d.ts +12 -7
  19. package/dist/Module.js +1 -0
  20. package/dist/NormalModule.d.ts +0 -1
  21. package/dist/NormalModule.js +0 -7
  22. package/dist/NormalModuleFactory.d.ts +1 -0
  23. package/dist/NormalModuleFactory.js +1 -22
  24. package/dist/RspackError.d.ts +8 -0
  25. package/dist/RspackError.js +21 -0
  26. package/dist/Stats.d.ts +2 -2
  27. package/dist/Template.d.ts +1 -1
  28. package/dist/Template.js +2 -2
  29. package/dist/builtin-loader/swc/index.d.ts +0 -4
  30. package/dist/builtin-loader/swc/index.js +1 -5
  31. package/dist/builtin-loader/swc/preact.d.ts +3 -4
  32. package/dist/builtin-loader/swc/types.d.ts +2 -17
  33. package/dist/builtin-plugin/BundlerInfoRspackPlugin.d.ts +1 -0
  34. package/dist/builtin-plugin/BundlerInfoRspackPlugin.js +1 -0
  35. package/dist/builtin-plugin/SwcJsMinimizerPlugin.d.ts +0 -28
  36. package/dist/builtin-plugin/SwcJsMinimizerPlugin.js +20 -69
  37. package/dist/builtin-plugin/css-extract/index.d.ts +2 -2
  38. package/dist/config/adapter.js +23 -10
  39. package/dist/config/adapterRuleUse.js +0 -11
  40. package/dist/config/defaults.js +22 -30
  41. package/dist/config/normalization.js +13 -5
  42. package/dist/config/zod.d.ts +168 -43
  43. package/dist/config/zod.js +23 -11
  44. package/dist/container/ModuleFederationPlugin.js +1 -1
  45. package/dist/container/default.runtime.js +1 -170
  46. package/dist/exports.d.ts +1 -1
  47. package/dist/exports.js +1 -1
  48. package/dist/lite-tapable/index.js +2 -2
  49. package/dist/loader-runner/index.js +28 -7
  50. package/dist/rspackOptionsApply.js +3 -0
  51. package/dist/stats/DefaultStatsFactoryPlugin.js +35 -11
  52. package/dist/stats/DefaultStatsPrinterPlugin.js +2 -2
  53. package/dist/stats/statsFactoryUtils.d.ts +13 -4
  54. package/dist/util/index.d.ts +2 -2
  55. package/dist/util/index.js +4 -3
  56. package/dist/util/memoize.js +5 -1
  57. package/dist/util/source.d.ts +1 -1
  58. package/dist/util/source.js +1 -1
  59. package/package.json +12 -7
  60. package/dist/builtin-loader/swc/emotion.d.ts +0 -17
  61. package/dist/builtin-loader/swc/emotion.js +0 -22
  62. package/dist/builtin-loader/swc/relay.d.ts +0 -5
  63. package/dist/builtin-loader/swc/relay.js +0 -48
  64. package/dist/container/default.runtime.d.ts +0 -2
@@ -16,14 +16,13 @@ exports.applyRspackOptionsBaseDefaults = exports.applyRspackOptionsDefaults = vo
16
16
  const assert_1 = __importDefault(require("assert"));
17
17
  const fs_1 = __importDefault(require("fs"));
18
18
  const path_1 = __importDefault(require("path"));
19
+ const ModuleTypeConstants_1 = require("../ModuleTypeConstants");
20
+ const builtin_plugin_1 = require("../builtin-plugin");
19
21
  const util_1 = require("../util");
22
+ const assertNotNil_1 = require("../util/assertNotNil");
20
23
  const cleverMerge_1 = require("../util/cleverMerge");
21
24
  const target_1 = require("./target");
22
25
  const Template = require("../Template");
23
- const ModuleTypeConstants_1 = require("../ModuleTypeConstants");
24
- const SwcCssMinimizerPlugin_1 = require("../builtin-plugin/SwcCssMinimizerPlugin");
25
- const SwcJsMinimizerPlugin_1 = require("../builtin-plugin/SwcJsMinimizerPlugin");
26
- const assertNotNil_1 = require("../util/assertNotNil");
27
26
  const applyRspackOptionsDefaults = (options) => {
28
27
  F(options, "context", () => process.cwd());
29
28
  F(options, "target", () => {
@@ -43,19 +42,15 @@ const applyRspackOptionsDefaults = (options) => {
43
42
  F(options.entry[key], "import", () => ["./src"]);
44
43
  }
45
44
  }
46
- // IGNORE(devtool): devtool is default to "eval" in webpack when mode is development
47
- F(options, "devtool", () => false);
45
+ F(options, "devtool", () => (development ? "eval" : false));
48
46
  D(options, "watch", false);
49
47
  D(options, "profile", false);
50
48
  // IGNORE(bail): bail is default to false in webpack, but it's set in `Compilation`
51
49
  D(options, "bail", false);
52
- const futureDefaults = options.experiments.futureDefaults ?? false;
53
50
  // IGNORE(cache): cache is default to { type: "memory" } in webpack when the mode is development,
54
51
  // but Rspack currently does not support this option
55
52
  F(options, "cache", () => development);
56
- applyExperimentsDefaults(options.experiments, {
57
- cache: options.cache
58
- });
53
+ applyExperimentsDefaults(options.experiments);
59
54
  applySnapshotDefaults(options.snapshot, { production });
60
55
  applyModuleDefaults(options.module, {
61
56
  asyncWebAssembly: options.experiments.asyncWebAssembly,
@@ -72,7 +67,7 @@ const applyRspackOptionsDefaults = (options) => {
72
67
  outputModule: options.experiments.outputModule,
73
68
  development,
74
69
  entry: options.entry,
75
- futureDefaults
70
+ futureDefaults: options.experiments.futureDefaults
76
71
  });
77
72
  applyExternalsPresetsDefaults(options.externalsPresets, {
78
73
  targetProperties
@@ -125,13 +120,12 @@ const applyInfrastructureLoggingDefaults = (infrastructureLogging) => {
125
120
  D(infrastructureLogging, "colors", tty);
126
121
  D(infrastructureLogging, "appendOnly", !tty);
127
122
  };
128
- const applyExperimentsDefaults = (experiments, { cache }) => {
123
+ const applyExperimentsDefaults = (experiments) => {
124
+ D(experiments, "futureDefaults", false);
129
125
  // IGNORE(experiments.lazyCompilation): In webpack, lazyCompilation is undefined by default
130
126
  D(experiments, "lazyCompilation", false);
131
- // IGNORE(experiments.asyncWebAssembly): The default value of `asyncWebAssembly` is determined by `futureDefaults` in webpack.
132
- D(experiments, "asyncWebAssembly", false);
133
- // IGNORE(experiments.css): Rspack will switch to `false` when reach 1.0 and `css-extract` is stable enough
134
- D(experiments, "css", true);
127
+ D(experiments, "asyncWebAssembly", experiments.futureDefaults);
128
+ D(experiments, "css", experiments.futureDefaults ? true : undefined);
135
129
  D(experiments, "topLevelAwait", true);
136
130
  // IGNORE(experiments.rspackFuture): Rspack specific configuration
137
131
  D(experiments, "rspackFuture", {});
@@ -139,7 +133,8 @@ const applyExperimentsDefaults = (experiments, { cache }) => {
139
133
  D(experiments.rspackFuture, "bundlerInfo", {});
140
134
  if (typeof experiments.rspackFuture.bundlerInfo === "object") {
141
135
  D(experiments.rspackFuture.bundlerInfo, "version", require("../../package.json").version);
142
- D(experiments.rspackFuture.bundlerInfo, "force", false);
136
+ D(experiments.rspackFuture.bundlerInfo, "bundler", "rspack");
137
+ D(experiments.rspackFuture.bundlerInfo, "force", true);
143
138
  }
144
139
  }
145
140
  };
@@ -155,10 +150,12 @@ const applyJavascriptParserOptionsDefaults = (parserOptions, fallback) => {
155
150
  D(parserOptions, "importExportsPresence", fallback?.importExportsPresence);
156
151
  D(parserOptions, "reexportExportsPresence", fallback?.reexportExportsPresence);
157
152
  D(parserOptions, "strictExportPresence", fallback?.strictExportPresence ?? false);
153
+ D(parserOptions, "worker", fallback?.worker ?? ["..."]);
158
154
  };
159
155
  const applyModuleDefaults = (module, { asyncWebAssembly, css, targetProperties }) => {
160
156
  (0, assertNotNil_1.assertNotNill)(module.parser);
161
157
  (0, assertNotNil_1.assertNotNill)(module.generator);
158
+ // IGNORE(module.parser): already check to align in 2024.6.27
162
159
  F(module.parser, ModuleTypeConstants_1.ASSET_MODULE_TYPE, () => ({}));
163
160
  (0, assertNotNil_1.assertNotNill)(module.parser.asset);
164
161
  F(module.parser.asset, "dataUrlCondition", () => ({}));
@@ -177,8 +174,6 @@ const applyModuleDefaults = (module, { asyncWebAssembly, css, targetProperties }
177
174
  F(module.parser, "javascript/esm", () => ({}));
178
175
  (0, assertNotNil_1.assertNotNill)(module.parser["javascript/esm"]);
179
176
  applyJavascriptParserOptionsDefaults(module.parser["javascript/esm"], module.parser.javascript);
180
- // IGNORE(module.generator): Rspack enables `experiments.css` by default currently
181
- // IGNORE(module.parser): Rspack enables `experiments.css` by default currently
182
177
  if (css) {
183
178
  F(module.parser, "css", () => ({}));
184
179
  (0, assertNotNil_1.assertNotNill)(module.parser.css);
@@ -189,6 +184,7 @@ const applyModuleDefaults = (module, { asyncWebAssembly, css, targetProperties }
189
184
  F(module.parser, "css/module", () => ({}));
190
185
  (0, assertNotNil_1.assertNotNill)(module.parser["css/module"]);
191
186
  D(module.parser["css/module"], "namedExports", true);
187
+ // IGNORE(module.generator): already check to align in 2024.6.27
192
188
  F(module.generator, "css", () => ({}));
193
189
  (0, assertNotNil_1.assertNotNill)(module.generator.css);
194
190
  D(module.generator["css"], "exportsOnly", !targetProperties || !targetProperties.document);
@@ -627,6 +623,7 @@ const applyExternalsPresetsDefaults = (externalsPresets, { targetProperties }) =
627
623
  D(externalsPresets, "electronRenderer", targetProperties &&
628
624
  targetProperties.electron &&
629
625
  targetProperties.electronRenderer);
626
+ D(externalsPresets, "nwjs", targetProperties && targetProperties.nwjs);
630
627
  };
631
628
  const applyLoaderDefaults = (loader, { targetProperties, environment }) => {
632
629
  F(loader, "target", () => {
@@ -680,25 +677,22 @@ const applyPerformanceDefaults = (performance, { production }) => {
680
677
  F(performance, "hints", () => (production ? "warning" : false));
681
678
  };
682
679
  const applyOptimizationDefaults = (optimization, { production, development, css }) => {
683
- // IGNORE(optimization.removeAvailableModules): In webpack, removeAvailableModules is false by default
684
- D(optimization, "removeAvailableModules", true);
680
+ D(optimization, "removeAvailableModules", false);
685
681
  D(optimization, "removeEmptyChunks", true);
686
682
  D(optimization, "mergeDuplicateChunks", true);
687
- // IGNORE(optimization.moduleIds): set to "natural" by default in rspack 1.0
688
683
  F(optimization, "moduleIds", () => {
689
684
  if (production)
690
685
  return "deterministic";
691
686
  if (development)
692
687
  return "named";
693
- return "named";
688
+ return "natural";
694
689
  });
695
- // IGNORE(optimization.chunkIds): set to "natural" by default in rspack 1.0
696
690
  F(optimization, "chunkIds", () => {
697
691
  if (production)
698
692
  return "deterministic";
699
693
  if (development)
700
694
  return "named";
701
- return "named";
695
+ return "natural";
702
696
  });
703
697
  F(optimization, "sideEffects", () => (production ? true : "flag"));
704
698
  D(optimization, "mangleExports", production);
@@ -708,13 +702,11 @@ const applyOptimizationDefaults = (optimization, { production, development, css
708
702
  D(optimization, "runtimeChunk", false);
709
703
  D(optimization, "realContentHash", production);
710
704
  D(optimization, "minimize", production);
711
- // IGNORE(optimization.concatenateModules): webpack sets this option as true by default when the mode is production,
712
- // but rspack is in the experimental stage and sets it to false by default
713
- D(optimization, "concatenateModules", false);
705
+ D(optimization, "concatenateModules", production);
714
706
  // IGNORE(optimization.minimizer): Rspack use `SwcJsMinimizerRspackPlugin` and `SwcCssMinimizerRspackPlugin` by default
715
707
  A(optimization, "minimizer", () => [
716
- new SwcJsMinimizerPlugin_1.SwcJsMinimizerRspackPlugin(),
717
- new SwcCssMinimizerPlugin_1.SwcCssMinimizerRspackPlugin()
708
+ new builtin_plugin_1.SwcJsMinimizerRspackPlugin(),
709
+ new builtin_plugin_1.LightningCssMinimizerRspackPlugin()
718
710
  ]);
719
711
  F(optimization, "nodeEnv", () => {
720
712
  if (production)
@@ -87,9 +87,7 @@ const getNormalizedRspackOptions = (config) => {
87
87
  auxiliaryComment: output.auxiliaryComment !== undefined
88
88
  ? output.auxiliaryComment
89
89
  : libraryBase.auxiliaryComment,
90
- amdContainer: output.amdContainer !== undefined
91
- ? output.amdContainer
92
- : libraryBase.amdContainer,
90
+ amdContainer: libraryBase.amdContainer,
93
91
  export: output.libraryExport !== undefined
94
92
  ? output.libraryExport
95
93
  : libraryBase.export,
@@ -123,10 +121,20 @@ const getNormalizedRspackOptions = (config) => {
123
121
  };
124
122
  }),
125
123
  resolve: nestedConfig(config.resolve, resolve => ({
126
- ...resolve
124
+ ...resolve,
125
+ tsConfig: optionalNestedConfig(resolve.tsConfig, tsConfig => {
126
+ return typeof tsConfig === "string"
127
+ ? { configFile: tsConfig }
128
+ : tsConfig;
129
+ })
127
130
  })),
128
131
  resolveLoader: nestedConfig(config.resolveLoader, resolve => ({
129
- ...resolve
132
+ ...resolve,
133
+ tsConfig: optionalNestedConfig(resolve.tsConfig, tsConfig => {
134
+ return typeof tsConfig === "string"
135
+ ? { configFile: tsConfig }
136
+ : tsConfig;
137
+ })
130
138
  })),
131
139
  module: nestedConfig(config.module, module => ({
132
140
  noParse: module.noParse,