@rspack/core 0.6.5-canary-5042eed-20240515115707 → 0.6.5-canary-dc02c55-20240516004313

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.
@@ -24,7 +24,6 @@ export declare class Watching {
24
24
  watch(files: Iterable<string>, dirs: Iterable<string>, missing: Iterable<string>): void;
25
25
  close(callback?: () => void): void;
26
26
  invalidate(callback?: Callback<Error, void>): void;
27
- lazyCompilationInvalidate(files: Set<string>): void;
28
27
  /**
29
28
  * The reason why this is _done instead of #done, is that in Webpack,
30
29
  * it will rewrite this function to another function
package/dist/Watching.js CHANGED
@@ -160,9 +160,6 @@ class Watching {
160
160
  this.onChange();
161
161
  __classPrivateFieldGet(this, _Watching_instances, "m", _Watching_invalidate).call(this);
162
162
  }
163
- lazyCompilationInvalidate(files) {
164
- __classPrivateFieldGet(this, _Watching_instances, "m", _Watching_invalidate).call(this, new Map(), new Map(), files, new Set());
165
- }
166
163
  _done(error, compilation) {
167
164
  this.running = false;
168
165
  let stats = undefined;
@@ -38,7 +38,7 @@ function createBuiltinPlugin(name, options) {
38
38
  }
39
39
  exports.createBuiltinPlugin = createBuiltinPlugin;
40
40
  function create(name, resolve,
41
- // `affectedHooks` is used to inform `createChildCompile` about which builtin plugin can be reserved.
41
+ // `affectedHooks` is used to inform `createChildCompile` about which builtin plugin can be reversed.
42
42
  // However, this has a drawback as it doesn't represent the actual condition but merely serves as an indicator.
43
43
  affectedHooks) {
44
44
  class Plugin extends RspackBuiltinPlugin {
@@ -58,7 +58,6 @@ export * from "./SwcJsMinimizerPlugin";
58
58
  export * from "./WarnCaseSensitiveModulesPlugin";
59
59
  export * from "./WebWorkerTemplatePlugin";
60
60
  export * from "./WorkerPlugin";
61
- export * from "./lazy-compilation/plugin";
62
61
  import { RawBuiltins } from "@rspack/binding";
63
62
  import { RspackOptionsNormalized } from "..";
64
63
  export interface Builtins {
@@ -76,7 +76,6 @@ __exportStar(require("./SwcJsMinimizerPlugin"), exports);
76
76
  __exportStar(require("./WarnCaseSensitiveModulesPlugin"), exports);
77
77
  __exportStar(require("./WebWorkerTemplatePlugin"), exports);
78
78
  __exportStar(require("./WorkerPlugin"), exports);
79
- __exportStar(require("./lazy-compilation/plugin"), exports);
80
79
  function resolveTreeShaking(treeShaking, production) {
81
80
  return treeShaking !== undefined
82
81
  ? treeShaking.toString()
@@ -8,7 +8,7 @@
8
8
  * https://github.com/webpack/webpack/blob/main/LICENSE
9
9
  */
10
10
  import type { Compilation } from "../Compilation";
11
- import type { AssetModuleFilename, Bail, Builtins, CacheOptions, ChunkFilename, ChunkLoading, ChunkLoadingGlobal, Clean, Context, CrossOriginLoading, CssChunkFilename, CssFilename, Dependencies, DevServer, DevTool, DevtoolFallbackModuleFilenameTemplate, DevtoolModuleFilenameTemplate, DevtoolNamespace, EnabledLibraryTypes, EnabledWasmLoadingTypes, EntryFilename, EntryRuntime, Externals, ExternalsPresets, ExternalsType, Filename, GeneratorOptionsByModuleType, GlobalObject, HashDigest, HashDigestLength, HashFunction, HashSalt, HotUpdateChunkFilename, HotUpdateGlobal, HotUpdateMainFilename, Iife, ImportFunctionName, InfrastructureLogging, LibraryOptions, Mode, Name, Node, NoParseOption, Optimization, OutputModule, ParserOptionsByModuleType, Path, Performance, Plugins, Profile, PublicPath, Resolve, RspackFutureOptions, RspackOptions, RuleSetRules, ScriptType, SnapshotOptions, SourceMapFilename, StatsValue, StrictModuleErrorHandling, Target, TrustedTypes, UniqueName, WasmLoading, Watch, WatchOptions, WebassemblyModuleFilename, WorkerPublicPath, LazyCompilationOptions } from "./zod";
11
+ import type { AssetModuleFilename, Bail, Builtins, CacheOptions, ChunkFilename, ChunkLoading, ChunkLoadingGlobal, Clean, Context, CrossOriginLoading, CssChunkFilename, CssFilename, Dependencies, DevServer, DevTool, DevtoolFallbackModuleFilenameTemplate, DevtoolModuleFilenameTemplate, DevtoolNamespace, EnabledLibraryTypes, EnabledWasmLoadingTypes, EntryFilename, EntryRuntime, Externals, ExternalsPresets, ExternalsType, Filename, GeneratorOptionsByModuleType, GlobalObject, HashDigest, HashDigestLength, HashFunction, HashSalt, HotUpdateChunkFilename, HotUpdateGlobal, HotUpdateMainFilename, Iife, ImportFunctionName, InfrastructureLogging, LibraryOptions, Mode, Name, Node, NoParseOption, Optimization, OutputModule, ParserOptionsByModuleType, Path, Performance, Plugins, Profile, PublicPath, Resolve, RspackFutureOptions, RspackOptions, RuleSetRules, ScriptType, SnapshotOptions, SourceMapFilename, StatsValue, StrictModuleErrorHandling, Target, TrustedTypes, UniqueName, WasmLoading, Watch, WatchOptions, WebassemblyModuleFilename, WorkerPublicPath } from "./zod";
12
12
  export declare const getNormalizedRspackOptions: (config: RspackOptions) => RspackOptionsNormalized;
13
13
  export type EntryDynamicNormalized = () => Promise<EntryStaticNormalized>;
14
14
  export type EntryNormalized = EntryDynamicNormalized | EntryStaticNormalized;
@@ -78,7 +78,7 @@ export interface ModuleOptionsNormalized {
78
78
  noParse?: NoParseOption;
79
79
  }
80
80
  export interface ExperimentsNormalized {
81
- lazyCompilation?: false | LazyCompilationOptions;
81
+ lazyCompilation?: boolean;
82
82
  asyncWebAssembly?: boolean;
83
83
  outputModule?: boolean;
84
84
  topLevelAwait?: boolean;
@@ -190,8 +190,7 @@ const getNormalizedRspackOptions = (config) => {
190
190
  performance: config.performance,
191
191
  plugins: nestedArray(config.plugins, p => [...p]),
192
192
  experiments: nestedConfig(config.experiments, experiments => ({
193
- ...experiments,
194
- lazyCompilation: optionalNestedConfig(experiments.lazyCompilation, options => (options === true ? {} : options))
193
+ ...experiments
195
194
  })),
196
195
  watch: config.watch,
197
196
  watchOptions: cloneObject(config.watchOptions),
@@ -4502,34 +4502,8 @@ declare const rspackFutureOptions: z.ZodObject<{
4502
4502
  } | undefined;
4503
4503
  }>;
4504
4504
  export type RspackFutureOptions = z.infer<typeof rspackFutureOptions>;
4505
- declare const lazyCompilationOptions: z.ZodObject<{
4506
- imports: z.ZodOptional<z.ZodBoolean>;
4507
- entries: z.ZodOptional<z.ZodBoolean>;
4508
- test: z.ZodOptional<z.ZodUnion<[z.ZodType<RegExp, z.ZodTypeDef, RegExp>, z.ZodFunction<z.ZodTuple<[z.ZodType<Module, z.ZodTypeDef, Module>], z.ZodUnknown>, z.ZodBoolean>]>>;
4509
- }, "strip", z.ZodTypeAny, {
4510
- imports?: boolean | undefined;
4511
- entries?: boolean | undefined;
4512
- test?: RegExp | ((args_0: Module, ...args_1: unknown[]) => boolean) | undefined;
4513
- }, {
4514
- imports?: boolean | undefined;
4515
- entries?: boolean | undefined;
4516
- test?: RegExp | ((args_0: Module, ...args_1: unknown[]) => boolean) | undefined;
4517
- }>;
4518
- export type LazyCompilationOptions = z.infer<typeof lazyCompilationOptions>;
4519
4505
  declare const experiments: z.ZodObject<{
4520
- lazyCompilation: z.ZodUnion<[z.ZodOptional<z.ZodBoolean>, z.ZodObject<{
4521
- imports: z.ZodOptional<z.ZodBoolean>;
4522
- entries: z.ZodOptional<z.ZodBoolean>;
4523
- test: z.ZodOptional<z.ZodUnion<[z.ZodType<RegExp, z.ZodTypeDef, RegExp>, z.ZodFunction<z.ZodTuple<[z.ZodType<Module, z.ZodTypeDef, Module>], z.ZodUnknown>, z.ZodBoolean>]>>;
4524
- }, "strip", z.ZodTypeAny, {
4525
- imports?: boolean | undefined;
4526
- entries?: boolean | undefined;
4527
- test?: RegExp | ((args_0: Module, ...args_1: unknown[]) => boolean) | undefined;
4528
- }, {
4529
- imports?: boolean | undefined;
4530
- entries?: boolean | undefined;
4531
- test?: RegExp | ((args_0: Module, ...args_1: unknown[]) => boolean) | undefined;
4532
- }>]>;
4506
+ lazyCompilation: z.ZodOptional<z.ZodBoolean>;
4533
4507
  asyncWebAssembly: z.ZodOptional<z.ZodBoolean>;
4534
4508
  outputModule: z.ZodOptional<z.ZodBoolean>;
4535
4509
  topLevelAwait: z.ZodOptional<z.ZodBoolean>;
@@ -4561,11 +4535,7 @@ declare const experiments: z.ZodObject<{
4561
4535
  } | undefined;
4562
4536
  }>>;
4563
4537
  }, "strict", z.ZodTypeAny, {
4564
- lazyCompilation?: boolean | {
4565
- imports?: boolean | undefined;
4566
- entries?: boolean | undefined;
4567
- test?: RegExp | ((args_0: Module, ...args_1: unknown[]) => boolean) | undefined;
4568
- } | undefined;
4538
+ lazyCompilation?: boolean | undefined;
4569
4539
  asyncWebAssembly?: boolean | undefined;
4570
4540
  outputModule?: boolean | undefined;
4571
4541
  topLevelAwait?: boolean | undefined;
@@ -4579,11 +4549,7 @@ declare const experiments: z.ZodObject<{
4579
4549
  } | undefined;
4580
4550
  } | undefined;
4581
4551
  }, {
4582
- lazyCompilation?: boolean | {
4583
- imports?: boolean | undefined;
4584
- entries?: boolean | undefined;
4585
- test?: RegExp | ((args_0: Module, ...args_1: unknown[]) => boolean) | undefined;
4586
- } | undefined;
4552
+ lazyCompilation?: boolean | undefined;
4587
4553
  asyncWebAssembly?: boolean | undefined;
4588
4554
  outputModule?: boolean | undefined;
4589
4555
  topLevelAwait?: boolean | undefined;
@@ -5217,19 +5183,7 @@ export declare const rspackOptions: z.ZodObject<{
5217
5183
  target: z.ZodOptional<z.ZodUnion<[z.ZodUnion<[z.ZodLiteral<false>, z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodEnum<["web", "webworker", "es3", "es5", "es2015", "es2016", "es2017", "es2018", "es2019", "es2020", "es2021", "es2022", "browserslist"]>, z.ZodLiteral<"node">]>, z.ZodLiteral<"async-node">]>, z.ZodType<`node${number}`, z.ZodTypeDef, `node${number}`>]>, z.ZodType<`async-node${number}`, z.ZodTypeDef, `async-node${number}`>]>, z.ZodType<`node${number}.${number}`, z.ZodTypeDef, `node${number}.${number}`>]>, z.ZodType<`async-node${number}.${number}`, z.ZodTypeDef, `async-node${number}.${number}`>]>, z.ZodLiteral<"electron-main">]>, z.ZodType<`electron${number}-main`, z.ZodTypeDef, `electron${number}-main`>]>, z.ZodType<`electron${number}.${number}-main`, z.ZodTypeDef, `electron${number}.${number}-main`>]>, z.ZodLiteral<"electron-renderer">]>, z.ZodType<`electron${number}-renderer`, z.ZodTypeDef, `electron${number}-renderer`>]>, z.ZodType<`electron${number}.${number}-renderer`, z.ZodTypeDef, `electron${number}.${number}-renderer`>]>, z.ZodLiteral<"electron-preload">]>, z.ZodType<`electron${number}-preload`, z.ZodTypeDef, `electron${number}-preload`>]>, z.ZodType<`electron${number}.${number}-preload`, z.ZodTypeDef, `electron${number}.${number}-preload`>]>]>, z.ZodArray<z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodEnum<["web", "webworker", "es3", "es5", "es2015", "es2016", "es2017", "es2018", "es2019", "es2020", "es2021", "es2022", "browserslist"]>, z.ZodLiteral<"node">]>, z.ZodLiteral<"async-node">]>, z.ZodType<`node${number}`, z.ZodTypeDef, `node${number}`>]>, z.ZodType<`async-node${number}`, z.ZodTypeDef, `async-node${number}`>]>, z.ZodType<`node${number}.${number}`, z.ZodTypeDef, `node${number}.${number}`>]>, z.ZodType<`async-node${number}.${number}`, z.ZodTypeDef, `async-node${number}.${number}`>]>, z.ZodLiteral<"electron-main">]>, z.ZodType<`electron${number}-main`, z.ZodTypeDef, `electron${number}-main`>]>, z.ZodType<`electron${number}.${number}-main`, z.ZodTypeDef, `electron${number}.${number}-main`>]>, z.ZodLiteral<"electron-renderer">]>, z.ZodType<`electron${number}-renderer`, z.ZodTypeDef, `electron${number}-renderer`>]>, z.ZodType<`electron${number}.${number}-renderer`, z.ZodTypeDef, `electron${number}.${number}-renderer`>]>, z.ZodLiteral<"electron-preload">]>, z.ZodType<`electron${number}-preload`, z.ZodTypeDef, `electron${number}-preload`>]>, z.ZodType<`electron${number}.${number}-preload`, z.ZodTypeDef, `electron${number}.${number}-preload`>]>, "many">]>>;
