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

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 (121) hide show
  1. package/dist/ChunkGroup.d.ts +1 -0
  2. package/dist/ChunkGroup.js +3 -0
  3. package/dist/Compilation.d.ts +38 -1
  4. package/dist/Compilation.js +109 -44
  5. package/dist/Compiler.d.ts +1 -0
  6. package/dist/Compiler.js +31 -26
  7. package/dist/ExecuteModulePlugin.d.ts +0 -1
  8. package/dist/ExecuteModulePlugin.js +0 -1
  9. package/dist/Module.d.ts +1 -2
  10. package/dist/Module.js +0 -1
  11. package/dist/MultiCompiler.js +11 -7
  12. package/dist/MultiStats.d.ts +1 -1
  13. package/dist/MultiStats.js +19 -16
  14. package/dist/NormalModule.js +3 -4
  15. package/dist/Resolver.d.ts +1 -2
  16. package/dist/RspackError.js +1 -1
  17. package/dist/Stats.d.ts +1 -1
  18. package/dist/Stats.js +22 -2
  19. package/dist/Template.d.ts +4 -4
  20. package/dist/Template.js +8 -6
  21. package/dist/Watching.js +3 -5
  22. package/dist/builtin-loader/lightningcss/index.js +1 -1
  23. package/dist/builtin-plugin/DefinePlugin.js +1 -1
  24. package/dist/builtin-plugin/DynamicEntryPlugin.d.ts +11 -10
  25. package/dist/builtin-plugin/DynamicEntryPlugin.js +26 -15
  26. package/dist/builtin-plugin/EnableChunkLoadingPlugin.d.ts +2 -2
  27. package/dist/builtin-plugin/EnableChunkLoadingPlugin.js +1 -1
  28. package/dist/builtin-plugin/EnableLibraryPlugin.js +1 -6
  29. package/dist/builtin-plugin/EnableWasmLoadingPlugin.d.ts +2 -2
  30. package/dist/builtin-plugin/EnableWasmLoadingPlugin.js +1 -1
  31. package/dist/builtin-plugin/EntryPlugin.d.ts +2 -2
  32. package/dist/builtin-plugin/ExternalsPlugin.js +1 -1
  33. package/dist/builtin-plugin/JavascriptModulesPlugin.d.ts +0 -1
  34. package/dist/builtin-plugin/JavascriptModulesPlugin.js +1 -1
  35. package/dist/builtin-plugin/LightningCssMiminizerRspackPlugin.d.ts +21 -4
  36. package/dist/builtin-plugin/LightningCssMiminizerRspackPlugin.js +29 -5
  37. package/dist/builtin-plugin/SwcCssMinimizerPlugin.d.ts +4 -6
  38. package/dist/builtin-plugin/SwcJsMinimizerPlugin.d.ts +17 -12
  39. package/dist/builtin-plugin/SwcJsMinimizerPlugin.js +11 -9
  40. package/dist/builtin-plugin/css-extract/hmr/hotModuleReplacement.js +13 -11
  41. package/dist/builtin-plugin/css-extract/hmr/normalizeUrl.d.ts +1 -1
  42. package/dist/builtin-plugin/css-extract/hmr/normalizeUrl.js +9 -7
  43. package/dist/builtin-plugin/css-extract/loader.js +5 -12
  44. package/dist/builtin-plugin/lazy-compilation/backend.js +4 -4
  45. package/dist/config/adapter.d.ts +2 -2
  46. package/dist/config/adapter.js +1 -0
  47. package/dist/config/adapterRuleUse.d.ts +2 -6
  48. package/dist/config/adapterRuleUse.js +7 -6
  49. package/dist/config/defaults.js +21 -32
  50. package/dist/config/normalization.d.ts +1 -0
  51. package/dist/config/normalization.js +5 -2
  52. package/dist/config/zod.d.ts +762 -114
  53. package/dist/config/zod.js +29 -6
  54. package/dist/container/default.runtime.js +1 -1
  55. package/dist/exports.d.ts +4 -3
  56. package/dist/exports.js +5 -2
  57. package/dist/lib/AbstractMethodError.js +2 -3
  58. package/dist/lib/Cache.d.ts +1 -1
  59. package/dist/lib/Cache.js +6 -4
  60. package/dist/lib/CacheFacade.js +8 -9
  61. package/dist/lib/Dependency.d.ts +23 -0
  62. package/dist/lib/Dependency.js +11 -0
  63. package/dist/lib/EnvironmentPlugin.js +1 -3
  64. package/dist/lib/LoaderOptionsPlugin.d.ts +4 -2
  65. package/dist/lib/LoaderOptionsPlugin.js +0 -2
  66. package/dist/lib/ModuleFilenameHelpers.js +1 -1
  67. package/dist/lib/WebpackError.d.ts +0 -6
  68. package/dist/lib/WebpackError.js +0 -8
  69. package/dist/lib/cache/MemoryCachePlugin.d.ts +5 -0
  70. package/dist/lib/cache/MemoryCachePlugin.js +40 -0
  71. package/dist/lib/cache/mergeEtags.d.ts +3 -3
  72. package/dist/lib/cache/mergeEtags.js +5 -3
  73. package/dist/lib/formatLocation.d.ts +1 -1
  74. package/dist/loader-runner/index.js +10 -9
  75. package/dist/loader-runner/loadLoader.js +8 -11
  76. package/dist/logging/Logger.js +3 -3
  77. package/dist/logging/createConsoleLogger.d.ts +26 -6
  78. package/dist/logging/createConsoleLogger.js +21 -58
  79. package/dist/logging/runtime.d.ts +4 -10
  80. package/dist/logging/runtime.js +8 -23
  81. package/dist/logging/truncateArgs.d.ts +4 -4
  82. package/dist/logging/truncateArgs.js +5 -10
  83. package/dist/node/NodeEnvironmentPlugin.js +2 -2
  84. package/dist/node/NodeWatchFileSystem.js +6 -6
  85. package/dist/node/nodeConsole.d.ts +7 -21
  86. package/dist/node/nodeConsole.js +31 -38
  87. package/dist/rspackOptionsApply.d.ts +0 -1
  88. package/dist/rspackOptionsApply.js +8 -7
  89. package/dist/sharing/ProvideSharedPlugin.d.ts +20 -19
  90. package/dist/sharing/ProvideSharedPlugin.js +26 -17
  91. package/dist/sharing/SharePlugin.d.ts +3 -0
  92. package/dist/sharing/SharePlugin.js +4 -1
  93. package/dist/stats/DefaultStatsFactoryPlugin.js +187 -96
  94. package/dist/stats/DefaultStatsPresetPlugin.js +2 -5
  95. package/dist/stats/DefaultStatsPrinterPlugin.js +18 -19
  96. package/dist/stats/StatsFactory.d.ts +2 -1
  97. package/dist/stats/StatsFactory.js +5 -10
  98. package/dist/stats/StatsPrinter.js +3 -4
  99. package/dist/stats/statsFactoryUtils.d.ts +155 -28
  100. package/dist/util/SizeFormatHelpers.js +1 -1
  101. package/dist/util/assertNotNil.d.ts +1 -1
  102. package/dist/util/assetCondition.d.ts +2 -0
  103. package/dist/util/assetCondition.js +2 -0
  104. package/dist/util/bindingVersionCheck.js +3 -3
  105. package/dist/util/cleverMerge.js +8 -6
  106. package/dist/util/comparators.d.ts +1 -1
  107. package/dist/util/comparators.js +5 -4
  108. package/dist/util/createHash.js +11 -6
  109. package/dist/util/fs.js +2 -2
  110. package/dist/util/hash/wasm-hash.js +5 -4
  111. package/dist/util/identifier.d.ts +4 -4
  112. package/dist/util/identifier.js +10 -10
  113. package/dist/util/index.js +1 -1
  114. package/dist/util/memoize.js +4 -6
  115. package/dist/util/smartGrouping.js +4 -6
  116. package/dist/util/webpack.d.ts +1 -1
  117. package/dist/util/webpack.js +2 -1
  118. package/module.d.ts +1 -1
  119. package/package.json +3 -3
  120. package/dist/builtin-plugin/css-extract/loader-options.json +0 -37
  121. package/dist/builtin-plugin/css-extract/plugin-options.json +0 -79
