@rspack/core 0.6.5-canary-231c64e-20240515075232 → 0.6.5-canary-5042eed-20240515115707

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.
@@ -4,7 +4,6 @@ exports.rspackOptions = exports.externalsType = void 0;
4
4
  const zod_1 = require("../../compiled/zod");
5
5
  const Chunk_1 = require("../Chunk");
6
6
  const Module_1 = require("../Module");
7
- const util_1 = require("../util");
8
7
  //#region Name
9
8
  const name = zod_1.z.string();
10
9
  //#endregion
@@ -372,19 +371,23 @@ const cssGeneratorExportsConvention = zod_1.z.enum([
372
371
  ]);
373
372
  const cssGeneratorExportsOnly = zod_1.z.boolean();
374
373
  const cssGeneratorLocalIdentName = zod_1.z.string();
374
+ const cssGeneratorEsModule = zod_1.z.boolean();
375
375
  const cssGeneratorOptions = zod_1.z.strictObject({
376
376
  exportsConvention: cssGeneratorExportsConvention.optional(),
377
- exportsOnly: cssGeneratorExportsOnly.optional()
377
+ exportsOnly: cssGeneratorExportsOnly.optional(),
378
+ esModule: cssGeneratorEsModule.optional()
378
379
  });
379
380
  const cssAutoGeneratorOptions = zod_1.z.strictObject({
380
381
  exportsConvention: cssGeneratorExportsConvention.optional(),
381
382
  exportsOnly: cssGeneratorExportsOnly.optional(),
382
- localIdentName: cssGeneratorLocalIdentName.optional()
383
+ localIdentName: cssGeneratorLocalIdentName.optional(),
384
+ esModule: cssGeneratorEsModule.optional()
383
385
  });
384
386
  const cssModuleGeneratorOptions = zod_1.z.strictObject({
385
387
  exportsConvention: cssGeneratorExportsConvention.optional(),
386
388
  exportsOnly: cssGeneratorExportsOnly.optional(),
387
- localIdentName: cssGeneratorLocalIdentName.optional()
389
+ localIdentName: cssGeneratorLocalIdentName.optional(),
390
+ esModule: cssGeneratorEsModule.optional()
388
391
  });
389
392
  const generatorOptionsByModuleTypeKnown = zod_1.z.strictObject({
390
393
  asset: assetGeneratorOptions.optional(),
@@ -746,21 +749,19 @@ const rspackFutureOptions = zod_1.z.strictObject({
746
749
  })
747
750
  .optional()
748
751
  });
