@rspack/core 1.0.0-beta.1 → 1.0.0-beta.2

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 (88) hide show
  1. package/dist/ChunkGroup.d.ts +1 -0
  2. package/dist/ChunkGroup.js +3 -0
  3. package/dist/Compilation.d.ts +18 -0
  4. package/dist/Compiler.js +2 -2
  5. package/dist/ExecuteModulePlugin.d.ts +0 -1
  6. package/dist/ExecuteModulePlugin.js +0 -1
  7. package/dist/Module.d.ts +1 -2
  8. package/dist/Module.js +0 -1
  9. package/dist/MultiCompiler.js +1 -1
  10. package/dist/Resolver.d.ts +1 -2
  11. package/dist/RspackError.js +1 -1
  12. package/dist/Stats.js +22 -2
  13. package/dist/Template.js +2 -2
  14. package/dist/builtin-loader/lightningcss/index.js +1 -1
  15. package/dist/builtin-plugin/DefinePlugin.js +1 -1
  16. package/dist/builtin-plugin/EnableChunkLoadingPlugin.d.ts +2 -2
  17. package/dist/builtin-plugin/EnableChunkLoadingPlugin.js +1 -1
  18. package/dist/builtin-plugin/EnableLibraryPlugin.js +1 -6
  19. package/dist/builtin-plugin/EnableWasmLoadingPlugin.d.ts +2 -2
  20. package/dist/builtin-plugin/EnableWasmLoadingPlugin.js +1 -1
  21. package/dist/builtin-plugin/ExternalsPlugin.js +1 -1
  22. package/dist/builtin-plugin/JavascriptModulesPlugin.d.ts +0 -1
  23. package/dist/builtin-plugin/JavascriptModulesPlugin.js +1 -1
  24. package/dist/builtin-plugin/SwcJsMinimizerPlugin.d.ts +1 -2
  25. package/dist/builtin-plugin/css-extract/hmr/hotModuleReplacement.js +3 -5
  26. package/dist/builtin-plugin/css-extract/hmr/normalizeUrl.js +7 -5
  27. package/dist/builtin-plugin/css-extract/loader.js +4 -10
  28. package/dist/builtin-plugin/lazy-compilation/backend.js +4 -4
  29. package/dist/config/adapter.js +1 -0
  30. package/dist/config/adapterRuleUse.d.ts +2 -6
  31. package/dist/config/adapterRuleUse.js +7 -6
  32. package/dist/config/defaults.js +21 -32
  33. package/dist/config/normalization.d.ts +1 -0
  34. package/dist/config/normalization.js +5 -2
  35. package/dist/config/zod.d.ts +440 -68
  36. package/dist/config/zod.js +21 -1
  37. package/dist/container/default.runtime.js +1 -1
  38. package/dist/lib/AbstractMethodError.js +2 -3
  39. package/dist/lib/Cache.d.ts +1 -1
  40. package/dist/lib/Dependency.d.ts +23 -0
  41. package/dist/lib/Dependency.js +11 -0
  42. package/dist/lib/EnvironmentPlugin.js +1 -3
  43. package/dist/lib/ModuleFilenameHelpers.js +1 -1
  44. package/dist/lib/WebpackError.d.ts +0 -6
  45. package/dist/lib/WebpackError.js +0 -8
  46. package/dist/lib/cache/MemoryCachePlugin.d.ts +5 -0
  47. package/dist/lib/cache/MemoryCachePlugin.js +40 -0
  48. package/dist/lib/formatLocation.d.ts +1 -1
  49. package/dist/loader-runner/index.js +6 -7
  50. package/dist/loader-runner/loadLoader.js +8 -11
  51. package/dist/logging/Logger.js +3 -3
  52. package/dist/logging/createConsoleLogger.d.ts +26 -6
  53. package/dist/logging/createConsoleLogger.js +21 -58
  54. package/dist/logging/runtime.d.ts +4 -10
  55. package/dist/logging/runtime.js +8 -23
  56. package/dist/logging/truncateArgs.d.ts +4 -4
  57. package/dist/logging/truncateArgs.js +5 -10
  58. package/dist/node/NodeEnvironmentPlugin.js +2 -2
  59. package/dist/node/NodeWatchFileSystem.js +6 -6
  60. package/dist/node/nodeConsole.d.ts +7 -21
  61. package/dist/node/nodeConsole.js +29 -36
  62. package/dist/rspackOptionsApply.d.ts +0 -1
  63. package/dist/rspackOptionsApply.js +8 -7
  64. package/dist/sharing/ProvideSharedPlugin.d.ts +20 -19
  65. package/dist/sharing/ProvideSharedPlugin.js +26 -17
  66. package/dist/sharing/SharePlugin.d.ts +3 -0
  67. package/dist/sharing/SharePlugin.js +4 -1
  68. package/dist/stats/DefaultStatsFactoryPlugin.js +187 -96
  69. package/dist/stats/DefaultStatsPresetPlugin.js +1 -2
  70. package/dist/stats/DefaultStatsPrinterPlugin.js +18 -19
  71. package/dist/stats/StatsFactory.d.ts +2 -1
  72. package/dist/stats/StatsFactory.js +2 -6
  73. package/dist/stats/statsFactoryUtils.d.ts +63 -23
  74. package/dist/util/SizeFormatHelpers.js +1 -1
  75. package/dist/util/bindingVersionCheck.js +3 -3
  76. package/dist/util/cleverMerge.js +3 -2
  77. package/dist/util/comparators.d.ts +1 -1
  78. package/dist/util/comparators.js +5 -4
  79. package/dist/util/createHash.js +1 -1
  80. package/dist/util/fs.js +2 -2
  81. package/dist/util/identifier.js +2 -2
  82. package/dist/util/index.js +1 -1
  83. package/dist/util/memoize.js +1 -4
  84. package/dist/util/smartGrouping.js +4 -6
  85. package/dist/util/webpack.d.ts +1 -1
  86. package/dist/util/webpack.js +2 -1
  87. package/module.d.ts +1 -1
  88. package/package.json +3 -3
