@rspack/core 1.0.0-beta.3 → 1.0.0-beta.5

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 (41) hide show
  1. package/dist/Compilation.d.ts +1 -7
  2. package/dist/Compilation.js +5 -13
  3. package/dist/DependenciesBlock.d.ts +8 -0
  4. package/dist/DependenciesBlock.js +30 -0
  5. package/dist/Dependency.d.ts +8 -0
  6. package/dist/Dependency.js +32 -0
  7. package/dist/Module.d.ts +6 -3
  8. package/dist/Module.js +13 -0
  9. package/dist/NormalModule.d.ts +2 -1
  10. package/dist/NormalModule.js +1 -1
  11. package/dist/builtin-plugin/ExternalsPlugin.d.ts +4 -4
  12. package/dist/builtin-plugin/HtmlRspackPlugin.d.ts +41 -10
  13. package/dist/builtin-plugin/HtmlRspackPlugin.js +16 -4
  14. package/dist/builtin-plugin/LightningCssMiminizerRspackPlugin.d.ts +2 -2
  15. package/dist/builtin-plugin/LightningCssMiminizerRspackPlugin.js +1 -7
  16. package/dist/builtin-plugin/css-extract/hmr/hotModuleReplacement.js +18 -11
  17. package/dist/builtin-plugin/css-extract/loader.d.ts +1 -1
  18. package/dist/builtin-plugin/css-extract/loader.js +2 -10
  19. package/dist/builtin-plugin/index.d.ts +0 -1
  20. package/dist/builtin-plugin/index.js +0 -1
  21. package/dist/config/adapterRuleUse.d.ts +1 -0
  22. package/dist/config/adapterRuleUse.js +2 -6
  23. package/dist/config/defaults.js +22 -13
  24. package/dist/config/zod.d.ts +199 -79
  25. package/dist/config/zod.js +10 -5
  26. package/dist/container/ContainerReferencePlugin.d.ts +1 -1
  27. package/dist/exports.d.ts +0 -1
  28. package/dist/exports.js +7 -10
  29. package/dist/loader-runner/index.js +3 -3
  30. package/dist/node/NodeWatchFileSystem.d.ts +3 -3
  31. package/dist/node/NodeWatchFileSystem.js +6 -6
  32. package/dist/stats/DefaultStatsFactoryPlugin.d.ts +0 -10
  33. package/dist/stats/DefaultStatsFactoryPlugin.js +130 -90
  34. package/dist/stats/DefaultStatsPresetPlugin.js +16 -15
  35. package/dist/stats/StatsFactory.js +5 -6
  36. package/dist/stats/statsFactoryUtils.d.ts +14 -1
  37. package/dist/stats/statsFactoryUtils.js +62 -1
  38. package/dist/util/fs.d.ts +245 -22
  39. package/package.json +3 -3
  40. package/dist/builtin-plugin/SwcCssMinimizerPlugin.d.ts +0 -16
  41. package/dist/builtin-plugin/SwcCssMinimizerPlugin.js +0 -12
@@ -8,7 +8,7 @@
8
8
  * https://github.com/webpack/webpack/blob/main/LICENSE
9
9
  */
10
10
  import type * as binding from "@rspack/binding";
11
- import { type ExternalObject, type JsCompilation, type JsModule, type JsPathData, type JsRuntimeModule } from "@rspack/binding";
11
+ import { type ExternalObject, type JsCompilation, type JsPathData, type JsRuntimeModule } from "@rspack/binding";
12
12
  import * as liteTapable from "@rspack/lite-tapable";
13
13
  import type { Source } from "../compiled/webpack-sources";
14
14
  import { Chunk } from "./Chunk";
