webpack 5.97.0 → 5.98.0

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 (32) hide show
  1. package/README.md +341 -392
  2. package/lib/Compilation.js +17 -15
  3. package/lib/DefinePlugin.js +7 -1
  4. package/lib/Module.js +4 -4
  5. package/lib/ModuleFilenameHelpers.js +8 -26
  6. package/lib/asset/AssetModulesPlugin.js +2 -2
  7. package/lib/config/defaults.js +12 -3
  8. package/lib/css/CssLoadingRuntimeModule.js +5 -2
  9. package/lib/css/CssModulesPlugin.js +11 -4
  10. package/lib/dependencies/CommonJsImportsParserPlugin.js +30 -0
  11. package/lib/dependencies/CssLocalIdentifierDependency.js +1 -1
  12. package/lib/dependencies/JsonExportsDependency.js +32 -26
  13. package/lib/esm/ModuleChunkLoadingRuntimeModule.js +3 -2
  14. package/lib/hmr/HotModuleReplacementRuntimeModule.js +0 -1
  15. package/lib/javascript/JavascriptModulesPlugin.js +3 -3
  16. package/lib/javascript/JavascriptParser.js +1 -0
  17. package/lib/json/JsonModulesPlugin.js +0 -1
  18. package/lib/json/JsonParser.js +3 -1
  19. package/lib/optimize/SplitChunksPlugin.js +3 -0
  20. package/lib/runtime/AutoPublicPathRuntimeModule.js +1 -1
  21. package/lib/stats/DefaultStatsFactoryPlugin.js +1 -1
  22. package/lib/util/Queue.js +19 -52
  23. package/lib/util/semver.js +18 -8
  24. package/lib/validateSchema.js +4 -7
  25. package/lib/wasm/EnableWasmLoadingPlugin.js +2 -2
  26. package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +2 -2
  27. package/lib/wasm-sync/WebAssemblyModulesPlugin.js +2 -2
  28. package/lib/web/JsonpChunkLoadingRuntimeModule.js +4 -2
  29. package/package.json +15 -16
  30. package/schemas/plugins/JsonModulesPluginParser.check.js +1 -1
  31. package/schemas/plugins/JsonModulesPluginParser.json +4 -0
  32. package/types.d.ts +52 -44