@@ -47,11 +47,11 @@ function getRawExtractCommentsOptions(extractComments) {
47
47
  return undefined;
48
48
  }
49
49
  exports.SwcJsMinimizerRspackPlugin = (0, base_1.create)(binding_1.BuiltinPluginName.SwcJsMinimizerRspackPlugin, (options) => {
50
- let compress = options?.compress ?? true;
51
- const mangle = options?.mangle ?? true;
50
+ let compress = options?.minimizerOptions?.compress ?? true;
51
+ const mangle = options?.minimizerOptions?.mangle ?? true;
52
52
  const format = {
53
53
  comments: false,
54
- ...options?.format
54
+ ...options?.minimizerOptions?.format
55
55
  };
56
56
  if (compress && typeof compress === "object") {
57
57
  compress = {
@@ -65,13 +65,15 @@ exports.SwcJsMinimizerRspackPlugin = (0, base_1.create)(binding_1.BuiltinPluginN
65
65
  };
66
66
  }
67
67
  return {
68
- extractComments: getRawExtractCommentsOptions(options?.extractComments),
69
- compress,
70
- mangle,
71
- format,
72
- module: options?.module,
73
68
  test: options?.test,
74
69
  include: options?.include,
75
- exclude: options?.exclude
70
+ exclude: options?.exclude,
71
+ extractComments: getRawExtractCommentsOptions(options?.extractComments),
72
+ minimizerOptions: {
73
+ compress,
74
+ mangle,
75
+ format,
76
+ module: options?.minimizerOptions?.module
77
+ }
76
78
  };
77
79
  }, "compilation");
@@ -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
  }