@@ -6,6 +6,7 @@ export declare class ChunkGroup {
6
6
  protected constructor(inner: JsChunkGroup, compilation: JsCompilation);
7
7
  getFiles(): ReadonlyArray<string>;
8
8
  getParents(): ReadonlyArray<ChunkGroup>;
9
+ isInitial(): boolean;
9
10
  get chunks(): ReadonlyArray<Chunk>;
10
11
  get index(): Readonly<number | undefined>;
11
12
  get name(): Readonly<string | undefined>;
@@ -40,6 +40,9 @@ class ChunkGroup {
40
40
  return ChunkGroup.__from_binding(cg, __classPrivateFieldGet(this, _ChunkGroup_innerCompilation, "f"));
41
41
  });
42
42
  }
43
+ isInitial() {
44
+ return __classPrivateFieldGet(this, _ChunkGroup_inner, "f").isInitial;
45
+ }
43
46
  get chunks() {
44
47
  return __classPrivateFieldGet(this, _ChunkGroup_inner, "f").chunks.map(c => Chunk_1.Chunk.__from_binding(c, __classPrivateFieldGet(this, _ChunkGroup_innerCompilation, "f")));
45
48
  }
@@ -102,6 +102,24 @@ export interface KnownNormalizedStatsOptions {
102
102
  logging: false | "none" | "error" | "warn" | "info" | "log" | "verbose";
103
103
  loggingDebug: ((value: string) => boolean)[];
104
104
  loggingTrace: boolean;
105
+ chunkModules: boolean;
106
+ chunkRelations: boolean;
107
+ reasons: boolean;
108
+ moduleAssets: boolean;
109
+ nestedModules: boolean;
110
+ source: boolean;
111
+ usedExports: boolean;
112
+ providedExports: boolean;
113
+ optimizationBailout: boolean;
114
+ depth: boolean;
115
+ assets: boolean;
116
+ chunks: boolean;
117
+ errors: boolean;
118
+ errorsCount: boolean;
119
+ hash: boolean;
120
+ modules: boolean;
121
+ warnings: boolean;
122
+ warningsCount: boolean;
105
123
  }
106
124
  export type CreateStatsOptionsContext = KnownCreateStatsOptionsContext & Record<string, any>;
107
125
  export type NormalizedStatsOptions = KnownNormalizedStatsOptions & Omit<StatsOptions, keyof KnownNormalizedStatsOptions> & Record<string, any>;
package/dist/Compiler.js CHANGED
@@ -368,7 +368,7 @@ class Compiler {
368
368
  });
369
369
  }
370
370
  purgeInputFileSystem() {
371
- if (this.inputFileSystem && this.inputFileSystem.purge) {
371
+ if (this.inputFileSystem?.purge) {
372
372
  this.inputFileSystem.purge();
373
373
  }
374
374
  }
@@ -614,7 +614,7 @@ _Compiler_instance = new WeakMap(), _Compiler_initial = new WeakMap(), _Compiler
614
614
  throw cached.error;
615
615
  return cached.exports;
616
616
  }