5218
5184
  mode: z.ZodOptional<z.ZodEnum<["development", "production", "none"]>>;
5219
5185
  experiments: z.ZodOptional<z.ZodObject<{
5220
- lazyCompilation: z.ZodUnion<[z.ZodOptional<z.ZodBoolean>, z.ZodObject<{
5221
- imports: z.ZodOptional<z.ZodBoolean>;
5222
- entries: z.ZodOptional<z.ZodBoolean>;
5223
- test: z.ZodOptional<z.ZodUnion<[z.ZodType<RegExp, z.ZodTypeDef, RegExp>, z.ZodFunction<z.ZodTuple<[z.ZodType<Module, z.ZodTypeDef, Module>], z.ZodUnknown>, z.ZodBoolean>]>>;
5224
- }, "strip", z.ZodTypeAny, {
5225
- imports?: boolean | undefined;
5226
- entries?: boolean | undefined;
5227
- test?: RegExp | ((args_0: Module, ...args_1: unknown[]) => boolean) | undefined;
5228
- }, {
5229
- imports?: boolean | undefined;
5230
- entries?: boolean | undefined;
5231
- test?: RegExp | ((args_0: Module, ...args_1: unknown[]) => boolean) | undefined;
5232
- }>]>;
5186
+ lazyCompilation: z.ZodOptional<z.ZodBoolean>;
5233
5187
  asyncWebAssembly: z.ZodOptional<z.ZodBoolean>;
5234
5188
  outputModule: z.ZodOptional<z.ZodBoolean>;
5235
5189
  topLevelAwait: z.ZodOptional<z.ZodBoolean>;
@@ -5261,11 +5215,7 @@ export declare const rspackOptions: z.ZodObject<{
5261
5215
  } | undefined;
5262
5216
  }>>;