@@ -338,12 +338,6 @@ export declare class Compilation {
338
338
  * @internal
339
339
  */
340
340
  __internal__hasAsset(name: string): boolean;
341
- /**
342
- * Note: This is not a webpack public API, maybe removed in future.
343
- *
344
- * @internal
345
- */
346
- __internal__getModules(): JsModule[];
347
341
  /**
348
342
  * Note: This is not a webpack public API, maybe removed in future.
349
343
  *
@@ -72,10 +72,10 @@ class Compilation {
72
72
  * These fields are generally used within a plugin, so they do not need to be passed back to the Rust side.
73
73
  */
74
74
  _Compilation_customModules.set(this, void 0);
75
- this.fileDependencies = (0, fake_1.createFakeCompilationDependencies)(() => __classPrivateFieldGet(this, _Compilation_inner, "f").getFileDependencies(), d => __classPrivateFieldGet(this, _Compilation_inner, "f").addFileDependencies(d));
76
- this.contextDependencies = (0, fake_1.createFakeCompilationDependencies)(() => __classPrivateFieldGet(this, _Compilation_inner, "f").getContextDependencies(), d => __classPrivateFieldGet(this, _Compilation_inner, "f").addContextDependencies(d));
77
- this.missingDependencies = (0, fake_1.createFakeCompilationDependencies)(() => __classPrivateFieldGet(this, _Compilation_inner, "f").getMissingDependencies(), d => __classPrivateFieldGet(this, _Compilation_inner, "f").addMissingDependencies(d));
78
- this.buildDependencies = (0, fake_1.createFakeCompilationDependencies)(() => __classPrivateFieldGet(this, _Compilation_inner, "f").getBuildDependencies(), d => __classPrivateFieldGet(this, _Compilation_inner, "f").addBuildDependencies(d));
75
+ this.fileDependencies = (0, fake_1.createFakeCompilationDependencies)(() => __classPrivateFieldGet(this, _Compilation_inner, "f").dependencies().fileDependencies, d => __classPrivateFieldGet(this, _Compilation_inner, "f").addFileDependencies(d));
76
+ this.contextDependencies = (0, fake_1.createFakeCompilationDependencies)(() => __classPrivateFieldGet(this, _Compilation_inner, "f").dependencies().contextDependencies, d => __classPrivateFieldGet(this, _Compilation_inner, "f").addContextDependencies(d));
77
+ this.missingDependencies = (0, fake_1.createFakeCompilationDependencies)(() => __classPrivateFieldGet(this, _Compilation_inner, "f").dependencies().missingDependencies, d => __classPrivateFieldGet(this, _Compilation_inner, "f").addMissingDependencies(d));
78
+ this.buildDependencies = (0, fake_1.createFakeCompilationDependencies)(() => __classPrivateFieldGet(this, _Compilation_inner, "f").dependencies().buildDependencies, d => __classPrivateFieldGet(this, _Compilation_inner, "f").addBuildDependencies(d));
79
79
  _Compilation_rebuildModuleCaller.set(this, ((compilation) => new MergeCaller_1.default((args) => {
80
80
  __classPrivateFieldGet(compilation, _Compilation_inner, "f").rebuildModule(args.map(item => item[0]), (err, modules) => {
81
81
  for (const [id, callback] of args) {
@@ -216,7 +216,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
216
216
  };
217
217
  }
218
218
  get modules() {
219
- return (0, memoize_1.memoizeValue)(() => new Set(this.__internal__getModules().map(item => Module_1.Module.__from_binding(item, this))));
219
+ return new Set(__classPrivateFieldGet(this, _Compilation_inner, "f").modules.map(module => Module_1.Module.__from_binding(module, this)));
220
220
  }
221
221
  get chunks() {
222
222
  return (0, memoize_1.memoizeValue)(() => new Set(this.__internal__getChunks()));
@@ -679,14 +679,6 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
679
679
  __internal__hasAsset(name) {
680
680
  return __classPrivateFieldGet(this, _Compilation_inner, "f").hasAsset(name);
681
681
  }
682
- /**
683
- * Note: This is not a webpack public API, maybe removed in future.
684
- *
685
- * @internal
686
- */
687
- __internal__getModules() {
688
- return __classPrivateFieldGet(this, _Compilation_inner, "f").getModules();
689
- }
690
682
  /**
691
683
  * Note: This is not a webpack public API, maybe removed in future.
692
684
  *
@@ -0,0 +1,8 @@
1
+ import type { DependenciesBlockDTO } from "@rspack/binding";
2
+ import { Dependency } from "./Dependency";
3
+ export declare class DependenciesBlock {
4
+ #private;
5
+ constructor(binding: DependenciesBlockDTO);
6
+ get dependencies(): Dependency[];
7
+ get blocks(): DependenciesBlock[];
8
+ }
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
3
+ if (kind === "m") throw new TypeError("Private method is not writable");
4
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
5
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
6
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
7
+ };
8
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
9
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
10
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
11
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
+ };
13
+ var _DependenciesBlock_binding;
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.DependenciesBlock = void 0;
16
+ const Dependency_1 = require("./Dependency");
17
+ class DependenciesBlock {
18
+ constructor(binding) {
19
+ _DependenciesBlock_binding.set(this, void 0);
20
+ __classPrivateFieldSet(this, _DependenciesBlock_binding, binding, "f");
21
+ }
22
+ get dependencies() {
23
+ return __classPrivateFieldGet(this, _DependenciesBlock_binding, "f").dependencies.map(d => new Dependency_1.Dependency(d));
24
+ }
25
+ get blocks() {
26
+ return __classPrivateFieldGet(this, _DependenciesBlock_binding, "f").blocks.map(b => new DependenciesBlock(b));
27
+ }
28
+ }
29
+ exports.DependenciesBlock = DependenciesBlock;
30
+ _DependenciesBlock_binding = new WeakMap();
@@ -0,0 +1,8 @@
1
+ import type { DependencyDTO } from "@rspack/binding";
2
+ export declare class Dependency {
3
+ #private;
4
+ constructor(binding: DependencyDTO);
5
+ get type(): string;
6
+ get category(): string;
7
+ get request(): string | undefined;
8
+ }
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
3
+ if (kind === "m") throw new TypeError("Private method is not writable");
4
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
5
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
6
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
7
+ };
8
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
9
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
10
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
11
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
+ };
13
+ var _Dependency_binding;
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.Dependency = void 0;
16
+ class Dependency {
17
+ constructor(binding) {
18
+ _Dependency_binding.set(this, void 0);
19
+ __classPrivateFieldSet(this, _Dependency_binding, binding, "f");
20
+ }
21
+ get type() {
22
+ return __classPrivateFieldGet(this, _Dependency_binding, "f").type;
23
+ }
24
+ get category() {
25
+ return __classPrivateFieldGet(this, _Dependency_binding, "f").category;
26
+ }
27
+ get request() {
28
+ return __classPrivateFieldGet(this, _Dependency_binding, "f").request;
29
+ }
30
+ }
31
+ exports.Dependency = Dependency;
32
+ _Dependency_binding = new WeakMap();
package/dist/Module.d.ts CHANGED
@@ -1,6 +1,7 @@
1
- import type { JsCodegenerationResult, JsCreateData, JsFactoryMeta, JsModule } from "@rspack/binding";
1
+ import type { JsCodegenerationResult, JsCreateData, JsFactoryMeta, JsModule, ModuleDTO } from "@rspack/binding";
2
2
  import type { Source } from "../compiled/webpack-sources";
3
3
  import type { Compilation } from "./Compilation";
4
+ import { DependenciesBlock } from "./DependenciesBlock";
4
5
  export type ResourceData = {
5
6
  resource: string;
6
7
  path: string;
@@ -56,11 +57,13 @@ export declare class Module {
56
57
  * @see {@link Compilation#customModules}
57
58
  */
58
59
  buildMeta: Record<string, any>;
59
- static __from_binding(module: JsModule, compilation?: Compilation): Module;
60
- constructor(module: JsModule, compilation?: Compilation);
60
+ static __from_binding(module: JsModule | ModuleDTO, compilation?: Compilation): Module;
61
+ constructor(module: JsModule | ModuleDTO, compilation?: Compilation);
61
62
  originalSource(): Source | null;
62
63
  identifier(): string;
63
64
  nameForCondition(): string | null;
65
+ get blocks(): DependenciesBlock[];
66
+ size(type?: string): number;
64
67
  }
65
68
  export declare class CodeGenerationResult {
66
69
  #private;
package/dist/Module.js CHANGED
@@ -13,6 +13,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
13
13
  var _Module_inner, _Module_originalSource, _CodeGenerationResult_inner;
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.CodeGenerationResults = exports.CodeGenerationResult = exports.Module = void 0;
16
+ const DependenciesBlock_1 = require("./DependenciesBlock");
16
17
  const source_1 = require("./util/source");
17
18
  class Module {
18
19
  static __from_binding(module, compilation) {
@@ -52,6 +53,18 @@ class Module {
52
53
  }
53
54
  return null;
54
55
  }
56
+ get blocks() {
57
+ if ("blocks" in __classPrivateFieldGet(this, _Module_inner, "f")) {
58
+ return __classPrivateFieldGet(this, _Module_inner, "f").blocks.map(b => new DependenciesBlock_1.DependenciesBlock(b));
59
+ }
60
+ return [];
61
+ }
62
+ size(type) {
63
+ if ("size" in __classPrivateFieldGet(this, _Module_inner, "f")) {
64
+ return __classPrivateFieldGet(this, _Module_inner, "f").size(type);
65
+ }
66
+ return 0;
67
+ }
55
68
  }
56
69
  exports.Module = Module;
57
70
  _Module_inner = new WeakMap(), _Module_originalSource = new WeakMap();
@@ -1,10 +1,11 @@
1
1
  /// <reference types="node" />
2
2
  import * as liteTapable from "@rspack/lite-tapable";
3
3
  import { Compilation } from "./Compilation";
4
+ import type { Module } from "./Module";
4
5
  import type { LoaderContext } from "./config";
5
6
  export declare class NormalModule {
6
7
  static getCompilationHooks(compilation: Compilation): {
7
- loader: liteTapable.SyncHook<[LoaderContext<{}>], void, {
8
+ loader: liteTapable.SyncHook<[LoaderContext<{}>, Module], void, {
8
9
  _UnsetAdditionalOptions: true;
9
10
  }>;
10
11
  readResourceForScheme: any;
@@ -76,7 +76,7 @@ class NormalModule {
76
76
  let hooks = compilationHooksMap.get(compilation);
77
77
  if (hooks === undefined) {
78
78
  hooks = {
79
- loader: new liteTapable.SyncHook(["loaderContext"]),
79
+ loader: new liteTapable.SyncHook(["loaderContext", "module"]),
80
80
  // TODO webpack 6 deprecate
81
81
  readResourceForScheme: new liteTapable.HookMap(scheme => {
82
82
  const hook = hooks.readResource.for(scheme);
@@ -7,7 +7,7 @@ export declare const ExternalsPlugin: {
7
7
  contextInfo?: {
8
8
  issuer: string;
9
9
  } | undefined;
10
- }, args_1: (args_0: Error | undefined, args_1: string | boolean | string[] | Record<string, string | string[]> | undefined, args_2: "module" | "global" | "system" | "promise" | "commonjs" | "umd" | "amd" | "jsonp" | "import" | "commonjs2" | "var" | "assign" | "this" | "window" | "self" | "commonjs-module" | "commonjs-static" | "amd-require" | "umd2" | "script" | "node-commonjs" | undefined, ...args_3: unknown[]) => void, ...args_2: unknown[]) => unknown) | ((args_0: {
10
+ }, args_1: (args_0: Error | undefined, args_1: string | boolean | string[] | Record<string, string | string[]> | undefined, args_2: "module" | "global" | "system" | "promise" | "commonjs" | "umd" | "amd" | "jsonp" | "import" | "commonjs2" | "var" | "assign" | "this" | "window" | "self" | "commonjs-module" | "commonjs-static" | "amd-require" | "umd2" | "module-import" | "script" | "node-commonjs" | undefined, ...args_3: unknown[]) => void, ...args_2: unknown[]) => unknown) | ((args_0: {
11
11
  context?: string | undefined;
12
12
  dependencyType?: string | undefined;
13
13
  request?: string | undefined;
@@ -21,7 +21,7 @@ export declare const ExternalsPlugin: {
21
21
  contextInfo?: {
22
22
  issuer: string;
23
23
  } | undefined;
24
- }, args_1: (args_0: Error | undefined, args_1: string | boolean | string[] | Record<string, string | string[]> | undefined, args_2: "module" | "global" | "system" | "promise" | "commonjs" | "umd" | "amd" | "jsonp" | "import" | "commonjs2" | "var" | "assign" | "this" | "window" | "self" | "commonjs-module" | "commonjs-static" | "amd-require" | "umd2" | "script" | "node-commonjs" | undefined, ...args_3: unknown[]) => void, ...args_2: unknown[]) => unknown) | ((args_0: {
24
+ }, args_1: (args_0: Error | undefined, args_1: string | boolean | string[] | Record<string, string | string[]> | undefined, args_2: "module" | "global" | "system" | "promise" | "commonjs" | "umd" | "amd" | "jsonp" | "import" | "commonjs2" | "var" | "assign" | "this" | "window" | "self" | "commonjs-module" | "commonjs-static" | "amd-require" | "umd2" | "module-import" | "script" | "node-commonjs" | undefined, ...args_3: unknown[]) => void, ...args_2: unknown[]) => unknown) | ((args_0: {
25
25
  context?: string | undefined;
26
26
  dependencyType?: string | undefined;
27
27
  request?: string | undefined;
@@ -37,7 +37,7 @@ export declare const ExternalsPlugin: {
37
37
  contextInfo?: {
38
38
  issuer: string;
39
39
  } | undefined;
40
- }, args_1: (args_0: Error | undefined, args_1: string | boolean | string[] | Record<string, string | string[]> | undefined, args_2: "module" | "global" | "system" | "promise" | "commonjs" | "umd" | "amd" | "jsonp" | "import" | "commonjs2" | "var" | "assign" | "this" | "window" | "self" | "commonjs-module" | "commonjs-static" | "amd-require" | "umd2" | "script" | "node-commonjs" | undefined, ...args_3: unknown[]) => void, ...args_2: unknown[]) => unknown) | ((args_0: {
40
+ }, args_1: (args_0: Error | undefined, args_1: string | boolean | string[] | Record<string, string | string[]> | undefined, args_2: "module" | "global" | "system" | "promise" | "commonjs" | "umd" | "amd" | "jsonp" | "import" | "commonjs2" | "var" | "assign" | "this" | "window" | "self" | "commonjs-module" | "commonjs-static" | "amd-require" | "umd2" | "module-import" | "script" | "node-commonjs" | undefined, ...args_3: unknown[]) => void, ...args_2: unknown[]) => unknown) | ((args_0: {
41
41
  context?: string | undefined;
42
42
  dependencyType?: string | undefined;
43
43
  request?: string | undefined;
@@ -51,7 +51,7 @@ export declare const ExternalsPlugin: {
51
51
  contextInfo?: {
52
52
  issuer: string;
53
53
  } | undefined;
54
- }, args_1: (args_0: Error | undefined, args_1: string | boolean | string[] | Record<string, string | string[]> | undefined, args_2: "module" | "global" | "system" | "promise" | "commonjs" | "umd" | "amd" | "jsonp" | "import" | "commonjs2" | "var" | "assign" | "this" | "window" | "self" | "commonjs-module" | "commonjs-static" | "amd-require" | "umd2" | "script" | "node-commonjs" | undefined, ...args_3: unknown[]) => void, ...args_2: unknown[]) => unknown) | ((args_0: {
54
+ }, args_1: (args_0: Error | undefined, args_1: string | boolean | string[] | Record<string, string | string[]> | undefined, args_2: "module" | "global" | "system" | "promise" | "commonjs" | "umd" | "amd" | "jsonp" | "import" | "commonjs2" | "var" | "assign" | "this" | "window" | "self" | "commonjs-module" | "commonjs-static" | "amd-require" | "umd2" | "module-import" | "script" | "node-commonjs" | undefined, ...args_3: unknown[]) => void, ...args_2: unknown[]) => unknown) | ((args_0: {
55
55
  context?: string | undefined;
56
56
  dependencyType?: string | undefined;
57
57
  request?: string | undefined;
@@ -7,24 +7,40 @@ declare const htmlRspackPluginOptions: z.ZodObject<{
7
7
  templateParameters: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
8
8
  inject: z.ZodOptional<z.ZodUnion<[z.ZodEnum<["head", "body"]>, z.ZodBoolean]>>;
9
9
  publicPath: z.ZodOptional<z.ZodString>;
10
- scriptLoading: z.ZodOptional<z.ZodEnum<["blocking", "defer", "module"]>>;
10
+ base: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodObject<{
11
+ href: z.ZodOptional<z.ZodString>;
12
+ target: z.ZodOptional<z.ZodEnum<["_self", "_blank", "_parent", "_top"]>>;
13
+ }, "strict", z.ZodTypeAny, {
14
+ target?: "_self" | "_blank" | "_parent" | "_top" | undefined;
15
+ href?: string | undefined;
16
+ }, {
17
+ target?: "_self" | "_blank" | "_parent" | "_top" | undefined;
18
+ href?: string | undefined;
19
+ }>]>>;
20
+ scriptLoading: z.ZodOptional<z.ZodEnum<["blocking", "defer", "module", "systemjs-module"]>>;
11
21
  chunks: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
12
- excludedChunks: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
22
+ excludeChunks: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
13
23
  sri: z.ZodOptional<z.ZodEnum<["sha256", "sha384", "sha512"]>>;
14
24
  minify: z.ZodOptional<z.ZodBoolean>;
15
25
  title: z.ZodOptional<z.ZodString>;
16
26
  favicon: z.ZodOptional<z.ZodString>;
17
27
  meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>>>;
28
+ hash: z.ZodOptional<z.ZodBoolean>;
18
29
  }, "strict", z.ZodTypeAny, {
19
30
  filename?: string | undefined;
20
31
  publicPath?: string | undefined;
32
+ hash?: boolean | undefined;
21
33
  chunks?: string[] | undefined;
22
34
  template?: string | undefined;
23
35
  templateContent?: string | undefined;
24
36
  templateParameters?: Record<string, string> | undefined;
25
37
  inject?: boolean | "head" | "body" | undefined;
26
- scriptLoading?: "module" | "blocking" | "defer" | undefined;
27
- excludedChunks?: string[] | undefined;
38
+ base?: string | {
39
+ target?: "_self" | "_blank" | "_parent" | "_top" | undefined;
40
+ href?: string | undefined;
41
+ } | undefined;
42
+ scriptLoading?: "module" | "blocking" | "defer" | "systemjs-module" | undefined;
43
+ excludeChunks?: string[] | undefined;
28
44
  sri?: "sha256" | "sha384" | "sha512" | undefined;
29
45
  minify?: boolean | undefined;
30
46
  title?: string | undefined;
@@ -33,13 +49,18 @@ declare const htmlRspackPluginOptions: z.ZodObject<{
33
49
  }, {
34
50
  filename?: string | undefined;
35
51
  publicPath?: string | undefined;
52
+ hash?: boolean | undefined;
36
53
  chunks?: string[] | undefined;
37
54
  template?: string | undefined;
38
55
  templateContent?: string | undefined;
39
56
  templateParameters?: Record<string, string> | undefined;
40
57
  inject?: boolean | "head" | "body" | undefined;
41
- scriptLoading?: "module" | "blocking" | "defer" | undefined;
42
- excludedChunks?: string[] | undefined;
58
+ base?: string | {
59
+ target?: "_self" | "_blank" | "_parent" | "_top" | undefined;
60
+ href?: string | undefined;
61
+ } | undefined;
62
+ scriptLoading?: "module" | "blocking" | "defer" | "systemjs-module" | undefined;
63
+ excludeChunks?: string[] | undefined;
43
64
  sri?: "sha256" | "sha384" | "sha512" | undefined;
44
65
  minify?: boolean | undefined;
45
66
  title?: string | undefined;
@@ -51,13 +72,18 @@ export declare const HtmlRspackPlugin: {
51
72
  new (c?: {
52
73
  filename?: string | undefined;
53
74
  publicPath?: string | undefined;
75
+ hash?: boolean | undefined;
54
76
  chunks?: string[] | undefined;
55
77
  template?: string | undefined;
56
78
  templateContent?: string | undefined;
57
79
  templateParameters?: Record<string, string> | undefined;
58
80
  inject?: boolean | "head" | "body" | undefined;
59
- scriptLoading?: "module" | "blocking" | "defer" | undefined;
60
- excludedChunks?: string[] | undefined;
81
+ base?: string | {
82
+ target?: "_self" | "_blank" | "_parent" | "_top" | undefined;
83
+ href?: string | undefined;
84
+ } | undefined;
85
+ scriptLoading?: "module" | "blocking" | "defer" | "systemjs-module" | undefined;
86
+ excludeChunks?: string[] | undefined;
61
87
  sri?: "sha256" | "sha384" | "sha512" | undefined;
62
88
  minify?: boolean | undefined;
63
89
  title?: string | undefined;
@@ -68,13 +94,18 @@ export declare const HtmlRspackPlugin: {
68
94
  _args: [c?: {
69
95
  filename?: string | undefined;
70
96
  publicPath?: string | undefined;
97
+ hash?: boolean | undefined;
71
98
  chunks?: string[] | undefined;
72
99
  template?: string | undefined;
73
100
  templateContent?: string | undefined;
74
101
  templateParameters?: Record<string, string> | undefined;
75
102
  inject?: boolean | "head" | "body" | undefined;
76
- scriptLoading?: "module" | "blocking" | "defer" | undefined;
77
- excludedChunks?: string[] | undefined;
103
+ base?: string | {
104
+ target?: "_self" | "_blank" | "_parent" | "_top" | undefined;
105
+ href?: string | undefined;
106
+ } | undefined;
107
+ scriptLoading?: "module" | "blocking" | "defer" | "systemjs-module" | undefined;
108
+ excludeChunks?: string[] | undefined;
78
109
  sri?: "sha256" | "sha384" | "sha512" | undefined;
79
110
  minify?: boolean | undefined;
80
111
  title?: string | undefined;
@@ -12,14 +12,24 @@ const htmlRspackPluginOptions = zod_1.z.strictObject({
12
12
  templateParameters: zod_1.z.record(zod_1.z.string()).optional(),
13
13
  inject: zod_1.z.enum(["head", "body"]).or(zod_1.z.boolean()).optional(),
14
14
  publicPath: zod_1.z.string().optional(),
15
- scriptLoading: zod_1.z.enum(["blocking", "defer", "module"]).optional(),
15
+ base: zod_1.z
16
+ .string()
17
+ .or(zod_1.z.strictObject({
18
+ href: zod_1.z.string().optional(),
19
+ target: zod_1.z.enum(["_self", "_blank", "_parent", "_top"]).optional()
20
+ }))
21
+ .optional(),
22
+ scriptLoading: zod_1.z
23
+ .enum(["blocking", "defer", "module", "systemjs-module"])
24
+ .optional(),
16
25
  chunks: zod_1.z.string().array().optional(),
17
- excludedChunks: zod_1.z.string().array().optional(),
26
+ excludeChunks: zod_1.z.string().array().optional(),
18
27
  sri: zod_1.z.enum(["sha256", "sha384", "sha512"]).optional(),
19
28
  minify: zod_1.z.boolean().optional(),
20
29
  title: zod_1.z.string().optional(),
21
30
  favicon: zod_1.z.string().optional(),
22
- meta: zod_1.z.record(zod_1.z.string().or(zod_1.z.record(zod_1.z.string()))).optional()
31
+ meta: zod_1.z.record(zod_1.z.string().or(zod_1.z.record(zod_1.z.string()))).optional(),
32
+ hash: zod_1.z.boolean().optional()
23
33
  });
24
34
  exports.HtmlRspackPlugin = (0, base_1.create)(binding_1.BuiltinPluginName.HtmlRspackPlugin, (c = {}) => {
25
35
  (0, validate_1.validate)(c, htmlRspackPluginOptions);
@@ -48,10 +58,12 @@ exports.HtmlRspackPlugin = (0, base_1.create)(binding_1.BuiltinPluginName.HtmlRs
48
58
  : configInject === false
49
59
  ? "false"
50
60
  : configInject;
61
+ const base = typeof c.base === "string" ? { href: c.base } : c.base;
51
62
  return {
52
63
  ...c,
53
64
  meta,
54
65
  scriptLoading,
55
- inject
66
+ inject,
67
+ base
56
68
  };
57
69
  });
@@ -1,5 +1,5 @@
1
1
  import { BuiltinPluginName } from "@rspack/binding";
2
- import { type Drafts, type FeatureOptions, type NonStandard, type PseudoClasses, type Targets } from "../builtin-loader/lightningcss";
2
+ import { type Drafts, type FeatureOptions, type NonStandard, type PseudoClasses } from "../builtin-loader/lightningcss";
3
3
  import type { AssetConditions } from "../util/assetCondition";
4
4
  export type LightningCssMinimizerRspackPluginOptions = {
5
5
  test?: AssetConditions;
@@ -8,7 +8,7 @@ export type LightningCssMinimizerRspackPluginOptions = {
8
8
  removeUnusedLocalIdents?: boolean;
9
9
  minimizerOptions?: {
10
10
  errorRecovery?: boolean;
11
- targets?: Targets | string[] | string;
11
+ targets?: string[] | string;
12
12
  include?: FeatureOptions;
13
13
  exclude?: FeatureOptions;
14
14
  draft?: Drafts;
@@ -1,11 +1,7 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.LightningCssMinimizerRspackPlugin = void 0;
7
4
  const binding_1 = require("@rspack/binding");
8
- const browserslist_1 = __importDefault(require("../../compiled/browserslist"));
9
5
  const lightningcss_1 = require("../builtin-loader/lightningcss");
10
6
  const base_1 = require("./base");
11
7
  exports.LightningCssMinimizerRspackPlugin = (0, base_1.create)(binding_1.BuiltinPluginName.LightningCssMinimizerRspackPlugin, (options) => {
@@ -25,9 +21,7 @@ exports.LightningCssMinimizerRspackPlugin = (0, base_1.create)(binding_1.Builtin
25
21
  : // exclude all features, avoid downgrade css syntax when minimize
26
22
  // 1048575 = Features.Empty | Features.Nesting | ... | Features.LogicalProperties
27
23
  1048575,
28
- targets: typeof targets === "string" || Array.isArray(targets)
29
- ? (0, lightningcss_1.browserslistToTargets)((0, browserslist_1.default)(targets))
30
- : targets,
24
+ targets: typeof targets === "string" ? [targets] : targets,
31
25
  draft: draft ? { customMedia: draft.customMedia ?? false } : undefined,
32
26
  nonStandard: nonStandard
33
27
  ? {
@@ -36,12 +36,10 @@ function getCurrentScriptUrl(moduleId) {
36
36
  if (!src) {
37
37
  return null;
38
38
  }
39
- const splitResult = src.split(/([^\\/]+)\.js$/);
40
- const filename = splitResult?.[1];
41
- if (!filename) {
42
- return [src.replace(".js", ".css")];
43
- }
44
- if (!fileMap) {
39
+ const splitResult = src.match(/([^\\/]+)\.js$/);
40
+ // biome-ignore lint/complexity/useOptionalChain: not use optionalChain to support legacy browser
41
+ const filename = splitResult && splitResult[1];
42
+ if (!filename || !fileMap) {
45
43
  return [src.replace(".js", ".css")];
46
44
  }
47
45
  return fileMap.split(",").map(mapRule => {
@@ -80,21 +78,29 @@ function updateCss(el, url) {
80
78
  return;
81
79
  }
82
80
  newEl.isLoaded = true;
83
- el.parentNode?.removeChild(el);
81
+ if (el.parentNode) {
82
+ el.parentNode.removeChild(el);
83
+ }
84
84
  });
85
85
  newEl.addEventListener("error", () => {
86
86
  if (newEl.isLoaded) {
87
87
  return;
88
88
  }
89
89
  newEl.isLoaded = true;
90
- el.parentNode?.removeChild(el);
90
+ if (el.parentNode) {
91
+ el.parentNode.removeChild(el);
92
+ }
91
93
  });
92
94
  newEl.href = `${normalizedUrl}?${Date.now()}`;
95
+ const parent = el.parentNode;
96
+ if (!parent) {
97
+ return;
98
+ }
93
99
  if (el.nextSibling) {
94
- el.parentNode?.insertBefore(newEl, el.nextSibling);
100
+ parent.insertBefore(newEl, el.nextSibling);
95
101
  }
96
102
  else {
97
- el.parentNode?.appendChild(newEl);
103
+ parent.appendChild(newEl);
98
104
  }
99
105
  }
100
106
  function getReloadUrl(href, src) {
@@ -163,7 +169,8 @@ function cssReload(moduleId, options) {
163
169
  return;
164
170
  }
165
171
  if (reloaded) {
166
- console.log("[HMR] css reload %s", src?.join(" "));
172
+ // biome-ignore lint/complexity/useOptionalChain: not use optionalChain to support legacy browser
173
+ console.log("[HMR] css reload %s", src && src.join(" "));
167
174
  }
168
175
  else {
169
176
  console.log("[HMR] Reload all css");
@@ -8,7 +8,7 @@ export interface CssExtractRspackLoaderOptions {
8
8
  publicPath?: string | ((resourcePath: string, context: string) => string);
9
9
  emit?: boolean;
10
10
  esModule?: boolean;
11
- layer?: boolean;
11
+ layer?: string;
12
12
  defaultExport?: boolean;
13
13
  }
14
14
  export declare function hotLoader(content: string, context: {
@@ -190,22 +190,14 @@ const pitch = function (request, _, data) {
190
190
  if (dependencies.length > 0) {
191
191
  additionalData[index_1.CssExtractRspackPlugin.pluginName] = dependencies
192
192
  .map(dep => {
193
- return [
194
- dep.identifier,
195
- dep.content,
196
- dep.context,
197
- dep.media,
198
- dep.supports,
199
- dep.sourceMap,
200
- dep.identifierIndex,
201
- dep.filepath
202
- ].join(SERIALIZE_SEP);
193
+ return JSON.stringify(dep);
203
194
  })
204
195
  .join(SERIALIZE_SEP);
205
196
  }
206
197
  callback(null, resultSource, undefined, additionalData);
207
198
  };
208
199
  this.importModule(`${this.resourcePath}.webpack[javascript/auto]!=!!!${request}`, {
200
+ layer: options.layer,
209
201
  publicPath: /** @type {Filename} */ publicPathForExtract,
210
202
  baseUri: `${exports.BASE_URI}/`
211
203
  }, (error, exports) => {
@@ -56,7 +56,6 @@ export * from "./SideEffectsFlagPlugin";
56
56
  export * from "./SizeLimitsPlugin";
57
57
  export * from "./SourceMapDevToolPlugin";
58
58
  export * from "./SplitChunksPlugin";
59
- export * from "./SwcCssMinimizerPlugin";
60
59
  export * from "./LightningCssMiminizerRspackPlugin";
61
60
  export * from "./SwcJsMinimizerPlugin";
62
61
  export * from "./WarnCaseSensitiveModulesPlugin";
@@ -74,7 +74,6 @@ __exportStar(require("./SideEffectsFlagPlugin"), exports);
74
74
  __exportStar(require("./SizeLimitsPlugin"), exports);
75
75
  __exportStar(require("./SourceMapDevToolPlugin"), exports);
76
76
  __exportStar(require("./SplitChunksPlugin"), exports);
77
- __exportStar(require("./SwcCssMinimizerPlugin"), exports);
78
77
  __exportStar(require("./LightningCssMiminizerRspackPlugin"), exports);
79
78
  __exportStar(require("./SwcJsMinimizerPlugin"), exports);
80
79
  __exportStar(require("./WarnCaseSensitiveModulesPlugin"), exports);
@@ -87,6 +87,7 @@ export interface LoaderContext<OptionsType = {}> {
87
87
  getMissingDependencies(): string[];
88
88
  addBuildDependency(file: string): void;
89
89
  importModule(request: string, options: {
90
+ layer?: string;
90
91
  publicPath?: PublicPath;
91
92
  baseUri?: string;
92
93
  }, callback: (err?: Error, res?: any) => void): void;
@@ -5,7 +5,6 @@ const builtin_loader_1 = require("../builtin-loader");
5
5
  const lightningcss_1 = require("../builtin-loader/lightningcss");
6
6
  const loader_runner_1 = require("../loader-runner");
7
7
  const util_1 = require("../util");
8
- const browserslist = require("../../compiled/browserslist");
9
8
  exports.BUILTIN_LOADER_PREFIX = "builtin:";
10
9
  function createRawModuleRuleUses(uses, path, options) {
11
10
  const normalizeRuleSetUseItem = (item) => typeof item === "string" ? { loader: item } : item;
@@ -26,11 +25,8 @@ const getSwcLoaderOptions = (o, _) => {
26
25
  };
27
26
  const getLightningcssLoaderOptions = (o, _) => {
28
27
  if (o && typeof o === "object") {
29
- if (o.targets && typeof o.targets === "string") {
30
- o.targets = (0, lightningcss_1.browserslistToTargets)(browserslist(o.targets));
31
- }
32
- if (o.targets && Array.isArray(o.targets)) {
33
- o.targets = (0, lightningcss_1.browserslistToTargets)(browserslist(o.targets));
28
+ if (typeof o.targets === "string") {
29
+ o.targets = [o.targets];
34
30
  }
35
31
  if (o.include && typeof o.include === "object") {
36
32
  o.include = (0, lightningcss_1.toFeatures)(o.include);