webpack 5.102.0 → 5.102.1

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 (53) hide show
  1. package/lib/ChunkGraph.js +2 -2
  2. package/lib/CodeGenerationResults.js +1 -1
  3. package/lib/Compilation.js +5 -11
  4. package/lib/ContextModule.js +3 -1
  5. package/lib/DefinePlugin.js +1 -1
  6. package/lib/DependencyTemplates.js +1 -1
  7. package/lib/FileSystemInfo.js +9 -12
  8. package/lib/ModuleFilenameHelpers.js +1 -1
  9. package/lib/NormalModule.js +1 -1
  10. package/lib/NormalModuleFactory.js +75 -4
  11. package/lib/RuntimeTemplate.js +10 -1
  12. package/lib/SourceMapDevToolPlugin.js +6 -8
  13. package/lib/asset/AssetBytesGenerator.js +1 -0
  14. package/lib/asset/AssetGenerator.js +2 -3
  15. package/lib/cache/getLazyHashedEtag.js +1 -1
  16. package/lib/config/browserslistTargetHandler.js +77 -76
  17. package/lib/config/defaults.js +7 -2
  18. package/lib/config/target.js +1 -1
  19. package/lib/css/CssModulesPlugin.js +2 -6
  20. package/lib/css/walkCssTokens.js +1 -1
  21. package/lib/dependencies/ContextElementDependency.js +2 -2
  22. package/lib/dependencies/CssLocalIdentifierDependency.js +1 -3
  23. package/lib/dependencies/HarmonyImportDependency.js +5 -2
  24. package/lib/dependencies/ImportContextDependency.js +13 -0
  25. package/lib/dependencies/ImportDependency.js +2 -2
  26. package/lib/dependencies/ImportMetaPlugin.js +1 -1
  27. package/lib/dependencies/WorkerPlugin.js +1 -3
  28. package/lib/ids/HashedModuleIdsPlugin.js +5 -7
  29. package/lib/ids/IdHelpers.js +1 -1
  30. package/lib/javascript/JavascriptModulesPlugin.js +2 -3
  31. package/lib/javascript/JavascriptParser.js +1 -1
  32. package/lib/library/SystemLibraryPlugin.js +15 -5
  33. package/lib/optimize/RealContentHashPlugin.js +5 -3
  34. package/lib/serialization/FileMiddleware.js +1 -1
  35. package/lib/serialization/ObjectMiddleware.js +1 -1
  36. package/lib/stats/DefaultStatsFactoryPlugin.js +1 -1
  37. package/lib/util/Hash.js +35 -5
  38. package/lib/util/create-schema-validation.js +1 -1
  39. package/lib/util/createHash.js +85 -15
  40. package/lib/util/hash/BatchedHash.js +47 -8
  41. package/lib/util/hash/wasm-hash.js +53 -13
  42. package/lib/wasm-async/AsyncWebAssemblyParser.js +0 -9
  43. package/lib/wasm-sync/WebAssemblyParser.js +0 -9
  44. package/lib/web/JsonpChunkLoadingRuntimeModule.js +1 -1
  45. package/package.json +18 -18
  46. package/schemas/WebpackOptions.check.js +1 -1
  47. package/schemas/WebpackOptions.json +16 -3
  48. package/schemas/plugins/ids/HashedModuleIdsPlugin.check.d.ts +7 -0
  49. package/schemas/plugins/ids/HashedModuleIdsPlugin.check.js +6 -0
  50. package/schemas/plugins/{HashedModuleIdsPlugin.json → ids/HashedModuleIdsPlugin.json} +15 -2
  51. package/types.d.ts +590 -196
  52. package/schemas/plugins/HashedModuleIdsPlugin.check.d.ts +0 -7
  53. package/schemas/plugins/HashedModuleIdsPlugin.check.js +0 -6
@@ -5,13 +5,15 @@
5
5
 
6
6
  "use strict";
7
7
 
8
+ const Hash = require("../Hash");
9
+
8
10
  // 65536 is the size of a wasm memory page
9
11
  // 64 is the maximum chunk size for every possible wasm hash implementation
10
12
  // 4 is the maximum number of bytes per char for string encoding (max is utf-8)
11
13
  // ~3 makes sure that it's always a block of 4 chars, so avoid partially encoded bytes for base64
12
14
  const MAX_SHORT_STRING = Math.floor((65536 - 64) / 4) & ~3;
13
15
 