752
+ const lazyCompilationOptions = zod_1.z.object({
753
+ imports: zod_1.z.boolean().optional(),
754
+ entries: zod_1.z.boolean().optional(),
755
+ test: zod_1.z
756
+ .instanceof(RegExp)
757
+ .or(zod_1.z.function().args(zod_1.z.custom()).returns(zod_1.z.boolean()))
758
+ .optional()
759
+ });
749
760
  const experiments = zod_1.z.strictObject({
750
- lazyCompilation: zod_1.z.boolean().optional(),
761
+ lazyCompilation: zod_1.z.boolean().optional().or(lazyCompilationOptions),
751
762
  asyncWebAssembly: zod_1.z.boolean().optional(),
752
763
  outputModule: zod_1.z.boolean().optional(),
753
764
  topLevelAwait: zod_1.z.boolean().optional(),
754
- newSplitChunks: zod_1.z
755
- .boolean()
756
- .optional()
757
- .refine(val => {
758
- if (val === false) {
759
- (0, util_1.deprecatedWarn)(`'experiments.newSplitChunks = ${JSON.stringify(val)}' has been deprecated, please switch to 'experiments.newSplitChunks = true' to use webpack's behavior.
760
- See the discussion here (https://github.com/web-infra-dev/rspack/discussions/4168)`);
761
- }
762
- return true;
763
- }),
764
765
  css: zod_1.z.boolean().optional(),
765
766
  futureDefaults: zod_1.z.boolean().optional(),
766
767
  rspackFuture: rspackFutureOptions.optional()
@@ -14,6 +14,7 @@ exports.RspackOptionsApply = void 0;
14
14
  * https://github.com/webpack/webpack/blob/main/LICENSE
15
15
  */
16
16
  const assert_1 = __importDefault(require("assert"));
17
+ const Module_1 = require("./Module");
17
18
  const graceful_fs_1 = __importDefault(require("../compiled/graceful-fs"));
18
19
  const builtin_plugin_1 = require("./builtin-plugin");
19
20
  const EntryOptionPlugin_1 = __importDefault(require("./lib/EntryOptionPlugin"));
@@ -25,7 +26,7 @@ const cleverMerge_1 = require("./util/cleverMerge");
25
26
  class RspackOptionsApply {
26
27
  constructor() { }
27
28
  process(options, compiler) {
28
- var _a;
29
+ var _a, _b, _c, _d;
29
30
  (0, assert_1.default)(options.output.path, "options.output.path should have value after `applyRspackOptionsDefaults`");
30
31
  compiler.outputPath = options.output.path;
31
32
  compiler.name = options.name;
@@ -163,6 +164,24 @@ class RspackOptionsApply {
163
164
  new builtin_plugin_1.MangleExportsPlugin(options.optimization.mangleExports !== "size").apply(compiler);
164
165
  }
165
166
  }
167
+ if (options.experiments.lazyCompilation) {
168
+ const lazyOptions = options.experiments.lazyCompilation;
169
+ new builtin_plugin_1.LazyCompilationPlugin(
170
+ // this is only for test
171
+ // @ts-expect-error cacheable is hide
172
+ (_b = lazyOptions.cacheable) !== null && _b !== void 0 ? _b : true, (_c = lazyOptions.entries) !== null && _c !== void 0 ? _c : true, (_d = lazyOptions.imports) !== null && _d !== void 0 ? _d : true, typeof lazyOptions.test === "function"
173
+ ? function (jsModule) {
174
+ return lazyOptions.test.call(lazyOptions, new Module_1.Module(jsModule));
175
+ }
176
+ : lazyOptions.test
177
+ ? {
178
+ source: lazyOptions.test.source,
179
+ flags: lazyOptions.test.flags
180
+ }
181
+ : undefined,
182
+ // @ts-expect-error backend is hide
183
+ lazyOptions.backend).apply(compiler);
184
+ }
166
185
  if (options.output.enabledLibraryTypes &&
167
186
  options.output.enabledLibraryTypes.length > 0) {
168
187
  for (const type of options.output.enabledLibraryTypes) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rspack/core",
3
- "version": "0.6.5-canary-231c64e-20240515075232",
3
+ "version": "0.6.5-canary-5042eed-20240515115707",
4
4
  "webpackVersion": "5.75.0",
5
5
  "license": "MIT",
6
6
  "description": "A Fast Rust-based Web Bundler",
@@ -71,8 +71,8 @@
71
71
  "watchpack": "^2.4.0",
72
72
  "zod": "^3.21.4",
73
73
  "zod-validation-error": "1.3.1",
74
- "@rspack/plugin-minify": "^0.6.5-canary-231c64e-20240515075232",
75
- "@rspack/core": "0.6.5-canary-231c64e-20240515075232"
74
+ "@rspack/plugin-minify": "^0.6.5-canary-5042eed-20240515115707",
75
+ "@rspack/core": "0.6.5-canary-5042eed-20240515115707"
76
76
  },
77
77
  "dependencies": {
78
78
  "@module-federation/runtime-tools": "0.1.6",
@@ -80,7 +80,7 @@
80
80
  "enhanced-resolve": "5.12.0",
81
81
  "tapable": "2.2.1",
82
82
  "webpack-sources": "3.2.3",
83
- "@rspack/binding": "0.6.5-canary-231c64e-20240515075232"
83
+ "@rspack/binding": "0.6.5-canary-5042eed-20240515115707"
84
84
  },
85
85
  "peerDependencies": {
86
86
  "@swc/helpers": ">=0.5.1"