617
- var execOptions = {
617
+ const execOptions = {
618
618
  id,
619
619
  module: {
620
620
  id,
@@ -1,5 +1,4 @@
1
1
  import type { Compiler } from "./Compiler";
2
2
  export default class ExecuteModulePlugin {
3
- constructor();
4
3
  apply(compiler: Compiler): void;
5
4
  }
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const node_vm_1 = __importDefault(require("node:vm"));
7
7
  const _1 = require(".");
8
8
  class ExecuteModulePlugin {
9
- constructor() { }
10
9
  apply(compiler) {
11
10
  compiler.hooks.compilation.tap("executeModule", compilation => {
12
11
  compilation.hooks.executeModule.tap("executeModule", (options, context) => {
package/dist/Module.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { JsCodegenerationResult, JsCodegenerationResults, JsCreateData, JsFactoryMeta, JsModule } from "@rspack/binding";
1
+ import type { JsCodegenerationResult, JsCreateData, JsFactoryMeta, JsModule } from "@rspack/binding";
2
2
  import type { Source } from "../compiled/webpack-sources";
3
3
  import type { Compilation } from "./Compilation";
4
4
  export type ResourceData = {
@@ -68,5 +68,4 @@ export declare class CodeGenerationResult {
68
68
  get(sourceType: string): string;
69
69
  }
70
70
  export declare class CodeGenerationResults {
71
- constructor(_result: JsCodegenerationResults);
72
71
  }
package/dist/Module.js CHANGED
@@ -67,6 +67,5 @@ class CodeGenerationResult {
67
67
  exports.CodeGenerationResult = CodeGenerationResult;
68
68
  _CodeGenerationResult_inner = new WeakMap();
69
69
  class CodeGenerationResults {
70
- constructor(_result) { }
71
70
  }
72
71
  exports.CodeGenerationResults = CodeGenerationResults;
@@ -271,7 +271,7 @@ class MultiCompiler {
271
271
  }
272
272
  purgeInputFileSystem() {
273
273
  for (const compiler of this.compilers) {
274
- if (compiler.inputFileSystem && compiler.inputFileSystem.purge) {
274
+ if (compiler.inputFileSystem?.purge) {
275
275
  compiler.inputFileSystem.purge();
276
276
  }
277
277
  }
@@ -1,7 +1,6 @@
1
1
  import type * as binding from "@rspack/binding";
2
2
  import { type Resolve } from "./config";
3
- interface ResolveContext {
4
- }
3
+ type ResolveContext = {};
5
4
  type ErrorWithDetail = Error & {
6
5
  details?: string;
7
6
  };
@@ -15,7 +15,7 @@ class NonErrorEmittedError extends Error {
15
15
  constructor(error) {
16
16
  super();
17
17
  this.name = "NonErrorEmittedError";
18
- this.message = "(Emitted value instead of an instance of Error) " + error;
18
+ this.message = `(Emitted value instead of an instance of Error) ${error}`;
19
19
  }
20
20
  }
21
21
  exports.NonErrorEmittedError = NonErrorEmittedError;
package/dist/Stats.js CHANGED
@@ -32,16 +32,17 @@ class Stats {
32
32
  return this.compilation.endTime;
33
33
  }
34
34
  hasErrors() {
35
- return __classPrivateFieldGet(this, _Stats_inner, "f").getErrors().length > 0;
35
+ return __classPrivateFieldGet(this, _Stats_inner, "f").hasErrors();
36
36
  }
37
37
  hasWarnings() {
38
- return __classPrivateFieldGet(this, _Stats_inner, "f").getWarnings().length > 0;
38
+ return __classPrivateFieldGet(this, _Stats_inner, "f").hasWarnings();
39
39
  }
40
40
  toJson(opts, forToString) {
41
41
  const options = this.compilation.createStatsOptions(opts, {
42
42
  forToString
43
43
  });
44
44
  const statsFactory = this.compilation.createStatsFactory(options);
45
+ const statsCompilationMap = new Map();
45
46
  // FIXME: This is a really ugly workaround for avoid panic for accessing previous compilation.
46
47
  // Modern.js dev server will detect whether the returned stats is available.
47
48
  // So this does not do harm to these frameworks.
@@ -50,6 +51,15 @@ class Stats {
50
51
  try {
51
52
  stats = statsFactory.create("compilation", this.compilation, {
52
53
  compilation: this.compilation,
54
+ getStatsCompilation: (compilation) => {
55
+ if (statsCompilationMap.has(compilation)) {
56
+ return statsCompilationMap.get(compilation);
57
+ }
58
+ const innerStats = __classPrivateFieldGet(this, _Stats_instances, "m", _Stats_getInnerByCompilation).call(this, compilation);
59
+ const innerStatsCompilation = innerStats.toJson(options);
60
+ statsCompilationMap.set(compilation, innerStatsCompilation);
61
+ return innerStatsCompilation;
62
+ },
53
63
  getInner: __classPrivateFieldGet(this, _Stats_instances, "m", _Stats_getInnerByCompilation).bind(this)
54
64
  });
55
65
  }
@@ -65,6 +75,7 @@ class Stats {
65
75
  });
66
76
  const statsFactory = this.compilation.createStatsFactory(options);
67
77
  const statsPrinter = this.compilation.createStatsPrinter(options);
78
+ const statsCompilationMap = new Map();
68
79
  // FIXME: This is a really ugly workaround for avoid panic for accessing previous compilation.
69
80
  // Modern.js dev server will detect whether the returned stats is available.
70
81
  // So this does not do harm to these frameworks.
@@ -73,6 +84,15 @@ class Stats {
73
84
  try {
74
85
  stats = statsFactory.create("compilation", this.compilation, {
75
86
  compilation: this.compilation,
87
+ getStatsCompilation: (compilation) => {
88
+ if (statsCompilationMap.has(compilation)) {
89
+ return statsCompilationMap.get(compilation);
90
+ }
91
+ const innerStats = __classPrivateFieldGet(this, _Stats_instances, "m", _Stats_getInnerByCompilation).call(this, compilation);
92
+ const innerStatsCompilation = innerStats.toJson(options);
93
+ statsCompilationMap.set(compilation, innerStatsCompilation);
94
+ return innerStatsCompilation;
95
+ },
76
96
  getInner: __classPrivateFieldGet(this, _Stats_instances, "m", _Stats_getInnerByCompilation).bind(this)
77
97
  });
78
98
  }
package/dist/Template.js CHANGED
@@ -156,7 +156,7 @@ class Template {
156
156
  if (!str)
157
157
  return "";
158
158
  const ind = str[0] === "\n" ? "" : prefix;
159
- return ind + str.replace(/\n([^\n])/g, "\n" + prefix + "$1");
159
+ return ind + str.replace(/\n([^\n])/g, `\n${prefix}$1`);
160
160
  }
161
161
  /**
162
162
  *
@@ -186,7 +186,7 @@ class Template {
186
186
  if (minId > moduleId)
187
187
  minId = moduleId;
188
188
  }
189
- if (minId < 16 + ("" + minId).length) {
189
+ if (minId < 16 + `${minId}`.length) {
190
190
  // add minId x ',' instead of 'Array(minId).concat(…)'
191
191
  minId = 0;
192
192
  }
@@ -141,7 +141,7 @@ function parseVersion(version) {
141
141
  .split("-")[0]
142
142
  .split(".")
143
143
  .map(v => Number.parseInt(v, 10));
144
- if (isNaN(major) || isNaN(minor) || isNaN(patch)) {
144
+ if (Number.isNaN(major) || Number.isNaN(minor) || Number.isNaN(patch)) {
145
145
  return null;
146
146
  }
147
147
  return (major << 16) | (minor << 8) | patch;
@@ -19,7 +19,7 @@ const normalizeValue = (define, supportsBigIntLiteral) => {
19
19
  return p.toString();
20
20
  }
21
21
  if (typeof p === "function") {
22
- return "(" + p.toString() + ")";
22
+ return `(${p.toString()})`;
23
23
  }
24
24
  if (typeof p === "bigint") {
25
25
  return supportsBigIntLiteral ? `${p}n` : `BigInt("${p}")`;
@@ -1,8 +1,8 @@
1
1
  import { BuiltinPluginName } from "@rspack/binding";
2
2
  export declare const EnableChunkLoadingPlugin: {
3
- new (type: any): {
3
+ new (type: string): {
4
4
  name: BuiltinPluginName;
5
- _args: [type: any];
5
+ _args: [type: string];
6
6
  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;
7
7
  raw(compiler: import("../Compiler").Compiler): import("@rspack/binding").BuiltinPlugin;
8
8
  apply(compiler: import("../Compiler").Compiler): void;
@@ -3,4 +3,4 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.EnableChunkLoadingPlugin = void 0;
4
4
  const binding_1 = require("@rspack/binding");
5
5
  const base_1 = require("./base");
6
- exports.EnableChunkLoadingPlugin = (0, base_1.create)(binding_1.BuiltinPluginName.EnableChunkLoadingPlugin, type => type);
6
+ exports.EnableChunkLoadingPlugin = (0, base_1.create)(binding_1.BuiltinPluginName.EnableChunkLoadingPlugin, (type) => type);
@@ -23,12 +23,7 @@ class EnableLibraryPlugin extends base_1.RspackBuiltinPlugin {
23
23
  }
24
24
  static checkEnabled(compiler, type) {
25
25
  if (!getEnabledTypes(compiler).has(type)) {
26
- throw new Error(`Library type "${type}" is not enabled. ` +
27
- "EnableLibraryPlugin need to be used to enable this type of library. " +
28
- 'This usually happens through the "output.enabledLibraryTypes" option. ' +
29
- 'If you are using a function as entry which sets "library", you need to add all potential library types to "output.enabledLibraryTypes". ' +
30
- "These types are enabled: " +
31
- Array.from(getEnabledTypes(compiler)).join(", "));
26
+ throw new Error(`Library type "${type}" is not enabled. EnableLibraryPlugin need to be used to enable this type of library. This usually happens through the "output.enabledLibraryTypes" option. If you are using a function as entry which sets "library", you need to add all potential library types to "output.enabledLibraryTypes". These types are enabled: ${Array.from(getEnabledTypes(compiler)).join(", ")}`);
32
27
  }
33
28
  }
34
29
  raw(compiler) {
@@ -1,8 +1,8 @@
1
1
  import { BuiltinPluginName } from "@rspack/binding";
2
2
  export declare const EnableWasmLoadingPlugin: {
3
- new (type: any): {
3
+ new (type: string): {
4
4
  name: BuiltinPluginName;
5
- _args: [type: any];
5
+ _args: [type: string];
6
6
  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;
7
7
  raw(compiler: import("../Compiler").Compiler): import("@rspack/binding").BuiltinPlugin;
8
8
  apply(compiler: import("../Compiler").Compiler): void;
@@ -3,4 +3,4 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.EnableWasmLoadingPlugin = void 0;
4
4
  const binding_1 = require("@rspack/binding");
5
5
  const base_1 = require("./base");
6
- exports.EnableWasmLoadingPlugin = (0, base_1.create)(binding_1.BuiltinPluginName.EnableWasmLoadingPlugin, type => type);
6
+ exports.EnableWasmLoadingPlugin = (0, base_1.create)(binding_1.BuiltinPluginName.EnableWasmLoadingPlugin, (type) => type);
@@ -26,7 +26,7 @@ function getRawExternalItem(item) {
26
26
  externalType: type
27
27
  });
28
28
  });
29
- if (promise && promise.then) {
29
+ if (promise?.then) {
30
30
  promise.then(result => resolve({
31
31
  result: getRawExternalItemValueFormFnResult(result),
32
32
  externalType: undefined
@@ -10,7 +10,6 @@ export type CompilationHooks = {
10
10
  export declare class JavascriptModulesPlugin extends RspackBuiltinPlugin {
11
11
  name: BuiltinPluginName;
12
12
  affectedHooks: "compilation";
13
- constructor();
14
13
  raw(): BuiltinPlugin;
15
14
  static getCompilationHooks(compilation: Compilation): CompilationHooks;
16
15
  }
@@ -31,7 +31,7 @@ const base_1 = require("./base");
31
31
  const compilationHooksMap = new WeakMap();
32
32
  class JavascriptModulesPlugin extends base_1.RspackBuiltinPlugin {
33
33
  constructor() {
34
- super();
34
+ super(...arguments);
35
35
  this.name = binding_1.BuiltinPluginName.JavascriptModulesPlugin;
36
36
  this.affectedHooks = "compilation";
37
37
  }
@@ -198,8 +198,7 @@ export interface TerserMangleOptions {
198
198
  safari10?: boolean;
199
199
  reserved?: string[];
200
200
  }
201
- export interface TerserManglePropertiesOptions {
202
- }
201
+ export type TerserManglePropertiesOptions = {};
203
202
  export declare const SwcJsMinimizerRspackPlugin: {
204
203
  new (options?: SwcJsMinimizerRspackPluginOptions | undefined): {
205
204
  name: BuiltinPluginName;
@@ -7,10 +7,8 @@ const noDocument = typeof document === "undefined";
7
7
  const { forEach } = Array.prototype;
8
8
  function debounce(fn, time) {
9
9
  let timeout = 0;
10
- return function () {
11
- // @ts-ignore
10
+ return function (...args) {
12
11
  const self = this;
13
- const args = arguments;
14
12
  const functionCall = function functionCall() {
15
13
  return fn.apply(self, args);
16
14
  };
@@ -34,12 +32,12 @@ function getCurrentScriptUrl(moduleId) {
34
32
  }
35
33
  srcByModuleId[moduleId] = src;
36
34
  }
37
- return function (fileMap) {
35
+ return (fileMap) => {
38
36
  if (!src) {
39
37
  return null;
40
38
  }
41
39
  const splitResult = src.split(/([^\\/]+)\.js$/);
42
- const filename = splitResult && splitResult[1];
40
+ const filename = splitResult?.[1];
43
41
  if (!filename) {
44
42
  return [src.replace(".js", ".css")];
45
43
  }
@@ -6,12 +6,14 @@ function normalizeUrl(urlString) {
6
6
  if (/^data:/i.test(urlString)) {
7
7
  return urlString;
8
8
  }
9
- var protocol = urlString.indexOf("//") !== -1 ? urlString.split("//")[0] + "//" : "";
10
- var components = urlString.replace(new RegExp(protocol, "i"), "").split("/");
11
- var host = components[0].toLowerCase().replace(/\.$/, "");
9
+ const protocol = urlString.indexOf("//") !== -1 ? `${urlString.split("//")[0]}//` : "";
10
+ const components = urlString
11
+ .replace(new RegExp(protocol, "i"), "")
12
+ .split("/");
13
+ const host = components[0].toLowerCase().replace(/\.$/, "");
12
14
  components[0] = "";
13
- var path = components
14
- .reduce(function (accumulator, item) {
15
+ const path = components
16
+ .reduce((accumulator, item) => {
15
17
  switch (item) {
16
18
  case "..":
17
19
  accumulator.pop();
@@ -11,7 +11,7 @@ const utils_1 = require("./utils");
11
11
  exports.BASE_URI = "webpack://";
12
12
  exports.MODULE_TYPE = "css/mini-extract";
13
13
  exports.AUTO_PUBLIC_PATH = "__mini_css_extract_plugin_public_path_auto__";
14
- exports.ABSOLUTE_PUBLIC_PATH = exports.BASE_URI + "/mini-css-extract-plugin/";
14
+ exports.ABSOLUTE_PUBLIC_PATH = `${exports.BASE_URI}/mini-css-extract-plugin/`;
15
15
  exports.SINGLE_DOT_PATH_SEGMENT = "__mini_css_extract_plugin_single_dot_path_segment__";
16
16
  const SERIALIZE_SEP = "__RSPACK_CSS_EXTRACT_SEP__";
17
17
  function hotLoader(content, context) {
@@ -42,10 +42,7 @@ function hotLoader(content, context) {
42
42
  }
43
43
  exports.hotLoader = hotLoader;
44
44
  const loader = function loader(content) {
45
- if (this._compiler &&
46
- this._compiler.options &&
47
- this._compiler.options.experiments &&
48
- this._compiler.options.experiments.css &&
45
+ if (this._compiler?.options?.experiments?.css &&
49
46
  this._module &&
50
47
  (this._module.type === "css" ||
51
48
  this._module.type === "css/auto" ||
@@ -55,10 +52,7 @@ const loader = function loader(content) {
55
52
  }
56
53
  };
57
54
  const pitch = function (request, _, data) {
58
- if (this._compiler &&
59
- this._compiler.options &&
60
- this._compiler.options.experiments &&
61
- this._compiler.options.experiments.css &&
55
+ if (this._compiler?.options?.experiments?.css &&
62
56
  this._module &&
63
57
  (this._module.type === "css" ||
64
58
  this._module.type === "css/auto" ||
@@ -122,7 +116,7 @@ const pitch = function (request, _, data) {
122
116
  }
123
117
  }
124
118
  else {
125
- locals = exports && exports.locals;
119
+ locals = exports?.locals;
126
120
  }
127
121
  if (Array.isArray(exports) && emit) {
128
122
  const identifierCountMap = new Map();
@@ -1,8 +1,8 @@
1
- /*
2
- MIT License http://www.opensource.org/licenses/mit-license.php
3
- Author Tobias Koppers @sokra
4
- */
5
1
  "use strict";
2
+ /*
3
+ * MIT License http://www.opensource.org/licenses/mit-license.php
4
+ * Author Tobias Koppers @sokra
5
+ */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.moduleImpl = exports.dispose = void 0;
8
8
  const getBackend = (options) => (compiler, callback) => {
@@ -129,6 +129,7 @@ function getRawOutput(output) {
129
129
  crossOriginLoading: getRawCrossOriginLoading(output.crossOriginLoading),
130
130
  cssFilename: output.cssFilename,
131
131
  cssChunkFilename: output.cssChunkFilename,
132
+ cssHeadDataCompression: output.cssHeadDataCompression,
132
133
  hotUpdateChunkFilename: output.hotUpdateChunkFilename,
133
134
  hotUpdateMainFilename: output.hotUpdateMainFilename,
134
135
  hotUpdateGlobal: output.hotUpdateGlobal,
@@ -102,12 +102,8 @@ export interface LoaderContext<OptionsType = {}> {
102
102
  _compilation: Compilation;
103
103
  _module: Module;
104
104
  }
105
- export interface LoaderDefinitionFunction<OptionsType = {}, ContextAdditions = {}> {
106
- (this: LoaderContext<OptionsType> & ContextAdditions, content: string, sourceMap?: string | SourceMap, additionalData?: AdditionalData): string | void | Buffer | Promise<string | Buffer>;
107
- }
108
- export interface PitchLoaderDefinitionFunction<OptionsType = {}, ContextAdditions = {}> {
109
- (this: LoaderContext<OptionsType> & ContextAdditions, remainingRequest: string, previousRequest: string, data: object): string | void | Buffer | Promise<string | Buffer>;
110
- }
105
+ export type LoaderDefinitionFunction<OptionsType = {}, ContextAdditions = {}> = (this: LoaderContext<OptionsType> & ContextAdditions, content: string, sourceMap?: string | SourceMap, additionalData?: AdditionalData) => string | void | Buffer | Promise<string | Buffer>;
106
+ export type PitchLoaderDefinitionFunction<OptionsType = {}, ContextAdditions = {}> = (this: LoaderContext<OptionsType> & ContextAdditions, remainingRequest: string, previousRequest: string, data: object) => string | void | Buffer | Promise<string | Buffer>;
111
107
  export type LoaderDefinition<OptionsType = {}, ContextAdditions = {}> = LoaderDefinitionFunction<OptionsType, ContextAdditions> & {
112
108
  raw?: false;
113
109
  pitch?: PitchLoaderDefinitionFunction;
@@ -55,7 +55,8 @@ function createRawModuleRuleUsesImpl(uses, path, options) {
55
55
  return [];
56
56
  }
57
57
  return uses.map((use, index) => {
58
- let o, isBuiltin = false;
58
+ let o;
59
+ let isBuiltin = false;
59
60
  if (use.loader.startsWith(exports.BUILTIN_LOADER_PREFIX)) {
60
61
  o = getBuiltinLoaderOptions(use.loader, use.options, options);
61
62
  o = (0, util_1.isNil)(o) ? undefined : typeof o === "string" ? o : JSON.stringify(o);
@@ -75,15 +76,15 @@ function resolveStringifyLoaders(use, path, compiler, isBuiltin) {
75
76
  else if (use.options === undefined) {
76
77
  }
77
78
  else if (typeof use.options === "string")
78
- obj.query = "?" + use.options;
79
+ obj.query = `?${use.options}`;
79
80
  else if (use.ident)
80
- obj.query = "??" + (ident = use.ident);
81
+ obj.query = `??${(ident = use.ident)}`;
81
82
  else if (typeof use.options === "object" && use.options.ident)
82
- obj.query = "??" + (ident = use.options.ident);
83
+ obj.query = `??${(ident = use.options.ident)}`;
83
84
  else if (typeof use.options === "object")
84
- obj.query = "??" + (ident = path);
85
+ obj.query = `??${(ident = path)}`;
85
86
  else
86
- obj.query = "?" + JSON.stringify(use.options);
87
+ obj.query = `?${JSON.stringify(use.options)}`;
87
88
  if (use.options && typeof use.options === "object") {
88
89
  if (!ident)
89
90
  ident = "[[missing ident]]";
@@ -403,8 +403,9 @@ const applyOutputDefaults = (output, { context, outputModule, targetProperties:
403
403
  D(output, "hotUpdateChunkFilename", `[id].[fullhash].hot-update.${output.module ? "mjs" : "js"}`);
404
404
  D(output, "hotUpdateMainFilename", "[runtime].[fullhash].hot-update.json");
405
405
  const uniqueNameId = Template_1.Template.toIdentifier(output.uniqueName);
406
- F(output, "hotUpdateGlobal", () => "webpackHotUpdate" + uniqueNameId);
407
- F(output, "chunkLoadingGlobal", () => "webpackChunk" + uniqueNameId);
406
+ F(output, "hotUpdateGlobal", () => `webpackHotUpdate${uniqueNameId}`);
407
+ F(output, "chunkLoadingGlobal", () => `webpackChunk${uniqueNameId}`);
408
+ D(output, "cssHeadDataCompression", !development);
408
409
  D(output, "assetModuleFilename", "[hash][ext][query]");
409
410
  D(output, "webassemblyModuleFilename", "[hash].module.wasm");
410
411
  F(output, "path", () => node_path_1.default.join(process.cwd(), "dist"));
@@ -427,10 +428,7 @@ const applyOutputDefaults = (output, { context, outputModule, targetProperties:
427
428
  return "module";
428
429
  if (tp.document)
429
430
  return "array-push";
430
- throw new Error("For the selected environment is no default ESM chunk format available:\n" +
431
- "ESM exports can be chosen when 'import()' is available.\n" +
432
- "JSONP Array push can be chosen when 'document' is available.\n" +
433
- helpMessage);
431
+ throw new Error(`For the selected environment is no default ESM chunk format available:\nESM exports can be chosen when 'import()' is available.\nJSONP Array push can be chosen when 'document' is available.\n${helpMessage}`);
434
432
  }
435
433
  if (tp.document)
436
434
  return "array-push";
@@ -440,10 +438,7 @@ const applyOutputDefaults = (output, { context, outputModule, targetProperties:
440
438
  return "commonjs";
441
439
  if (tp.importScripts)
442
440
  return "array-push";
443
- throw new Error("For the selected environment is no default script chunk format available:\n" +
444
- "JSONP Array push can be chosen when 'document' or 'importScripts' is available.\n" +
445
- "CommonJs exports can be chosen when 'require' or node builtins are available.\n" +
446
- helpMessage);
441
+ throw new Error(`For the selected environment is no default script chunk format available:\nJSONP Array push can be chosen when 'document' or 'importScripts' is available.\nCommonJs exports can be chosen when 'require' or node builtins are available.\n${helpMessage}`);
447
442
  }
448
443
  throw new Error("Chunk format can't be selected by default when no target is specified");
449
444
  });
@@ -592,8 +587,8 @@ const applyOutputDefaults = (output, { context, outputModule, targetProperties:
592
587
  const environment = output.environment;
593
588
  const optimistic = (v) => v || v === undefined;
594
589
  const conditionallyOptimistic = (v, c) => (v === undefined && c) || v;
595
- F(environment, "globalThis", () => tp && tp.globalThis);
596
- F(environment, "bigIntLiteral", () => tp && tp.bigIntLiteral);
590
+ F(environment, "globalThis", () => tp?.globalThis);
591
+ F(environment, "bigIntLiteral", () => tp?.bigIntLiteral);
597
592
  F(environment, "const", () => tp && optimistic(tp.const));
598
593
  F(environment, "arrowFunction", () => tp && optimistic(tp.arrowFunction));
599
594
  F(environment, "asyncFunction", () => tp && optimistic(tp.asyncFunction));
@@ -602,25 +597,19 @@ const applyOutputDefaults = (output, { context, outputModule, targetProperties:
602
597
  F(environment, "optionalChaining", () => tp && optimistic(tp.optionalChaining));
603
598
  F(environment, "nodePrefixForCoreModules", () => tp && optimistic(tp.nodePrefixForCoreModules));
604
599
  F(environment, "templateLiteral", () => tp && optimistic(tp.templateLiteral));
605
- F(environment, "dynamicImport", () => conditionallyOptimistic(tp && tp.dynamicImport, output.module));
606
- F(environment, "dynamicImportInWorker", () => conditionallyOptimistic(tp && tp.dynamicImportInWorker, output.module));
607
- F(environment, "module", () => conditionallyOptimistic(tp && tp.module, output.module));
600
+ F(environment, "dynamicImport", () => conditionallyOptimistic(tp?.dynamicImport, output.module));
601
+ F(environment, "dynamicImportInWorker", () => conditionallyOptimistic(tp?.dynamicImportInWorker, output.module));
602
+ F(environment, "module", () => conditionallyOptimistic(tp?.module, output.module));
608
603
  F(environment, "document", () => tp && optimistic(tp.document));
609
604
  };
610
605
  const applyExternalsPresetsDefaults = (externalsPresets, { targetProperties }) => {
611
- D(externalsPresets, "web", targetProperties && targetProperties.web);
612
- D(externalsPresets, "node", targetProperties && targetProperties.node);
613
- D(externalsPresets, "electron", targetProperties && targetProperties.electron);
614
- D(externalsPresets, "electronMain", targetProperties &&
615
- targetProperties.electron &&
616
- targetProperties.electronMain);
617
- D(externalsPresets, "electronPreload", targetProperties &&
618
- targetProperties.electron &&
619
- targetProperties.electronPreload);
620
- D(externalsPresets, "electronRenderer", targetProperties &&
621
- targetProperties.electron &&
622
- targetProperties.electronRenderer);
623
- D(externalsPresets, "nwjs", targetProperties && targetProperties.nwjs);
606
+ D(externalsPresets, "web", targetProperties?.web);
607
+ D(externalsPresets, "node", targetProperties?.node);
608
+ D(externalsPresets, "electron", targetProperties?.electron);
609
+ D(externalsPresets, "electronMain", targetProperties?.electron && targetProperties.electronMain);
610
+ D(externalsPresets, "electronPreload", targetProperties?.electron && targetProperties.electronPreload);
611
+ D(externalsPresets, "electronRenderer", targetProperties?.electron && targetProperties.electronRenderer);
612
+ D(externalsPresets, "nwjs", targetProperties?.nwjs);
624
613
  };
625
614
  const applyLoaderDefaults = (loader, { targetProperties, environment }) => {
626
615
  F(loader, "target", () => {
@@ -649,19 +638,19 @@ const applyNodeDefaults = (node, { targetProperties }) => {
649
638
  return;
650
639
  // IGNORE(node.global): The default value of `global` is determined by `futureDefaults` in webpack.
651
640
  F(node, "global", () => {
652
- if (targetProperties && targetProperties.global)
641
+ if (targetProperties?.global)
653
642
  return false;
654
643
  return "warn";
655
644
  });
656
645
  // IGNORE(node.__dirname): The default value of `__dirname` is determined by `futureDefaults` in webpack.
657
646
  F(node, "__dirname", () => {
658
- if (targetProperties && targetProperties.node)
647
+ if (targetProperties?.node)
659
648
  return "eval-only";
660
649
  return "warn-mock";
661
650
  });
662
651
  // IGNORE(node.__filename): The default value of `__filename` is determined by `futureDefaults` in webpack.
663
652
  F(node, "__filename", () => {
664
- if (targetProperties && targetProperties.node)
653
+ if (targetProperties?.node)
665
654
  return "eval-only";
666
655
  return "warn-mock";
667
656
  });
@@ -772,7 +761,7 @@ const getResolveDefaults = ({ context, targetProperties, mode, css }) => {
772
761
  }
773
762
  const jsExtensions = [".js", ".json", ".wasm"];
774
763
  const tp = targetProperties;
775
- const browserField = tp && tp.web && (!tp.node || (tp.electron && tp.electronRenderer));
764
+ const browserField = tp?.web && (!tp.node || (tp.electron && tp.electronRenderer));
776
765
  const aliasFields = browserField ? ["browser"] : [];
777
766
  const mainFields = browserField
778
767
  ? ["browser", "module", "..."]
@@ -74,6 +74,7 @@ export interface OutputNormalized {
74
74
  environment?: Environment;
75
75
  charset?: boolean;
76
76
  chunkLoadTimeout?: number;
77
+ cssHeadDataCompression?: boolean;
77
78
  }
78
79
  export interface ModuleOptionsNormalized {
79
80
  defaultRules?: RuleSetRules;