@@ -53,13 +51,17 @@ function getCurrentScriptUrl(moduleId) {
53
51
  };
54
52
  }
55
53
  function updateCss(el, url) {
54
+ let normalizedUrl;
56
55
  if (!url) {
57
56
  if (!el.href) {
58
57
  return;
59
58
  }
60
- url = el.href.split("?")[0];
59
+ normalizedUrl = el.href.split("?")[0];
61
60
  }
62
- if (!isUrlRequest(url)) {
61
+ else {
62
+ normalizedUrl = url;
63
+ }
64
+ if (!isUrlRequest(normalizedUrl)) {
63
65
  return;
64
66
  }
65
67
  if (el.isLoaded === false) {
@@ -67,7 +69,7 @@ function updateCss(el, url) {
67
69
  // We're probably changing the same file more than once.
68
70
  return;
69
71
  }
70
- if (!url || !(url.indexOf(".css") > -1)) {
72
+ if (!normalizedUrl || !(normalizedUrl.indexOf(".css") > -1)) {
71
73
  return;
72
74
  }
73
75
  el.visited = true;
@@ -87,7 +89,7 @@ function updateCss(el, url) {
87
89
  newEl.isLoaded = true;
88
90
  el.parentNode?.removeChild(el);
89
91
  });
90
- newEl.href = `${url}?${Date.now()}`;
92
+ newEl.href = `${normalizedUrl}?${Date.now()}`;
91
93
  if (el.nextSibling) {
92
94
  el.parentNode?.insertBefore(newEl, el.nextSibling);
93
95
  }
@@ -97,9 +99,9 @@ function updateCss(el, url) {
97
99
  }
98
100
  function getReloadUrl(href, src) {
99
101
  let ret = "";
100
- href = (0, normalizeUrl_1.normalizeUrl)(href);
102
+ const normalizedHref = (0, normalizeUrl_1.normalizeUrl)(href);
101
103
  src.some(url => {
102
- if (href.indexOf(src) > -1) {
104
+ if (normalizedHref.indexOf(src) > -1) {
103
105
  ret = url;
104
106
  }
105
107
  });
@@ -1,2 +1,2 @@
1
- declare function normalizeUrl(urlString: string): string;
1
+ declare function normalizeUrl(url: string): string;
2
2
  export { normalizeUrl };
@@ -1,17 +1,19 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.normalizeUrl = void 0;
4
- function normalizeUrl(urlString) {
5
- urlString = urlString.trim();
4
+ function normalizeUrl(url) {
5
+ const urlString = url.trim();
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();
@@ -6,12 +6,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.pitch = exports.hotLoader = exports.SINGLE_DOT_PATH_SEGMENT = exports.ABSOLUTE_PUBLIC_PATH = exports.AUTO_PUBLIC_PATH = exports.MODULE_TYPE = exports.BASE_URI = void 0;
7
7
  const node_path_1 = __importDefault(require("node:path"));
8
8
  const index_1 = require("./index");
9
- const loader_options_json_1 = __importDefault(require("./loader-options.json"));
10
9
  const utils_1 = require("./utils");
11
10
  exports.BASE_URI = "webpack://";
12
11
  exports.MODULE_TYPE = "css/mini-extract";
13
12
  exports.AUTO_PUBLIC_PATH = "__mini_css_extract_plugin_public_path_auto__";
14
- exports.ABSOLUTE_PUBLIC_PATH = exports.BASE_URI + "/mini-css-extract-plugin/";
13
+ exports.ABSOLUTE_PUBLIC_PATH = `${exports.BASE_URI}/mini-css-extract-plugin/`;
15
14
  exports.SINGLE_DOT_PATH_SEGMENT = "__mini_css_extract_plugin_single_dot_path_segment__";
16
15
  const SERIALIZE_SEP = "__RSPACK_CSS_EXTRACT_SEP__";
17
16
  function hotLoader(content, context) {
@@ -42,10 +41,7 @@ function hotLoader(content, context) {
42
41
  }
43
42
  exports.hotLoader = hotLoader;
44
43
  const loader = function loader(content) {
45
- if (this._compiler &&
46
- this._compiler.options &&
47
- this._compiler.options.experiments &&
48
- this._compiler.options.experiments.css &&
44
+ if (this._compiler?.options?.experiments?.css &&
49
45
  this._module &&
50
46
  (this._module.type === "css" ||
51
47
  this._module.type === "css/auto" ||
@@ -55,10 +51,7 @@ const loader = function loader(content) {
55
51
  }
56
52
  };
57
53
  const pitch = function (request, _, data) {
58
- if (this._compiler &&
59
- this._compiler.options &&
60
- this._compiler.options.experiments &&
61
- this._compiler.options.experiments.css &&
54
+ if (this._compiler?.options?.experiments?.css &&
62
55
  this._module &&
63
56
  (this._module.type === "css" ||
64
57
  this._module.type === "css/auto" ||
@@ -69,7 +62,7 @@ const pitch = function (request, _, data) {
69
62
  this.emitWarning(e);
70
63
  return;
71
64
  }
72
- const options = this.getOptions(loader_options_json_1.default);
65
+ const options = this.getOptions();
73
66
  const emit = typeof options.emit !== "undefined" ? options.emit : true;
74
67
  const callback = this.async();
75
68
  const filepath = this.resourcePath;
@@ -122,7 +115,7 @@ const pitch = function (request, _, data) {
122
115
  }
123
116
  }
124
117
  else {
125
- locals = exports && exports.locals;
118
+ locals = exports?.locals;
126
119
  }
127
120
  if (Array.isArray(exports) && emit) {
128
121
  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) => {
@@ -1,4 +1,4 @@
1
- import { type RawLibraryOptions, type RawOptions } from "@rspack/binding";
1
+ import { type JsLibraryOptions, type RawOptions } from "@rspack/binding";
2
2
  import type { Compiler } from "../Compiler";
3
3
  import { type LoaderContext, type LoaderDefinition, type LoaderDefinitionFunction } from "./adapterRuleUse";
4
4
  import type { RspackOptionsNormalized } from "./normalization";
@@ -6,5 +6,5 @@ import type { ChunkLoading, LibraryOptions, Resolve } from "./zod";
6
6
  export type { LoaderContext, LoaderDefinition, LoaderDefinitionFunction };
7
7
  export declare const getRawOptions: (options: RspackOptionsNormalized, compiler: Compiler) => RawOptions;
8
8
  export declare function getRawResolve(resolve: Resolve): RawOptions["resolve"];
9
- export declare function getRawLibrary(library: LibraryOptions): RawLibraryOptions;
9
+ export declare function getRawLibrary(library: LibraryOptions): JsLibraryOptions;
10
10
  export declare function getRawChunkLoading(chunkLoading: ChunkLoading): string;
@@ -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;
@@ -54,6 +54,7 @@ const getNormalizedRspackOptions = (config) => {
54
54
  chunkLoading: output.chunkLoading,
55
55
  chunkFilename: output.chunkFilename,
56
56
  crossOriginLoading: output.crossOriginLoading,
57
+ cssHeadDataCompression: output.cssHeadDataCompression,
57
58
  cssFilename: output.cssFilename,
58
59
  cssChunkFilename: output.cssChunkFilename,
59
60
  hotUpdateMainFilename: output.hotUpdateMainFilename,
@@ -282,8 +283,10 @@ const cloneObject = (value) => ({ ...value });
282
283
  const keyedNestedConfig = (value, fn, customKeys) => {
283
284
  const result = value === undefined
284
285
  ? {}
285
- : Object.keys(value).reduce((obj, key) => ((obj[key] = (customKeys && key in customKeys ? customKeys[key] : fn)(value[key])),
286
- obj), {});
286
+ : Object.keys(value).reduce((obj, key) => {
287
+ obj[key] = (customKeys && key in customKeys ? customKeys[key] : fn)(value[key]);
288
+ return obj;
289
+ }, {});
287
290
  if (customKeys) {
288
291
  for (const key of Object.keys(customKeys)) {
289
292
  if (!(key in result)) {