5263
5217
  }, "strict", z.ZodTypeAny, {
5264
- lazyCompilation?: boolean | {
5265
- imports?: boolean | undefined;
5266
- entries?: boolean | undefined;
5267
- test?: RegExp | ((args_0: Module, ...args_1: unknown[]) => boolean) | undefined;
5268
- } | undefined;
5218
+ lazyCompilation?: boolean | undefined;
5269
5219
  asyncWebAssembly?: boolean | undefined;
5270
5220
  outputModule?: boolean | undefined;
5271
5221
  topLevelAwait?: boolean | undefined;
@@ -5279,11 +5229,7 @@ export declare const rspackOptions: z.ZodObject<{
5279
5229
  } | undefined;
5280
5230
  } | undefined;
5281
5231
  }, {
5282
- lazyCompilation?: boolean | {
5283
- imports?: boolean | undefined;
5284
- entries?: boolean | undefined;
5285
- test?: RegExp | ((args_0: Module, ...args_1: unknown[]) => boolean) | undefined;
5286
- } | undefined;
5232
+ lazyCompilation?: boolean | undefined;
5287
5233
  asyncWebAssembly?: boolean | undefined;
5288
5234
  outputModule?: boolean | undefined;
5289
5235
  topLevelAwait?: boolean | undefined;
@@ -6715,11 +6661,7 @@ export declare const rspackOptions: z.ZodObject<{
6715
6661
  target?: false | "es3" | "es5" | "es2015" | "es2016" | "es2017" | "es2018" | "es2019" | "es2020" | "es2021" | "es2022" | "node" | "async-node" | "web" | "webworker" | "browserslist" | `node${number}` | `async-node${number}` | `node${number}.${number}` | `async-node${number}.${number}` | "electron-main" | `electron${number}-main` | `electron${number}.${number}-main` | "electron-renderer" | `electron${number}-renderer` | `electron${number}.${number}-renderer` | "electron-preload" | `electron${number}-preload` | `electron${number}.${number}-preload` | ("es3" | "es5" | "es2015" | "es2016" | "es2017" | "es2018" | "es2019" | "es2020" | "es2021" | "es2022" | "node" | "async-node" | "web" | "webworker" | "browserslist" | `node${number}` | `async-node${number}` | `node${number}.${number}` | `async-node${number}.${number}` | "electron-main" | `electron${number}-main` | `electron${number}.${number}-main` | "electron-renderer" | `electron${number}-renderer` | `electron${number}.${number}-renderer` | "electron-preload" | `electron${number}-preload` | `electron${number}.${number}-preload`)[] | undefined;
6716
6662
  mode?: "none" | "development" | "production" | undefined;
6717
6663
  experiments?: {
6718
- lazyCompilation?: boolean | {
6719
- imports?: boolean | undefined;
6720
- entries?: boolean | undefined;
6721
- test?: RegExp | ((args_0: Module, ...args_1: unknown[]) => boolean) | undefined;
6722
- } | undefined;
6664
+ lazyCompilation?: boolean | undefined;
6723
6665
  asyncWebAssembly?: boolean | undefined;
6724
6666
  outputModule?: boolean | undefined;
6725
6667
  topLevelAwait?: boolean | undefined;
@@ -7143,11 +7085,7 @@ export declare const rspackOptions: z.ZodObject<{
7143
7085
  target?: false | "es3" | "es5" | "es2015" | "es2016" | "es2017" | "es2018" | "es2019" | "es2020" | "es2021" | "es2022" | "node" | "async-node" | "web" | "webworker" | "browserslist" | `node${number}` | `async-node${number}` | `node${number}.${number}` | `async-node${number}.${number}` | "electron-main" | `electron${number}-main` | `electron${number}.${number}-main` | "electron-renderer" | `electron${number}-renderer` | `electron${number}.${number}-renderer` | "electron-preload" | `electron${number}-preload` | `electron${number}.${number}-preload` | ("es3" | "es5" | "es2015" | "es2016" | "es2017" | "es2018" | "es2019" | "es2020" | "es2021" | "es2022" | "node" | "async-node" | "web" | "webworker" | "browserslist" | `node${number}` | `async-node${number}` | `node${number}.${number}` | `async-node${number}.${number}` | "electron-main" | `electron${number}-main` | `electron${number}.${number}-main` | "electron-renderer" | `electron${number}-renderer` | `electron${number}.${number}-renderer` | "electron-preload" | `electron${number}-preload` | `electron${number}.${number}-preload`)[] | undefined;
7144
7086
  mode?: "none" | "development" | "production" | undefined;
7145
7087
  experiments?: {
7146
- lazyCompilation?: boolean | {
7147
- imports?: boolean | undefined;
7148
- entries?: boolean | undefined;
7149
- test?: RegExp | ((args_0: Module, ...args_1: unknown[]) => boolean) | undefined;
7150
- } | undefined;
7088
+ lazyCompilation?: boolean | undefined;
7151
7089
  asyncWebAssembly?: boolean | undefined;
7152
7090
  outputModule?: boolean | undefined;
7153
7091
  topLevelAwait?: boolean | undefined;
@@ -749,16 +749,8 @@ const rspackFutureOptions = zod_1.z.strictObject({
749
749
  })
750
750
  .optional()
751
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
- });
760
752
  const experiments = zod_1.z.strictObject({
761
- lazyCompilation: zod_1.z.boolean().optional().or(lazyCompilationOptions),
753
+ lazyCompilation: zod_1.z.boolean().optional(),
762
754
  asyncWebAssembly: zod_1.z.boolean().optional(),
763
755
  outputModule: zod_1.z.boolean().optional(),
764
756
  topLevelAwait: zod_1.z.boolean().optional(),
@@ -14,7 +14,6 @@ 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");
18
17
  const graceful_fs_1 = __importDefault(require("../compiled/graceful-fs"));
19
18
  const builtin_plugin_1 = require("./builtin-plugin");
20
19
  const EntryOptionPlugin_1 = __importDefault(require("./lib/EntryOptionPlugin"));
@@ -26,7 +25,7 @@ const cleverMerge_1 = require("./util/cleverMerge");
26
25
  class RspackOptionsApply {
27
26
  constructor() { }
28
27
  process(options, compiler) {
29
- var _a, _b, _c, _d;
28
+ var _a;
30
29
  (0, assert_1.default)(options.output.path, "options.output.path should have value after `applyRspackOptionsDefaults`");
31
30
  compiler.outputPath = options.output.path;
32
31
  compiler.name = options.name;
@@ -164,24 +163,6 @@ class RspackOptionsApply {
164
163
  new builtin_plugin_1.MangleExportsPlugin(options.optimization.mangleExports !== "size").apply(compiler);
165
164
  }
166
165
  }
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
- }
185
166
  if (options.output.enabledLibraryTypes &&
186
167
  options.output.enabledLibraryTypes.length > 0) {
187
168
  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-5042eed-20240515115707",
3
+ "version": "0.6.5-canary-dc02c55-20240516004313",
4
4
  "webpackVersion": "5.75.0",
5
5
  "license": "MIT",
6
6
  "description": "A Fast Rust-based Web Bundler",
@@ -61,7 +61,7 @@
61
61
  "pug-loader": "^2.4.0",
62
62
  "react-relay": "^16.0.0",
63
63
  "sass": "1.56.2",
64
- "sass-loader": "13.2.0",
64
+ "sass-loader": "14.2.1",
65
65
  "source-map": "^0.7.4",
66
66
  "source-map-loader": "^5.0.0",
67
67
  "styled-components": "^6.0.8",
@@ -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-5042eed-20240515115707",
75
- "@rspack/core": "0.6.5-canary-5042eed-20240515115707"
74
+ "@rspack/core": "0.6.5-canary-dc02c55-20240516004313",
75
+ "@rspack/plugin-minify": "^0.6.5-canary-dc02c55-20240516004313"
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-5042eed-20240515115707"
83
+ "@rspack/binding": "0.6.5-canary-dc02c55-20240516004313"
84
84
  },
85
85
  "peerDependencies": {
86
86
  "@swc/helpers": ">=0.5.1"
@@ -1,50 +0,0 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
- /// <reference types="node" />
4
- /// <reference types="node" />
5
- import type { IncomingMessage, ServerResponse, ServerOptions as ServerOptionsImport } from "http";
6
- import type { ListenOptions, Server } from "net";
7
- import type { Compiler } from "../..";
8
- import type { SecureContextOptions, TlsOptions } from "tls";
9
- export interface LazyCompilationDefaultBackendOptions {
10
- /**
11
- * A custom client.
12
- */
13
- client?: string;
14
- /**
15
- * Specifies where to listen to from the server.
16
- */
17
- listen?: number | ListenOptions | ((server: Server) => void);
18
- /**
19
- * Specifies the protocol the client should use to connect to the server.
20
- */
21
- protocol?: "http" | "https";
22
- /**
23
- * Specifies how to create the server handling the EventSource requests.
24
- */
25
- server?: ServerOptionsImport<typeof IncomingMessage> | ServerOptionsHttps<typeof IncomingMessage, typeof ServerResponse> | (() => Server);
26
- }
27
- export type ServerOptionsHttps<Request extends typeof IncomingMessage = typeof IncomingMessage, Response extends typeof ServerResponse = typeof ServerResponse> = SecureContextOptions & TlsOptions & ServerOptionsImport<Request, Response>;
28
- declare const getBackend: (options: Omit<LazyCompilationDefaultBackendOptions, "client"> & {
29
- client: NonNullable<LazyCompilationDefaultBackendOptions["client"]>;
30
- }) => (compiler: Compiler, callback: (err: any, obj?: {
31
- dispose: (callback: (err: any) => void) => void;
32
- module: (args: {
33
- module: string;
34
- path: string;
35
- }) => {
36
- data: string;
37
- client: string;
38
- active: boolean;
39
- };
40
- } | undefined) => void) => void;
41
- export default getBackend;
42
- export declare function dispose(callback: any): void;
43
- export declare function moduleImpl(args: {
44
- module: string;
45
- path: string;
46
- }): {
47
- active: boolean;
48
- data: string;
49
- client: string;
50
- };
@@ -1,139 +0,0 @@
1
- /*
2
- MIT License http://www.opensource.org/licenses/mit-license.php
3
- Author Tobias Koppers @sokra
4
- */
5
- "use strict";
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.moduleImpl = exports.dispose = void 0;
8
- const getBackend = (options) => (compiler, callback) => {
9
- const logger = compiler.getInfrastructureLogger("LazyCompilationBackend");
10
- const activeModules = new Map();
11
- const filesByKey = new Map();
12
- const prefix = "/lazy-compilation-using-";
13
- const isHttps = options.protocol === "https" ||
14
- (typeof options.server === "object" &&
15
- ("key" in options.server || "pfx" in options.server));
16
- const createServer = typeof options.server === "function"
17
- ? options.server
18
- : (() => {
19
- const http = isHttps ? require("https") : require("http");
20
- return http.createServer.bind(http, options.server);
21
- })();
22
- const listen = typeof options.listen === "function"
23
- ? options.listen
24
- : (server) => {
25
- let listen = options.listen;
26
- if (typeof listen === "object" && !("port" in listen))
27
- listen = { ...listen, port: undefined };
28
- server.listen(listen);
29
- };
30
- const protocol = options.protocol || (isHttps ? "https" : "http");
31
- const requestListener = (req, res) => {
32
- const keys = req.url.slice(prefix.length).split("@");
33
- req.socket.on("close", () => {
34
- setTimeout(() => {
35
- for (const key of keys) {
36
- const oldValue = activeModules.get(key) || 0;
37
- activeModules.set(key, oldValue - 1);
38
- if (oldValue === 1) {
39
- logger.log(`${key} is no longer in use. Next compilation will skip this module.`);
40
- }
41
- }
42
- }, 120000);
43
- });
44
- req.socket.setNoDelay(true);
45
- res.writeHead(200, {
46
- "content-type": "text/event-stream",
47
- "Access-Control-Allow-Origin": "*",
48
- "Access-Control-Allow-Methods": "*",
49
- "Access-Control-Allow-Headers": "*"
50
- });
51
- res.write("\n");
52
- const moduleActivated = [];
53
- for (const key of keys) {
54
- const oldValue = activeModules.get(key) || 0;
55
- activeModules.set(key, oldValue + 1);
56
- if (oldValue === 0) {
57
- logger.log(`${key} is now in use and will be compiled.`);
58
- moduleActivated.push(key);
59
- }
60
- }
61
- if (moduleActivated.length && compiler.watching) {
62
- compiler.watching.lazyCompilationInvalidate(new Set(moduleActivated.map(key => filesByKey.get(key))));
63
- }
64
- };
65
- const server = createServer();
66
- server.on("request", requestListener);
67
- let isClosing = false;
68
- const sockets = new Set();
69
- server.on("connection", socket => {
70
- sockets.add(socket);
71
- socket.on("close", () => {
72
- sockets.delete(socket);
73
- });
74
- if (isClosing)
75
- socket.destroy();
76
- });
77
- server.on("clientError", e => {
78
- if (e.message !== "Server is disposing")
79
- logger.warn(e);
80
- });
81
- server.on("listening", (err) => {
82
- if (err)
83
- return callback(err);
84
- const addr = server.address();
85
- if (typeof addr === "string")
86
- throw new Error("addr must not be a string");
87
- const urlBase = addr.address === "::" || addr.address === "0.0.0.0"
88
- ? `${protocol}://localhost:${addr.port}`
89
- : addr.family === "IPv6"
90
- ? `${protocol}://[${addr.address}]:${addr.port}`
91
- : `${protocol}://${addr.address}:${addr.port}`;
92
- logger.log(`Server-Sent-Events server for lazy compilation open at ${urlBase}.`);
93
- const result = {
94
- dispose(callback) {
95
- isClosing = true;
96
- // Removing the listener is a workaround for a memory leak in node.js
97
- server.off("request", requestListener);
98
- server.close(err => {
99
- callback(err);
100
- });
101
- for (const socket of sockets) {
102
- socket.destroy(new Error("Server is disposing"));
103
- }
104
- },
105
- module({ module: originalModule, path }) {
106
- const key = `${encodeURIComponent(originalModule.replace(/\\/g, "/").replace(/@/g, "_")).replace(/%(2F|3A|24|26|2B|2C|3B|3D|3A)/g, decodeURIComponent)}`;
107
- filesByKey.set(key, path);
108
- const active = activeModules.get(key) > 0;
109
- return {
110
- client: `${options.client}?${encodeURIComponent(urlBase + prefix)}`,
111
- data: key,
112
- active
113
- };
114
- }
115
- };
116
- state.module = result.module;
117
- state.dispose = result.dispose;
118
- callback(null, result);
119
- });
120
- listen(server);
121
- };
122
- exports.default = getBackend;
123
- function unimplemented() {
124
- throw new Error("access before initialization");
125
- }
126
- const state = {
127
- module: unimplemented,
128
- dispose: unimplemented
129
- };
130
- function dispose(callback) {
131
- state.dispose(callback);
132
- state.dispose = unimplemented;
133
- state.module = unimplemented;
134
- }
135
- exports.dispose = dispose;
136
- function moduleImpl(args) {
137
- return state.module(args);
138
- }
139
- exports.moduleImpl = moduleImpl;
@@ -1,30 +0,0 @@
1
- import { BuiltinPluginName, JsModule, RawRegexMatcher } from "@rspack/binding";
2
- export declare const BuiltinLazyCompilationPlugin: {
3
- new (module: (args: {
4
- module: string;
5
- path: string;
6
- }) => {
7
- active: boolean;
8
- data: string;
9
- client: string;
10
- }, cacheable: boolean, entries: boolean, imports: boolean, test?: RawRegexMatcher | ((m: JsModule) => boolean) | undefined): {
11
- name: BuiltinPluginName;
12
- _options: {
13
- module: (args: {
14
- module: string;
15
- path: string;
16
- }) => {
17
- active: boolean;
18
- data: string;
19
- client: string;
20
- };
21
- cacheable: boolean;
22
- imports: boolean;
23
- entries: boolean;
24
- test: RawRegexMatcher | ((m: JsModule) => boolean) | undefined;
25
- };
26
- affectedHooks: "done" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | undefined;
27
- raw(): import("@rspack/binding").BuiltinPlugin;
28
- apply(compiler: import("../../Compiler").Compiler): void;
29
- };
30
- };
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BuiltinLazyCompilationPlugin = void 0;
4
- const binding_1 = require("@rspack/binding");
5
- const base_1 = require("../base");
6
- exports.BuiltinLazyCompilationPlugin = (0, base_1.create)(binding_1.BuiltinPluginName.LazyCompilationPlugin, (module, cacheable, entries, imports, test) => ({ module, cacheable, imports, entries, test }), "thisCompilation");
@@ -1,13 +0,0 @@
1
- import type { Compiler } from "../..";
2
- import { LazyCompilationDefaultBackendOptions } from "./backend";
3
- import { JsModule, RawRegexMatcher } from "@rspack/binding";
4
- export default class LazyCompilationPlugin {
5
- cacheable: boolean;
6
- entries: boolean;
7
- imports: boolean;
8
- test?: RawRegexMatcher | ((m: JsModule) => boolean);
9
- backend?: LazyCompilationDefaultBackendOptions;
10
- constructor(cacheable: boolean, entries: boolean, imports: boolean, test?: RawRegexMatcher | ((m: JsModule) => boolean), backend?: LazyCompilationDefaultBackendOptions);
11
- apply(compiler: Compiler): void;
12
- }
13
- export { LazyCompilationPlugin };
@@ -1,60 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.LazyCompilationPlugin = void 0;
27
- const lazyCompilation_1 = require("./lazyCompilation");
28
- const backend_1 = __importStar(require("./backend"));
29
- class LazyCompilationPlugin {
30
- constructor(cacheable, entries, imports, test, backend) {
31
- this.cacheable = cacheable;
32
- this.entries = entries;
33
- this.imports = imports;
34
- this.test = test;
35
- this.backend = backend;
36
- }
37
- apply(compiler) {
38
- const backend = (0, backend_1.default)({
39
- ...this.backend,
40
- client: require.resolve(`../../../hot/lazy-compilation-${compiler.options.externalsPresets.node ? "node" : "web"}.js`)
41
- });
42
- new lazyCompilation_1.BuiltinLazyCompilationPlugin(backend_1.moduleImpl, this.cacheable, this.entries, this.imports, this.test).apply(compiler);
43
- let initialized = false;
44
- compiler.hooks.beforeCompile.tapAsync("LazyCompilationPlugin", (_params, callback) => {
45
- if (initialized)
46
- return callback();
47
- backend(compiler, (err, result) => {
48
- if (err)
49
- return callback(err);
50
- initialized = true;
51
- callback();
52
- });
53
- });
54
- compiler.hooks.shutdown.tapAsync("LazyCompilationPlugin", callback => {
55
- (0, backend_1.dispose)(callback);
56
- });
57
- }
58
- }
59
- exports.default = LazyCompilationPlugin;
60
- exports.LazyCompilationPlugin = LazyCompilationPlugin;