14
- class WasmHash {
16
+ class WasmHash extends Hash {
15
17
  /**
16
18
  * @param {WebAssembly.Instance} instance wasm instance
17
19
  * @param {WebAssembly.Instance[]} instancesPool pool of instances
@@ -19,6 +21,8 @@ class WasmHash {
19
21
  * @param {number} digestSize size of digest returned by wasm
20
22
  */
21
23
  constructor(instance, instancesPool, chunkSize, digestSize) {
24
+ super();
25
+
22
26
  const exports = /** @type {EXPECTED_ANY} */ (instance.exports);
23
27
  exports.init();
24
28
  this.exports = exports;
@@ -35,17 +39,39 @@ class WasmHash {
35
39
  }
36
40
 
37
41
  /**
38
- * @param {Buffer | string} data data
39
- * @param {BufferEncoding=} encoding encoding
40
- * @returns {this} itself
42
+ * Update hash {@link https://nodejs.org/api/crypto.html#crypto_hash_update_data_inputencoding}
43
+ * @overload
44
+ * @param {string | Buffer} data data
45
+ * @returns {Hash} updated hash
46
+ */
47
+ /**
48
+ * Update hash {@link https://nodejs.org/api/crypto.html#crypto_hash_update_data_inputencoding}
49
+ * @overload
50
+ * @param {string} data data
51
+ * @param {string=} inputEncoding data encoding
52
+ * @returns {this} updated hash
41
53
  */
42
- update(data, encoding) {
54
+ /**
55
+ * Update hash {@link https://nodejs.org/api/crypto.html#crypto_hash_update_data_inputencoding}
56
+ * @param {string | Buffer} data data
57
+ * @param {string=} inputEncoding data encoding
58
+ * @returns {this} updated hash
59
+ */
60
+ update(data, inputEncoding) {
43
61
  if (typeof data === "string") {
44
62
  while (data.length > MAX_SHORT_STRING) {
45
- this._updateWithShortString(data.slice(0, MAX_SHORT_STRING), encoding);
63
+ this._updateWithShortString(
64
+ data.slice(0, MAX_SHORT_STRING),
65
+ /** @type {NodeJS.BufferEncoding} */
66
+ (inputEncoding)
67
+ );
46
68
  data = data.slice(MAX_SHORT_STRING);
47
69
  }
48
- this._updateWithShortString(data, encoding);
70
+ this._updateWithShortString(
71
+ data,
72
+ /** @type {NodeJS.BufferEncoding} */
73
+ (inputEncoding)
74
+ );
49
75
  return this;
50
76
  }
51
77
  this._updateWithBuffer(data);
@@ -136,17 +162,31 @@ class WasmHash {
136
162
  }
137
163
 
138
164
  /**
139
- * @param {BufferEncoding} type type
140
- * @returns {Buffer | string} digest
165
+ * Calculates the digest {@link https://nodejs.org/api/crypto.html#crypto_hash_digest_encoding}
166
+ * @overload
167
+ * @returns {Buffer} digest
168
+ */
169
+ /**
170
+ * Calculates the digest {@link https://nodejs.org/api/crypto.html#crypto_hash_digest_encoding}
171
+ * @overload
172
+ * @param {string=} encoding encoding of the return value
173
+ * @returns {string} digest
174
+ */
175
+ /**
176
+ * Calculates the digest {@link https://nodejs.org/api/crypto.html#crypto_hash_digest_encoding}
177
+ * @param {string=} encoding encoding of the return value
178
+ * @returns {string | Buffer} digest
141
179
  */
142
- digest(type) {
180
+ digest(encoding) {
143
181
  const { exports, buffered, mem, digestSize } = this;
144
182
  exports.final(buffered);
145
183
  this.instancesPool.push(this);
146
184
  const hex = mem.toString("latin1", 0, digestSize);
147
- if (type === "hex") return hex;
148
- if (type === "binary" || !type) return Buffer.from(hex, "hex");
149
- return Buffer.from(hex, "hex").toString(type);
185
+ if (encoding === "hex") return hex;
186
+ if (encoding === "binary" || !encoding) return Buffer.from(hex, "hex");
187
+ return Buffer.from(hex, "hex").toString(
188
+ /** @type {NodeJS.BufferEncoding} */ (encoding)
189
+ );
150
190
  }
151
191
  }
152
192
 
@@ -26,15 +26,6 @@ const decoderOpts = {
26
26
  };
27
27
 
28
28
  class WebAssemblyParser extends Parser {
29
- /**
30
- * @param {{}=} options parser options
31
- */
32
- constructor(options) {
33
- super();
34
- this.hooks = Object.freeze({});
35
- this.options = options;
36
- }
37
-
38
29
  /**
39
30
  * @param {string | Buffer | PreparsedAst} source the source to parse
40
31
  * @param {ParserState} state the parser state
@@ -63,15 +63,6 @@ const decoderOpts = {
63
63
  };
64
64
 
65
65
  class WebAssemblyParser extends Parser {
66
- /**
67
- * @param {{}=} options parser options
68
- */
69
- constructor(options) {
70
- super();
71
- this.hooks = Object.freeze({});
72
- this.options = options;
73
- }
74
-
75
66
  /**
76
67
  * @param {string | Buffer | PreparsedAst} source the source to parse
77
68
  * @param {ParserState} state the parser state
@@ -69,7 +69,7 @@ class JsonpChunkLoadingRuntimeModule extends RuntimeModule {
69
69
  if (options && options.baseUri) {
70
70
  return `${RuntimeGlobals.baseURI} = ${JSON.stringify(options.baseUri)};`;
71
71
  }
72
- return `${RuntimeGlobals.baseURI} = (document && document.baseURI) || self.location.href;`;
72
+ return `${RuntimeGlobals.baseURI} = (typeof document !== 'undefined' && document.baseURI) || self.location.href;`;
73
73
  }
74
74
 
75
75
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webpack",
3
- "version": "5.102.0",
3
+ "version": "5.102.1",
4
4
  "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.",
5
5
  "homepage": "https://github.com/webpack/webpack",
6
6
  "bugs": "https://github.com/webpack/webpack/issues",
@@ -89,7 +89,7 @@
89
89
  "@webassemblyjs/wasm-parser": "^1.14.1",
90
90
  "acorn": "^8.15.0",
91
91
  "acorn-import-phases": "^1.0.3",
92
- "browserslist": "^4.24.5",
92
+ "browserslist": "^4.26.3",
93
93
  "chrome-trace-event": "^1.0.2",
94
94
  "enhanced-resolve": "^5.17.3",
95
95
  "es-module-lexer": "^1.2.1",
@@ -101,8 +101,8 @@
101
101
  "loader-runner": "^4.2.0",
102
102
  "mime-types": "^2.1.27",
103
103
  "neo-async": "^2.6.2",
104
- "schema-utils": "^4.3.2",
105
- "tapable": "^2.2.3",
104
+ "schema-utils": "^4.3.3",
105
+ "tapable": "^2.3.0",
106
106
  "terser-webpack-plugin": "^5.3.11",
107
107
  "watchpack": "^2.4.4",
108
108
  "webpack-sources": "^3.3.3"
@@ -110,17 +110,17 @@
110
110
  "devDependencies": {
111
111
  "@babel/core": "^7.27.1",
112
112
  "@babel/preset-react": "^7.27.1",
113
- "@codspeed/core": "^4.0.1",
114
- "@eslint/js": "^9.29.0",
115
- "@eslint/markdown": "^7.1.0",
116
- "@stylistic/eslint-plugin": "^5.2.2",
113
+ "@codspeed/core": "^5.0.1",
114
+ "@eslint/js": "^9.36.0",
115
+ "@eslint/markdown": "^7.3.0",
116
+ "@stylistic/eslint-plugin": "^5.4.0",
117
117
  "@types/glob-to-regexp": "^0.4.4",
118
118
  "@types/graceful-fs": "^4.1.9",
119
119
  "@types/jest": "^30.0.0",
120
120
  "@types/mime-types": "^2.1.4",
121
- "@types/node": "^24.1.0",
121
+ "@types/node": "^24.5.2",
122
122
  "@types/xxhashjs": "^0.2.4",
123
- "assemblyscript": "^0.28.5",
123
+ "assemblyscript": "^0.28.8",
124
124
  "babel-loader": "^10.0.0",
125
125
  "bundle-loader": "^0.5.6",
126
126
  "coffee-loader": "^5.0.0",
@@ -131,13 +131,13 @@
131
131
  "date-fns": "^4.0.0",
132
132
  "es5-ext": "^0.10.53",
133
133
  "es6-promise-polyfill": "^1.2.0",
134
- "eslint": "^9.29.0",
134
+ "eslint": "^9.36.0",
135
135
  "eslint-config-prettier": "^10.1.1",
136
136
  "eslint-config-webpack": "^4.5.1",
137
137
  "eslint-plugin-import": "^2.32.0",
138
138
  "eslint-plugin-jest": "^29.0.1",
139
139
  "eslint-plugin-jsdoc": "^51.2.3",
140
- "eslint-plugin-n": "^17.21.0",
140
+ "eslint-plugin-n": "^17.23.1",
141
141
  "eslint-plugin-prettier": "^5.5.0",
142
142
  "eslint-plugin-unicorn": "^61.0.1",
143
143
  "file-loader": "^6.0.0",
@@ -146,11 +146,11 @@
146
146
  "hash-wasm": "^4.9.0",
147
147
  "husky": "^9.0.11",
148
148
  "istanbul": "^0.4.5",
149
- "jest": "^30.1.2",
150
- "jest-circus": "^30.1.2",
151
- "jest-cli": "^30.1.2",
152
- "jest-diff": "^30.1.2",
153
- "jest-environment-node": "^30.1.2",
149
+ "jest": "^30.2.0",
150
+ "jest-circus": "^30.2.0",
151
+ "jest-cli": "^30.2.0",
152
+ "jest-diff": "^30.2.0",
153
+ "jest-environment-node": "^30.2.0",
154
154
  "jest-junit": "^16.0.0",
155
155
  "json-loader": "^0.5.7",
156
156
  "json5": "^2.1.3",
@@ -184,7 +184,7 @@
184
184
  "toml": "^3.0.0",
185
185
  "tooling": "webpack/tooling#v1.24.3",
186
186
  "ts-loader": "^9.5.1",
187
- "typescript": "^5.9.2",
187
+ "typescript": "^5.9.3",
188
188
  "url-loader": "^4.1.0",
189
189
  "wast-loader": "^1.12.1",
190
190
  "webassembly-feature": "1.3.0",