@@ -259,15 +259,25 @@ module.exports.parseRange = str => {
259
259
  const items = str.split(/\s+-\s+/);
260
260
 
261
261
  if (items.length === 1) {
262
- const items =
263
- /** @type {SemVerRangeItem[][]} */
264
- (
265
- str
266
- .trim()
267
- .split(/(?<=[-0-9A-Za-z])\s+/g)
268
- .map(parseSimple)
269
- );
262
+ str = str.trim();
270
263
 
264
+ /** @type {SemVerRangeItem[][]} */
265
+ const items = [];
266
+ const r = /[-0-9A-Za-z]\s+/g;
267
+ var start = 0;
268
+ var match;
269
+ while ((match = r.exec(str))) {
270
+ const end = match.index + 1;
271
+ items.push(
272
+ /** @type {SemVerRangeItem[]} */
273
+ (parseSimple(str.slice(start, end).trim()))
274
+ );
275
+ start = end;
276
+ }
277
+ items.push(
278
+ /** @type {SemVerRangeItem[]} */
279
+ (parseSimple(str.slice(start).trim()))
280
+ );
271
281
  return combine(items, 2);
272
282
  }
273
283
 
@@ -87,7 +87,7 @@ const validateSchema = (schema, options, validationConfiguration) => {
87
87
  children.some(
88
88
  child =>
89
89
  child.keyword === "absolutePath" &&
90
- child.dataPath === ".output.filename"
90
+ child.instancePath === "/output/filename"
91
91
  )
92
92
  ) {
93
93
  return `${formattedError}\nPlease use output.path to specify absolute path and output.filename for the file name.`;
@@ -97,7 +97,7 @@ const validateSchema = (schema, options, validationConfiguration) => {
97
97
  children &&
98
98
  children.some(
99
99
  child =>
100
- child.keyword === "pattern" && child.dataPath === ".devtool"
100
+ child.keyword === "pattern" && child.instancePath === "/devtool"
101
101
  )
102
102
  ) {
103
103
  return (
@@ -108,10 +108,7 @@ const validateSchema = (schema, options, validationConfiguration) => {
108
108
  }
109
109
 
110
110
  if (error.keyword === "additionalProperties") {
111
- const params =
112
- /** @type {import("ajv").AdditionalPropertiesParams} */ (
113
- error.params
114
- );
111
+ const params = error.params;
115
112
  if (
116
113
  Object.prototype.hasOwnProperty.call(
117
114
  DID_YOU_MEAN,
@@ -136,7 +133,7 @@ const validateSchema = (schema, options, validationConfiguration) => {
136
133
  }?`;
137
134
  }
138
135
 
139
- if (!error.dataPath) {
136
+ if (!error.instancePath) {
140
137
  if (params.additionalProperty === "debug") {
141
138
  return (
142
139
  `${formattedError}\n` +
@@ -99,7 +99,7 @@ class EnableWasmLoadingPlugin {
99
99
  new ReadFileCompileWasmPlugin({
100
100
  mangleImports: compiler.options.optimization.mangleWasmImports,
101
101
  import:
102
- compiler.options.output.environment.module &&
102
+ compiler.options.output.module &&
103
103
  compiler.options.output.environment.dynamicImport
104
104
  }).apply(compiler);
105
105
  }
@@ -108,7 +108,7 @@ class EnableWasmLoadingPlugin {
108
108
  const ReadFileCompileAsyncWasmPlugin = require("../node/ReadFileCompileAsyncWasmPlugin");
109
109
  new ReadFileCompileAsyncWasmPlugin({
110
110
  import:
111
- compiler.options.output.environment.module &&
111
+ compiler.options.output.module &&
112
112
  compiler.options.output.environment.dynamicImport
113
113
  }).apply(compiler);
114
114
  }
@@ -11,7 +11,7 @@ const Generator = require("../Generator");
11
11
  const { tryRunOrWebpackError } = require("../HookWebpackError");
12
12
  const { WEBASSEMBLY_MODULE_TYPE_ASYNC } = require("../ModuleTypeConstants");
13
13
  const WebAssemblyImportDependency = require("../dependencies/WebAssemblyImportDependency");
14
- const { compareModulesByIdentifier } = require("../util/comparators");
14
+ const { compareModulesByIdOrIdentifier } = require("../util/comparators");
15
15
  const memoize = require("../util/memoize");
16
16
 
17
17
  /** @typedef {import("webpack-sources").Source} Source */
@@ -146,7 +146,7 @@ class AsyncWebAssemblyModulesPlugin {
146
146
 
147
147
  for (const module of chunkGraph.getOrderedChunkModulesIterable(
148
148
  chunk,
149
- compareModulesByIdentifier
149
+ compareModulesByIdOrIdentifier(chunkGraph)
150
150
  )) {
151
151
  if (module.type === WEBASSEMBLY_MODULE_TYPE_ASYNC) {
152
152
  const filenameTemplate =
@@ -9,7 +9,7 @@ const Generator = require("../Generator");
9
9
  const { WEBASSEMBLY_MODULE_TYPE_SYNC } = require("../ModuleTypeConstants");
10
10
  const WebAssemblyExportImportedDependency = require("../dependencies/WebAssemblyExportImportedDependency");
11
11
  const WebAssemblyImportDependency = require("../dependencies/WebAssemblyImportDependency");
12
- const { compareModulesByIdentifier } = require("../util/comparators");
12
+ const { compareModulesByIdOrIdentifier } = require("../util/comparators");
13
13
  const memoize = require("../util/memoize");
14
14
  const WebAssemblyInInitialChunkError = require("./WebAssemblyInInitialChunkError");
15
15
 
@@ -89,7 +89,7 @@ class WebAssemblyModulesPlugin {
89
89
 
90
90
  for (const module of chunkGraph.getOrderedChunkModulesIterable(
91
91
  chunk,
92
- compareModulesByIdentifier
92
+ compareModulesByIdOrIdentifier(chunkGraph)
93
93
  )) {
94
94
  if (module.type === WEBASSEMBLY_MODULE_TYPE_SYNC) {
95
95
  const filenameTemplate =
@@ -80,7 +80,8 @@ class JsonpChunkLoadingRuntimeModule extends RuntimeModule {
80
80
  chunkLoadingGlobal,
81
81
  hotUpdateGlobal,
82
82
  crossOriginLoading,
83
- scriptType
83
+ scriptType,
84
+ charset
84
85
  }
85
86
  } = compilation;
86
87
  const globalObject = runtimeTemplate.globalObject;
@@ -229,6 +230,7 @@ class JsonpChunkLoadingRuntimeModule extends RuntimeModule {
229
230
  linkPrefetch.call(
230
231
  Template.asString([
231
232
  "var link = document.createElement('link');",
233
+ charset ? "link.charset = 'utf-8';" : "",
232
234
  crossOriginLoading
233
235
  ? `link.crossOrigin = ${JSON.stringify(
234
236
  crossOriginLoading
@@ -268,7 +270,7 @@ class JsonpChunkLoadingRuntimeModule extends RuntimeModule {
268
270
  scriptType && scriptType !== "module"
269
271
  ? `link.type = ${JSON.stringify(scriptType)};`
270
272
  : "",
271
- "link.charset = 'utf-8';",
273
+ charset ? "link.charset = 'utf-8';" : "",
272
274
  `if (${RuntimeGlobals.scriptNonce}) {`,
273
275
  Template.indent(
274
276
  `link.setAttribute("nonce", ${RuntimeGlobals.scriptNonce});`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webpack",
3
- "version": "5.97.0",
3
+ "version": "5.98.0",
4
4
  "author": "Tobias Koppers @sokra",
5
5
  "description": "Packs ECMAScript/CommonJs/AMD modules for the browser. Allows you to split your codebase into multiple bundles, which can be loaded on demand. Supports loaders to preprocess files, i.e. json, jsx, es7, css, less, ... and your custom stuff.",
6
6
  "license": "MIT",
@@ -23,9 +23,9 @@
23
23
  "loader-runner": "^4.2.0",
24
24
  "mime-types": "^2.1.27",
25
25
  "neo-async": "^2.6.2",
26
- "schema-utils": "^3.2.0",
26
+ "schema-utils": "^4.3.0",
27
27
  "tapable": "^2.1.1",
28
- "terser-webpack-plugin": "^5.3.10",
28
+ "terser-webpack-plugin": "^5.3.11",
29
29
  "watchpack": "^2.4.1",
30
30
  "webpack-sources": "^3.2.3"
31
31
  },
@@ -35,15 +35,15 @@
35
35
  }
36
36
  },
37
37
  "devDependencies": {
38
- "@babel/core": "^7.25.8",
38
+ "@babel/core": "^7.26.8",
39
39
  "@babel/preset-react": "^7.25.7",
40
- "@eslint/js": "^9.12.0",
41
- "@stylistic/eslint-plugin": "^2.9.0",
40
+ "@eslint/js": "^9.20.0",
41
+ "@stylistic/eslint-plugin": "^3.1.0",
42
42
  "@types/glob-to-regexp": "^0.4.4",
43
43
  "@types/jest": "^29.5.11",
44
44
  "@types/mime-types": "^2.1.4",
45
45
  "@types/node": "^22.0.0",
46
- "assemblyscript": "^0.27.30",
46
+ "assemblyscript": "^0.27.34",
47
47
  "babel-loader": "^9.1.3",
48
48
  "benchmark": "^2.1.4",
49
49
  "bundle-loader": "^0.5.6",
@@ -55,8 +55,8 @@
55
55
  "date-fns": "^4.0.0",
56
56
  "es5-ext": "^0.10.53",
57
57
  "es6-promise-polyfill": "^1.2.0",
58
- "eslint": "^9.12.0",
59
- "eslint-config-prettier": "^9.1.0",
58
+ "eslint": "^9.20.0",
59
+ "eslint-config-prettier": "^10.0.1",
60
60
  "eslint-plugin-jest": "^28.6.0",
61
61
  "eslint-plugin-jsdoc": "^48.10.1",
62
62
  "eslint-plugin-n": "^17.11.1",
@@ -67,7 +67,6 @@
67
67
  "globals": "^15.4.0",
68
68
  "hash-wasm": "^4.9.0",
69
69
  "husky": "^9.0.11",
70
- "is-ci": "^3.0.0",
71
70
  "istanbul": "^0.4.5",
72
71
  "jest": "^29.7.0",
73
72
  "jest-circus": "^29.7.0",
@@ -87,28 +86,28 @@
87
86
  "mini-svg-data-uri": "^1.2.3",
88
87
  "nyc": "^17.1.0",
89
88
  "open-cli": "^8.0.0",
90
- "prettier": "^3.2.1",
89
+ "prettier": "^3.5.0",
91
90
  "prettier-2": "npm:prettier@^2",
92
91
  "pretty-format": "^29.5.0",
93
92
  "pug": "^3.0.3",
94
93
  "pug-loader": "^2.4.0",
95
94
  "raw-loader": "^4.0.1",
96
- "react": "^18.3.1",
97
- "react-dom": "^18.3.1",
95
+ "react": "^19.0.0",
96
+ "react-dom": "^19.0.0",
98
97
  "rimraf": "^3.0.2",
99
98
  "script-loader": "^0.7.2",
100
99
  "simple-git": "^3.27.0",
101
100
  "strip-ansi": "^6.0.0",
102
101
  "style-loader": "^4.0.0",
103
- "terser": "^5.34.1",
102
+ "terser": "^5.38.1",
104
103
  "toml": "^3.0.0",
105
104
  "tooling": "webpack/tooling#v1.23.5",
106
105
  "ts-loader": "^9.5.1",
107
- "typescript": "^5.6.2",
106
+ "typescript": "^5.7.3",
108
107
  "url-loader": "^4.1.0",
109
108
  "wast-loader": "^1.12.1",
110
109
  "webassembly-feature": "1.3.0",
111
- "webpack-cli": "^5.0.1",
110
+ "webpack-cli": "^6.0.1",
112
111
  "xxhashjs": "^0.2.2",
113
112
  "yamljs": "^0.3.0",
114
113
  "yarn-deduplicate": "^6.0.1"
@@ -3,4 +3,4 @@
3
3
  * DO NOT MODIFY BY HAND.
4
4
  * Run `yarn special-lint-fix` to update
5
5
  */
6
- "use strict";function r(t,{instancePath:e="",parentData:a,parentDataProperty:o,rootData:n=t}={}){if(!t||"object"!=typeof t||Array.isArray(t))return r.errors=[{params:{type:"object"}}],!1;{const e=0;for(const e in t)if("parse"!==e)return r.errors=[{params:{additionalProperty:e}}],!1;if(0===e&&void 0!==t.parse&&!(t.parse instanceof Function))return r.errors=[{params:{}}],!1}return r.errors=null,!0}module.exports=r,module.exports.default=r;
6
+ "use strict";function r(e,{instancePath:t="",parentData:o,parentDataProperty:a,rootData:s=e}={}){if(!e||"object"!=typeof e||Array.isArray(e))return r.errors=[{params:{type:"object"}}],!1;{const t=0;for(const t in e)if("exportsDepth"!==t&&"parse"!==t)return r.errors=[{params:{additionalProperty:t}}],!1;if(0===t){if(void 0!==e.exportsDepth){const t=0;if("number"!=typeof e.exportsDepth)return r.errors=[{params:{type:"number"}}],!1;var n=0===t}else n=!0;if(n)if(void 0!==e.parse){const t=0;if(!(e.parse instanceof Function))return r.errors=[{params:{}}],!1;n=0===t}else n=!0}}return r.errors=null,!0}module.exports=r,module.exports.default=r;
@@ -3,6 +3,10 @@
3
3
  "type": "object",
4
4
  "additionalProperties": false,
5
5
  "properties": {
6
+ "exportsDepth": {
7
+ "description": "The depth of json dependency flagged as `exportInfo`.",
8
+ "type": "number"
9
+ },
6
10
  "parse": {
7
11
  "description": "Function that executes for a module source string and should return json-compatible data.",
8
12
  "instanceof": "Function",
package/types.d.ts CHANGED
@@ -248,19 +248,20 @@ declare interface ArgumentConfig {
248
248
  type: "string" | "number" | "boolean" | "path" | "enum" | "RegExp" | "reset";
249
249
  values?: any[];
250
250
  }
251
+ type ArrayBufferLike = ArrayBuffer | SharedArrayBuffer;
251
252
  type ArrayBufferView =
252
- | Uint8Array
253
- | Uint8ClampedArray
254
- | Uint16Array
255
- | Uint32Array
256
- | Int8Array
257
- | Int16Array
258
- | Int32Array
259
- | BigUint64Array
260
- | BigInt64Array
261
- | Float32Array
262
- | Float64Array
263
- | DataView;
253
+ | Uint8Array<ArrayBufferLike>
254
+ | Uint8ClampedArray<ArrayBufferLike>
255
+ | Uint16Array<ArrayBufferLike>
256
+ | Uint32Array<ArrayBufferLike>
257
+ | Int8Array<ArrayBufferLike>
258
+ | Int16Array<ArrayBufferLike>
259
+ | Int32Array<ArrayBufferLike>
260
+ | BigUint64Array<ArrayBufferLike>
261
+ | BigInt64Array<ArrayBufferLike>
262
+ | Float32Array<ArrayBufferLike>
263
+ | Float64Array<ArrayBufferLike>
264
+ | DataView<ArrayBufferLike>;
264
265
  declare interface Asset {
265
266
  /**
266
267
  * the filename of the asset
@@ -4546,7 +4547,7 @@ declare interface ExportSpec {
4546
4547
  */
4547
4548
  hidden?: boolean;
4548
4549
  }
4549
- type ExportedVariableInfo = string | ScopeInfo | VariableInfo;
4550
+ type ExportedVariableInfo = string | VariableInfo | ScopeInfo;
4550
4551
  declare abstract class ExportsInfo {
4551
4552
  get ownedExports(): Iterable<ExportInfo>;
4552
4553
  get orderedOwnedExports(): Iterable<ExportInfo>;
@@ -6810,7 +6811,7 @@ declare class JavascriptParser extends Parser {
6810
6811
  | undefined
6811
6812
  | ((
6812
6813
  arg0: string,
6813
- arg1: string | ScopeInfo | VariableInfo,
6814
+ arg1: string | VariableInfo | ScopeInfo,
6814
6815
  arg2: () => string[]
6815
6816
  ) => any),
6816
6817
  defined: undefined | ((arg0: string) => any),
@@ -7143,6 +7144,7 @@ declare class JavascriptParser extends Parser {
7143
7144
  | ExportAllDeclarationJavascriptParser
7144
7145
  | ImportExpressionJavascriptParser
7145
7146
  ) => undefined | ImportAttributes;
7147
+ static VariableInfo: typeof VariableInfo;
7146
7148
  }
7147
7149
 
7148
7150
  /**
@@ -7480,6 +7482,10 @@ declare interface KnownAssetInfo {
7480
7482
  declare interface KnownBuildInfo {
7481
7483
  cacheable?: boolean;
7482
7484
  parsed?: boolean;
7485
+ moduleArgument?: string;
7486
+ exportsArgument?: string;
7487
+ strict?: boolean;
7488
+ moduleConcatenationBailout?: string;
7483
7489
  fileDependencies?: LazySet<string>;
7484
7490
  contextDependencies?: LazySet<string>;
7485
7491
  missingDependencies?: LazySet<string>;
@@ -7491,10 +7497,6 @@ declare interface KnownBuildInfo {
7491
7497
  snapshot?: null | Snapshot;
7492
7498
  }
7493
7499
  declare interface KnownBuildMeta {
7494
- moduleArgument?: string;
7495
- exportsArgument?: string;
7496
- strict?: boolean;
7497
- moduleConcatenationBailout?: string;
7498
7500
  exportsType?: "namespace" | "dynamic" | "default" | "flagged";
7499
7501
  defaultObject?: false | "redirect" | "redirect-warn";
7500
7502
  strictHarmonyModule?: boolean;
@@ -13918,7 +13920,7 @@ declare interface RuntimeValueOptions {
13918
13920
  * to create the range of the _parent node_.
13919
13921
  */
13920
13922
  declare interface ScopeInfo {
13921
- definitions: StackedMap<string, ScopeInfo | VariableInfo>;
13923
+ definitions: StackedMap<string, VariableInfo | ScopeInfo>;
13922
13924
  topLevelScope: boolean | "arrow";
13923
13925
  inShorthand: string | boolean;
13924
13926
  inTaggedTemplateTag: boolean;
@@ -15249,7 +15251,12 @@ type UsageStateType = 0 | 1 | 2 | 3 | 4;
15249
15251
  type UsedName = string | false | string[];
15250
15252
  type Value = string | number | boolean | RegExp;
15251
15253
  type ValueCacheVersion = string | Set<string>;
15252
- declare abstract class VariableInfo {
15254
+ declare class VariableInfo {
15255
+ constructor(
15256
+ declaredScope: ScopeInfo,
15257
+ freeName?: string | true,
15258
+ tagInfo?: TagInfo
15259
+ );
15253
15260
  declaredScope: ScopeInfo;
15254
15261
  freeName?: string | true;
15255
15262
  tagInfo?: TagInfo;
@@ -15458,6 +15465,7 @@ declare class WebpackError extends Error {
15458
15465
  * Creates an instance of WebpackError.
15459
15466
  */
15460
15467
  constructor(message?: string);
15468
+ [index: number]: () => string;
15461
15469
  details?: string;
15462
15470
  module?: null | Module;
15463
15471
  loc?: SyntheticDependencyLocation | RealDependencyLocation;
@@ -15749,18 +15757,18 @@ declare interface WriteFile {
15749
15757
  file: PathOrFileDescriptorFs,
15750
15758
  data:
15751
15759
  | string
15752
- | Uint8Array
15753
- | Uint8ClampedArray
15754
- | Uint16Array
15755
- | Uint32Array
15756
- | Int8Array
15757
- | Int16Array
15758
- | Int32Array
15759
- | BigUint64Array
15760
- | BigInt64Array
15761
- | Float32Array
15762
- | Float64Array
15763
- | DataView,
15760
+ | Uint8Array<ArrayBufferLike>
15761
+ | Uint8ClampedArray<ArrayBufferLike>
15762
+ | Uint16Array<ArrayBufferLike>
15763
+ | Uint32Array<ArrayBufferLike>
15764
+ | Int8Array<ArrayBufferLike>
15765
+ | Int16Array<ArrayBufferLike>
15766
+ | Int32Array<ArrayBufferLike>
15767
+ | BigUint64Array<ArrayBufferLike>
15768
+ | BigInt64Array<ArrayBufferLike>
15769
+ | Float32Array<ArrayBufferLike>
15770
+ | Float64Array<ArrayBufferLike>
15771
+ | DataView<ArrayBufferLike>,
15764
15772
  options: WriteFileOptions,
15765
15773
  callback: (arg0: null | NodeJS.ErrnoException) => void
15766
15774
  ): void;
@@ -15768,18 +15776,18 @@ declare interface WriteFile {
15768
15776
  file: PathOrFileDescriptorFs,
15769
15777
  data:
15770
15778
  | string
15771
- | Uint8Array
15772
- | Uint8ClampedArray
15773
- | Uint16Array
15774
- | Uint32Array
15775
- | Int8Array
15776
- | Int16Array
15777
- | Int32Array
15778
- | BigUint64Array
15779
- | BigInt64Array
15780
- | Float32Array
15781
- | Float64Array
15782
- | DataView,
15779
+ | Uint8Array<ArrayBufferLike>
15780
+ | Uint8ClampedArray<ArrayBufferLike>
15781
+ | Uint16Array<ArrayBufferLike>
15782
+ | Uint32Array<ArrayBufferLike>
15783
+ | Int8Array<ArrayBufferLike>
15784
+ | Int16Array<ArrayBufferLike>
15785
+ | Int32Array<ArrayBufferLike>
15786
+ | BigUint64Array<ArrayBufferLike>
15787
+ | BigInt64Array<ArrayBufferLike>
15788
+ | Float32Array<ArrayBufferLike>
15789
+ | Float64Array<ArrayBufferLike>
15790
+ | DataView<ArrayBufferLike>,
15783
15791
  callback: (arg0: null | NodeJS.ErrnoException) => void
15784
15792
  ): void;
15785
15793
  }