@depup/webpack 5.110.1-depup.0 → 5.110.3-depup.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 (70) hide show
  1. package/README.md +4 -4
  2. package/changes.json +3 -3
  3. package/lib/ChunkGraph.js +20 -18
  4. package/lib/Compilation.js +1 -1
  5. package/lib/ConcatenationScope.js +25 -35
  6. package/lib/DotenvPlugin.js +41 -13
  7. package/lib/ExportsInfo.js +10 -0
  8. package/lib/FlagDependencyUsagePlugin.js +8 -2
  9. package/lib/NormalModule.js +13 -20
  10. package/lib/RuntimePlugin.js +3 -0
  11. package/lib/RuntimeTemplate.js +437 -432
  12. package/lib/async-modules/AsyncModuleHelpers.js +10 -4
  13. package/lib/config/defaults.js +26 -16
  14. package/lib/config/normalization.js +18 -8
  15. package/lib/css/CssLoadingRuntimeModule.js +32 -13
  16. package/lib/css/CssModulesPlugin.js +9 -17
  17. package/lib/css/data.js +13 -3
  18. package/lib/css/syntax.js +78 -10
  19. package/lib/dependencies/CommonJsRequireDependency.js +18 -4
  20. package/lib/dependencies/ContextDependencyTemplateAsRequireCall.js +20 -7
  21. package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +10 -4
  22. package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +2 -0
  23. package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +143 -17
  24. package/lib/dependencies/HarmonyImportDependency.js +94 -41
  25. package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +93 -14
  26. package/lib/dependencies/HarmonyImportSideEffectDependency.js +114 -0
  27. package/lib/dependencies/HtmlEntryDependency.js +12 -2
  28. package/lib/dependencies/ImportContextDependency.js +43 -3
  29. package/lib/dependencies/ImportDependency.js +8 -29
  30. package/lib/dependencies/ImportParserPlugin.js +24 -14
  31. package/lib/dependencies/RequireHeaderDependency.js +20 -21
  32. package/lib/dependencies/WorkerAndWorkletPlugin.js +1 -0
  33. package/lib/dependencies/WorkerDependency.js +6 -12
  34. package/lib/dependencies/WorkletDependency.js +7 -11
  35. package/lib/dependencies/importOptionsCheck.js +47 -0
  36. package/lib/errors/DotenvFileError.js +29 -0
  37. package/lib/errors/ImportedBindingAssignmentError.js +30 -0
  38. package/lib/esm/ModuleChunkLoadingPlugin.js +6 -9
  39. package/lib/esm/ModuleChunkLoadingRuntimeModule.js +7 -1
  40. package/lib/html/HtmlModulesPlugin.js +84 -38
  41. package/lib/html/syntax.js +417 -169
  42. package/lib/javascript/JavascriptModulesPlugin.js +5 -10
  43. package/lib/loaders/LoaderRunner.js +33 -5
  44. package/lib/node/ReadFileCompileAsyncWasmPlugin.js +8 -15
  45. package/lib/optimize/ConcatenatedModule.js +46 -7
  46. package/lib/optimize/ConstExportsPlugin.js +5 -0
  47. package/lib/optimize/InlineExports.js +121 -0
  48. package/lib/optimize/RealContentHashPlugin.js +111 -35
  49. package/lib/prefetch/ResourceHintPlugin.js +12 -13
  50. package/lib/runtime/AsyncModuleRuntimeModule.js +5 -1
  51. package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +11 -1
  52. package/lib/schemes/HttpUriPlugin.js +22 -5
  53. package/lib/serialization/FileMiddleware.js +15 -2
  54. package/lib/typescript/TypeScriptPlugin.js +8 -10
  55. package/lib/util/ArrayQueue.js +3 -3
  56. package/lib/util/SourceProcessor.js +24 -8
  57. package/lib/util/URLAbsoluteSpecifier.js +3 -1
  58. package/lib/util/conventions.js +5 -1
  59. package/lib/util/createMappings.js +25 -3
  60. package/lib/util/internalSerializables.js +2 -0
  61. package/lib/util/removeBOM.js +82 -1
  62. package/lib/wasm-async/AsyncWasmCompileRuntimeModule.js +5 -3
  63. package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +5 -3
  64. package/lib/wasm-async/UniversalCompileAsyncWasmPlugin.js +7 -12
  65. package/lib/web/FetchCompileAsyncWasmPlugin.js +10 -6
  66. package/lib/web/FetchCompileWasmPlugin.js +4 -2
  67. package/package.json +7 -7
  68. package/schemas/WebpackOptions.check.js +1 -1
  69. package/schemas/WebpackOptions.json +9 -10
  70. package/types.d.ts +95 -27
@@ -57,7 +57,11 @@ class AsyncModuleRuntimeModule extends HelperRuntimeModule {
57
57
  `${cst} hasUnresolvedAsyncSubgraph = asyncDeps.some((id) => {`,
58
58
  Template.indent([
59
59
  `${cst} cache = __webpack_module_cache__[id];`,
60
- "return !cache || cache[webpackDone] === false;"
60
+ "if (!cache) return true;",
61
+ // A cached entry no longer means finished, and a rejected
62
+ // one is done but its error must still reach the importer.
63
+ `${cst} deps = cache.exports;`,
64
+ "return deps[webpackDone] !== true || deps[webpackError] !== undefined;"
61
65
  ]),
62
66
  "});",
63
67
  "if (hasUnresolvedAsyncSubgraph) {",
@@ -290,7 +290,17 @@ class MakeOptimizedDeferredNamespaceObjectRuntimeModule extends HelperRuntimeMod
290
290
  ]),
291
291
  "};",
292
292
  hasAsync
293
- ? `if(isAsync) obj[${RuntimeGlobals.deferredModuleAsyncTransitiveDependenciesSymbol}] = asyncDeps;`
293
+ ? // `GatherAsynchronousTransitiveDependencies` skips a module that is
294
+ // already evaluating, and evaluates the rest right here.
295
+ `if(isAsync) obj[${RuntimeGlobals.deferredModuleAsyncTransitiveDependenciesSymbol}] = asyncDeps.filter(${runtimeTemplate.basicFunction(
296
+ "id",
297
+ [
298
+ `${cst} dep = __webpack_module_cache__[id];`,
299
+ "if (dep && (dep.evaluating || dep.evaluatingAsync)) return false;",
300
+ "r(id);",
301
+ "return true;"
302
+ ]
303
+ )});`
294
304
  : "",
295
305
  "return obj;"
296
306
  ]),
@@ -149,7 +149,8 @@ const verifyIntegrity = (content, integrity) => {
149
149
  };
150
150
 
151
151
  /**
152
- * Parses key value pairs.
152
+ * Parses key value pairs. Keys are lower-cased because HTTP directive names are
153
+ * case-insensitive; values are kept verbatim (they may be quoted field lists).
153
154
  * @param {string} str input
154
155
  * @returns {Record<string, string>} parsed
155
156
  */
@@ -159,11 +160,11 @@ const parseKeyValuePairs = (str) => {
159
160
  for (const item of str.split(",")) {
160
161
  const i = item.indexOf("=");
161
162
  if (i >= 0) {
162
- const key = item.slice(0, i).trim();
163
+ const key = item.slice(0, i).trim().toLowerCase();
163
164
  const value = item.slice(i + 1).trim();
164
165
  result[key] = value;
165
166
  } else {
166
- const key = item.trim();
167
+ const key = item.trim().toLowerCase();
167
168
  if (!key) continue;
168
169
  result[key] = key;
169
170
  }
@@ -186,7 +187,9 @@ const parseCacheControl = (cacheControl, requestTime) => {
186
187
  let validUntil = 0;
187
188
  if (cacheControl) {
188
189
  const parsed = parseKeyValuePairs(cacheControl);
189
- if (parsed["no-cache"]) storeCache = storeLock = false;
190
+ if (parsed["no-cache"] || parsed["no-store"]) {
191
+ storeCache = storeLock = false;
192
+ }
190
193
  if (parsed["max-age"] && !Number.isNaN(Number(parsed["max-age"]))) {
191
194
  validUntil = requestTime + Number(parsed["max-age"]) * 1000;
192
195
  }
@@ -984,7 +987,11 @@ class HttpUriPlugin {
984
987
  /** @type {Buffer[]} */
985
988
  const bufferArr = [];
986
989
 
987
- const contentEncoding = res.headers["content-encoding"];
990
+ // content codings are case-insensitive tokens
991
+ const contentEncodingHeader = res.headers["content-encoding"];
992
+ const contentEncoding =
993
+ contentEncodingHeader &&
994
+ contentEncodingHeader.trim().toLowerCase();
988
995
  /** @type {Readable} */
989
996
  let stream = res;
990
997
  if (contentEncoding === "gzip") {
@@ -994,6 +1001,16 @@ class HttpUriPlugin {
994
1001
  } else if (contentEncoding === "deflate") {
995
1002
  stream = stream.pipe(createInflate());
996
1003
  }
1004
+ if (stream !== res) {
1005
+ // a decompressor error never reaches the request's handler
1006
+ stream.once("error", (err) => {
1007
+ logger.log(
1008
+ `GET ${url} [${res.statusCode}] (invalid encoding)`
1009
+ );
1010
+ err.message += `\nwhile decompressing ${url}`;
1011
+ callback(err);
1012
+ });
1013
+ }
997
1014
 
998
1015
  stream.on(
999
1016
  "data",
@@ -549,9 +549,13 @@ class FileMiddleware extends SerializerMiddleware {
549
549
  });
550
550
  }
551
551
  if (compression) {
552
- pipeline(compression, stream, reject);
552
+ // resolve on the pipeline, not on the transform's "finish":
553
+ // the latter fires before the destination has flushed
554
+ pipeline(compression, stream, (err) => {
555
+ if (err) return reject(err);
556
+ resolve();
557
+ });
553
558
  stream = compression;
554
- stream.on("finish", () => resolve());
555
559
  } else {
556
560
  stream.on("error", (err) => reject(err));
557
561
  stream.on("finish", () => resolve());
@@ -793,6 +797,15 @@ class FileMiddleware extends SerializerMiddleware {
793
797
  });
794
798
  return;
795
799
  }
800
+ // a file truncated after `stat` reads 0 bytes forever
801
+ if (bytesRead === 0 && remaining > 0) {
802
+ this.fs.close(fd, (err) => {
803
+ reject(
804
+ err || new Error(`Unexpected end of file ${file}`)
805
+ );
806
+ });
807
+ return;
808
+ }
796
809
  /** @type {number} */
797
810
  (currentBufferUsed) += bytesRead;
798
811
  remaining -= bytesRead;
@@ -14,7 +14,7 @@ const {
14
14
  } = require("../ModuleTypeConstants");
15
15
  const NormalModule = require("../NormalModule");
16
16
  const memoize = require("../util/memoize");
17
- const removeBOM = require("../util/removeBOM");
17
+ const { removeBOMFromResult } = require("../util/removeBOM");
18
18
 
19
19
  const getModuleBuildError = memoize(() =>
20
20
  require("../errors/ModuleBuildError")
@@ -133,15 +133,11 @@ const stripTypes = (input) => {
133
133
  };
134
134
 
135
135
  /**
136
- * Coerce a Buffer-or-string source to a UTF-8 string, dropping any BOM.
137
136
  * @param {string | Buffer} source raw source from the loader pipeline
138
- * @returns {string} UTF-8 string without BOM
137
+ * @returns {string} UTF-8 string
139
138
  */
140
- const toBomFreeString = (source) => {
141
- const text = Buffer.isBuffer(source) ? source.toString("utf8") : source;
142
- const stripped = removeBOM(text);
143
- return typeof stripped === "string" ? stripped : stripped.toString("utf8");
144
- };
139
+ const asString = (source) =>
140
+ Buffer.isBuffer(source) ? source.toString("utf8") : source;
145
141
 
146
142
  class TypeScriptPlugin {
147
143
  /**
@@ -181,8 +177,10 @@ class TypeScriptPlugin {
181
177
  throw new (getModuleBuildError())(new Error(NODE_API_MISSING));
182
178
  }
183
179
 
184
- const [rawSource, loaderSourceMap, ...rest] = result;
185
- const preStripSource = toBomFreeString(rawSource);
180
+ // A BOM must be off the source before it is stripped of types, and its
181
+ // map moved with it.
182
+ const [rawSource, loaderSourceMap, ...rest] = removeBOMFromResult(result);
183
+ const preStripSource = asString(rawSource);
186
184
  const strippedSource = stripTypes(preStripSource);
187
185
 
188
186
  const needSourceMap = module.useSourceMap || module.useSimpleSourceMap;
@@ -90,11 +90,11 @@ class ArrayQueue {
90
90
  [Symbol.iterator]() {
91
91
  return {
92
92
  next: () => {
93
- const item = this.dequeue();
94
- if (item) {
93
+ // length, not truthiness: a queued `0`/`false`/`undefined` is a value
94
+ if (this.length > 0) {
95
95
  return {
96
96
  done: false,
97
- value: item
97
+ value: /** @type {T} */ (this.dequeue())
98
98
  };
99
99
  }
100
100
  return {
@@ -99,6 +99,23 @@ const expandDeferredWrites = (text, resolve, infix) => {
99
99
  return out + text.slice(from);
100
100
  };
101
101
 
102
+ /**
103
+ * The text this print spells with every deferred write declined: each marker
104
+ * replaced by what would stand there had no renderer answered. What a print
105
+ * verifying itself by re-parsing has to read, since a marker otherwise parses
106
+ * as text where its node stood. `build` rather than `source` so a write inside
107
+ * an attribute comes back escaped for where it sits.
108
+ * @param {string} text the printed output, holding this print's markers
109
+ * @param {DeferredWrite[]} writes what the print deferred, indexed by id
110
+ * @returns {string} the text with every marker put back
111
+ */
112
+ const declineDeferredWrites = (text, writes) =>
113
+ expandDeferredWrites(
114
+ text,
115
+ (id) => (id < writes.length ? writes[id].build(undefined) : undefined),
116
+ deferredInfix
117
+ );
118
+
102
119
  /**
103
120
  * Babel-style visitor map keyed by a numeric node-type discriminator; a bucket
104
121
  * is a function (enter-only) or `{ enter?, exit? }`.
@@ -389,16 +406,14 @@ class PrintContext {
389
406
  _growStore(need) {
390
407
  // From empty: a context that prints one inline `style=""` must not pay for
391
408
  // a stylesheet's worth of columns.
392
- const size = Math.max(need, this._storeText.length * 2, 16);
393
- // Appended, which keeps the column packed for the read every composed child
394
- // makes, and carries what it already holds across in the same pass.
395
- const held = this._storeText;
396
- const text = [];
397
- for (let i = 0; i < held.length; i++) text.push(held[i]);
398
- for (let i = held.length; i < size; i++) text.push("");
409
+ const text = this._storeText;
410
+ const size = Math.max(need, text.length * 2, 16);
411
+ // Appended in place: `push` keeps the column packed for the read every
412
+ // composed child makes, and what it already holds never moves — where
413
+ // filling a second array would copy every slot again at each growth.
414
+ for (let i = text.length; i < size; i++) text.push("");
399
415
  const gen = new Int32Array(size);
400
416
  gen.set(this._storeGen);
401
- this._storeText = text;
402
417
  this._storeGen = gen;
403
418
  }
404
419
 
@@ -1142,4 +1157,5 @@ class SourceProcessor {
1142
1157
  SourceProcessor.PrintContext = PrintContext;
1143
1158
 
1144
1159
  module.exports = SourceProcessor;
1160
+ module.exports.declineDeferredWrites = declineDeferredWrites;
1145
1161
  module.exports.deferredWrite = deferredWrite;
@@ -17,6 +17,7 @@ const _0CharCode = "0".charCodeAt(0);
17
17
  const _9CharCode = "9".charCodeAt(0);
18
18
  const plusCharCode = "+".charCodeAt(0);
19
19
  const hyphenCharCode = "-".charCodeAt(0);
20
+ const dotCharCode = ".".charCodeAt(0);
20
21
  const colonCharCode = ":".charCodeAt(0);
21
22
  const hashCharCode = "#".charCodeAt(0);
22
23
  const queryCharCode = "?".charCodeAt(0);
@@ -46,7 +47,8 @@ function getScheme(specifier) {
46
47
  (ch >= aUpperCaseCharCode && ch <= zUpperCaseCharCode) ||
47
48
  (ch >= _0CharCode && ch <= _9CharCode) ||
48
49
  ch === plusCharCode ||
49
- ch === hyphenCharCode
50
+ ch === hyphenCharCode ||
51
+ ch === dotCharCode
50
52
  ) {
51
53
  if (++i === specifier.length) return;
52
54
  ch = specifier.charCodeAt(i);
@@ -115,7 +115,11 @@ module.exports.cssExportConvention = (input, convention) => {
115
115
  const set = new Set();
116
116
  if (typeof convention === "function") {
117
117
  const result = convention(input);
118
- const validate = (/** @type {string} */ name) => {
118
+ /**
119
+ * @param {string} name name returned by the convention function
120
+ * @returns {void}
121
+ */
122
+ const validate = (name) => {
119
123
  if (typeof name !== "string" || name.length === 0) {
120
124
  throw new Error(
121
125
  `exportsConvention function must return a non-empty string or an array of non-empty strings, got ${safeStringify(result)}`
@@ -13,9 +13,9 @@
13
13
  * while richer call sites can pass arrays of segments.
14
14
  *
15
15
  * TODO move this encoder into `webpack-sources` and replace the body of this
16
- * file with re-exports. The public shape (`encodeVLQ`, `encodeMappings(lines)`,
17
- * `MappingSegment`, `LineMappings`) is intended to match what would land
18
- * upstream so call sites don't have to change.
16
+ * file with re-exports. The public shape (`encodeVLQ`, `decodeVLQ`,
17
+ * `encodeMappings(lines)`, `MappingSegment`, `LineMappings`) is intended to
18
+ * match what would land upstream so call sites don't have to change.
19
19
  */
20
20
 
21
21
  const VLQ_BASE64 =
@@ -38,6 +38,27 @@ const encodeVLQ = (value) => {
38
38
  return result;
39
39
  };
40
40
 
41
+ /**
42
+ * Decode one base64 VLQ value per the source-map V3 spec.
43
+ * @param {string} mappings a VLQ encoded `mappings` string
44
+ * @param {number} start index of the value's first character
45
+ * @returns {{ value: number, end: number }} the decoded value and the index just past it; `end` equals `start` when there is no valid value at `start`
46
+ */
47
+ const decodeVLQ = (mappings, start) => {
48
+ let value = 0;
49
+ let shift = 0;
50
+ let index = start;
51
+ let digit;
52
+ do {
53
+ digit = index < mappings.length ? VLQ_BASE64.indexOf(mappings[index]) : -1;
54
+ if (digit < 0) return { value: 0, end: start };
55
+ value += (digit & 0x1f) << shift;
56
+ shift += 5;
57
+ index++;
58
+ } while (digit & 0x20);
59
+ return { value: value & 1 ? -(value >>> 1) : value >>> 1, end: index };
60
+ };
61
+
41
62
  /**
42
63
  * @typedef {object} MappingSegment
43
64
  * @property {number=} generatedColumn 0-based generated column (defaults to 0)
@@ -114,5 +135,6 @@ const encodeMappings = (lines) => {
114
135
  return encodedLines.join(";");
115
136
  };
116
137
 
138
+ module.exports.decodeVLQ = decodeVLQ;
117
139
  module.exports.encodeMappings = encodeMappings;
118
140
  module.exports.encodeVLQ = encodeVLQ;
@@ -211,6 +211,8 @@ module.exports = {
211
211
  "errors/EnvironmentNotSupportAsyncWarning": () =>
212
212
  require("../errors/EnvironmentNotSupportAsyncWarning"),
213
213
  "errors/HookWebpackError": () => require("../errors/HookWebpackError"),
214
+ "errors/ImportedBindingAssignmentError": () =>
215
+ require("../errors/ImportedBindingAssignmentError"),
214
216
  "errors/InvalidDependenciesModuleWarning": () =>
215
217
  require("../errors/InvalidDependenciesModuleWarning"),
216
218
  "errors/JSONParseError": () => require("../errors/JSONParseError"),
@@ -5,12 +5,17 @@
5
5
 
6
6
  "use strict";
7
7
 
8
+ const { decodeVLQ, encodeVLQ } = require("./createMappings");
9
+
10
+ /** @import { RawSourceMap } from "webpack-sources" */
11
+ /** @import { Result } from "../NormalModule" */
12
+
8
13
  /**
9
14
  * Returns result without BOM.
10
15
  * @param {string | Buffer} strOrBuffer string or buffer
11
16
  * @returns {string | Buffer} result without BOM
12
17
  */
13
- module.exports = (strOrBuffer) => {
18
+ const removeBOM = (strOrBuffer) => {
14
19
  if (typeof strOrBuffer === "string" && strOrBuffer.charCodeAt(0) === 0xfeff) {
15
20
  return strOrBuffer.slice(1);
16
21
  } else if (
@@ -24,3 +29,79 @@ module.exports = (strOrBuffer) => {
24
29
 
25
30
  return strOrBuffer;
26
31
  };
32
+
33
+ /**
34
+ * A BOM occupies generated column 0 of the first line, so a map describing
35
+ * BOM-prefixed content starts that line at column 1 or later. Removing the BOM
36
+ * moves the line one column left; the segments after the first are encoded
37
+ * relative to it, so only the first is rewritten. A map already starting at
38
+ * column 0 describes the content without its BOM and is left alone.
39
+ * @param {string} mappings VLQ encoded `mappings` of a map for BOM-prefixed content
40
+ * @returns {string} `mappings` for the same content without its BOM
41
+ */
42
+ const shiftMappings = (mappings) => {
43
+ const { value, end } = decodeVLQ(mappings, 0);
44
+ if (end === 0 || value <= 0) return mappings;
45
+ return encodeVLQ(value - 1) + mappings.slice(end);
46
+ };
47
+
48
+ /**
49
+ * Adjust a source map that accompanied BOM-prefixed content for the removal of
50
+ * that BOM. Anything without VLQ `mappings` is passed through untouched, as is
51
+ * a map declaring a version other than 3 — earlier versions spell `mappings`
52
+ * differently. A map that declares no version at all is taken as version 3.
53
+ * @param {(string | RawSourceMap)=} sourceMap the map, as an object or as JSON
54
+ * @returns {(string | RawSourceMap)=} the adjusted map
55
+ */
56
+ const adjustSourceMapForRemovedBOM = (sourceMap) => {
57
+ if (!sourceMap) return sourceMap;
58
+
59
+ if (typeof sourceMap === "string") {
60
+ /** @type {RawSourceMap} */
61
+ let parsed;
62
+ try {
63
+ parsed = JSON.parse(sourceMap);
64
+ } catch (_err) {
65
+ return sourceMap;
66
+ }
67
+ const adjusted = adjustSourceMapForRemovedBOM(parsed);
68
+ return adjusted === parsed ? sourceMap : JSON.stringify(adjusted);
69
+ }
70
+
71
+ if (sourceMap.version !== undefined && sourceMap.version !== 3) {
72
+ return sourceMap;
73
+ }
74
+
75
+ if (typeof sourceMap.mappings !== "string") return sourceMap;
76
+
77
+ const mappings = shiftMappings(sourceMap.mappings);
78
+
79
+ return mappings === sourceMap.mappings
80
+ ? sourceMap
81
+ : { ...sourceMap, mappings };
82
+ };
83
+
84
+ /**
85
+ * @param {Result} result a loader result: content, an optional source map, extra info
86
+ * @returns {Result} the result with a leading BOM removed from its content and its source map kept in sync
87
+ */
88
+ const removeBOMFromResult = (result) => {
89
+ const content = result[0];
90
+ const withoutBOM = removeBOM(content);
91
+
92
+ if (withoutBOM === content) return result;
93
+
94
+ // Copied rather than rebuilt, so a result carrying no source map keeps its
95
+ // arity.
96
+ const adjusted = /** @type {Result} */ ([...result]);
97
+
98
+ adjusted[0] = withoutBOM;
99
+
100
+ if (adjusted[1]) adjusted[1] = adjustSourceMapForRemovedBOM(adjusted[1]);
101
+
102
+ return adjusted;
103
+ };
104
+
105
+ module.exports.adjustSourceMapForRemovedBOM = adjustSourceMapForRemovedBOM;
106
+ module.exports.removeBOM = removeBOM;
107
+ module.exports.removeBOMFromResult = removeBOMFromResult;
@@ -11,11 +11,12 @@ const Template = require("../Template");
11
11
  const { fullHashPathData } = require("../wasm/wasmModuleFilename");
12
12
 
13
13
  /** @import Chunk from "../Chunk" */
14
+ /** @import ChunkGraph from "../ChunkGraph" */
14
15
  /** @import Compilation from "../Compilation" */
15
16
  /** @import { RuntimeSpec } from "../util/runtime" */
16
17
 
17
18
  /** @typedef {(wasmModuleSrcPath: string) => string} GenerateBeforeLoadBinaryCode */
18
- /** @typedef {(wasmModuleSrcPath: string, runtime: RuntimeSpec) => string} GenerateLoadBinaryCode */
19
+ /** @typedef {(wasmModuleSrcPath: string, runtime: RuntimeSpec, analyzable: boolean) => string} GenerateLoadBinaryCode */
19
20
  /** @typedef {() => string} GenerateBeforeCompileStreaming */
20
21
 
21
22
  /**
@@ -69,7 +70,7 @@ class AsyncWasmCompileRuntimeModule extends RuntimeModule {
69
70
  // Analyzable output bakes the binary's URL into the call site instead.
70
71
  const analyzable = runtimeTemplate.supportsAnalyzable(
71
72
  "wasm",
72
- undefined,
73
+ /** @type {ChunkGraph} */ (this.chunkGraph),
73
74
  undefined,
74
75
  chunk.runtime
75
76
  );
@@ -92,7 +93,8 @@ class AsyncWasmCompileRuntimeModule extends RuntimeModule {
92
93
 
93
94
  const loader = this.generateLoadBinaryCode(
94
95
  wasmModuleSrcPath,
95
- chunk.runtime
96
+ chunk.runtime,
97
+ analyzable
96
98
  );
97
99
 
98
100
  // Fallback path: fetch -> arrayBuffer -> WebAssembly.compile
@@ -11,11 +11,12 @@ const Template = require("../Template");
11
11
  const { fullHashPathData } = require("../wasm/wasmModuleFilename");
12
12
 
13
13
  /** @import Chunk from "../Chunk" */
14
+ /** @import ChunkGraph from "../ChunkGraph" */
14
15
  /** @import Compilation from "../Compilation" */
15
16
  /** @import { RuntimeSpec } from "../util/runtime" */
16
17
 
17
18
  /** @typedef {(wasmModuleSrcPath: string) => string} GenerateBeforeLoadBinaryCode */
18
- /** @typedef {(wasmModuleSrcPath: string, runtime: RuntimeSpec) => string} GenerateLoadBinaryCode */
19
+ /** @typedef {(wasmModuleSrcPath: string, runtime: RuntimeSpec, analyzable: boolean) => string} GenerateLoadBinaryCode */
19
20
  /** @typedef {() => string} GenerateBeforeInstantiateStreaming */
20
21
 
21
22
  /**
@@ -70,7 +71,7 @@ class AsyncWasmLoadingRuntimeModule extends RuntimeModule {
70
71
  // Analyzable output bakes the binary's URL into the call site instead.
71
72
  const analyzable = runtimeTemplate.supportsAnalyzable(
72
73
  "wasm",
73
- undefined,
74
+ /** @type {ChunkGraph} */ (this.chunkGraph),
74
75
  undefined,
75
76
  chunk.runtime
76
77
  );
@@ -93,7 +94,8 @@ class AsyncWasmLoadingRuntimeModule extends RuntimeModule {
93
94
 
94
95
  const loader = this.generateLoadBinaryCode(
95
96
  wasmModuleSrcPath,
96
- chunk.runtime
97
+ chunk.runtime,
98
+ analyzable
97
99
  );
98
100
  const fallback = [
99
101
  `.then(${runtimeTemplate.returningFunction("x.arrayBuffer()", "x")})`,
@@ -67,31 +67,26 @@ class UniversalCompileAsyncWasmPlugin {
67
67
  // per call: it depends on parse results, so it is not settled while the plugin
68
68
  // is being applied.
69
69
  /**
70
- * @param {RuntimeSpec} runtime the runtime this loader serves
70
+ * @param {boolean} analyzable whether the call site bakes a complete URL
71
71
  * @returns {string} the argument to hand the reader
72
72
  */
73
- const wasmUrlArg = (runtime) =>
74
- compilation.runtimeTemplate.supportsAnalyzable(
75
- "wasm",
76
- undefined,
77
- undefined,
78
- runtime
79
- )
73
+ const wasmUrlArg = (analyzable) =>
74
+ analyzable
80
75
  ? "wasmUrl"
81
76
  : compilation.runtimeTemplate.importMetaUrl("wasmUrl");
82
77
  /**
83
78
  * Generates the runtime expression that fetches the binary in browsers
84
79
  * or reads it from the filesystem in Node.js.
85
- * @type {(path: string, runtime: RuntimeSpec) => string}
80
+ * @type {(path: string, runtime: RuntimeSpec, analyzable: boolean) => string}
86
81
  */
87
- const generateLoadBinaryCode = (path, runtime) =>
82
+ const generateLoadBinaryCode = (path, runtime, analyzable) =>
88
83
  Template.asString([
89
84
  "(useFetch",
90
- Template.indent([`? fetch(${wasmUrlArg(runtime)})`]),
85
+ Template.indent([`? fetch(${wasmUrlArg(analyzable)})`]),
91
86
  Template.indent([
92
87
  ": Promise.all([import('fs'), import('url')]).then(([{ readFile }, { URL }]) => new Promise((resolve, reject) => {",
93
88
  Template.indent([
94
- `readFile(${wasmUrlArg(runtime)}, (err, buffer) => {`,
89
+ `readFile(${wasmUrlArg(analyzable)}, (err, buffer) => {`,
95
90
  Template.indent([
96
91
  "if (err) return reject(err);",
97
92
  "",
@@ -91,12 +91,14 @@ class FetchCompileAsyncWasmPlugin {
91
91
  }
92
92
  const baked = compilation.runtimeTemplate.supportsAnalyzable(
93
93
  "wasm",
94
- undefined,
94
+ chunkGraph,
95
95
  undefined,
96
96
  chunk.runtime
97
97
  );
98
- const analyzable =
99
- compilation.runtimeTemplate.supportsAnalyzable("wasm-relative");
98
+ const analyzable = compilation.runtimeTemplate.supportsAnalyzable(
99
+ "wasm-relative",
100
+ chunkGraph
101
+ );
100
102
  // A baked URL carries the public path already, and a settled one is written
101
103
  // out below; only a path nothing but the global knows asks for it.
102
104
  const constant =
@@ -151,12 +153,14 @@ class FetchCompileAsyncWasmPlugin {
151
153
  }
152
154
  const baked = compilation.runtimeTemplate.supportsAnalyzable(
153
155
  "wasm",
154
- undefined,
156
+ chunkGraph,
155
157
  undefined,
156
158
  chunk.runtime
157
159
  );
158
- const analyzable =
159
- compilation.runtimeTemplate.supportsAnalyzable("wasm-relative");
160
+ const analyzable = compilation.runtimeTemplate.supportsAnalyzable(
161
+ "wasm-relative",
162
+ chunkGraph
163
+ );
160
164
  // A baked URL carries the public path already, and a settled one is written
161
165
  // out below; only a path nothing but the global knows asks for it.
162
166
  const constant =
@@ -99,8 +99,10 @@ class FetchCompileWasmPlugin {
99
99
  return;
100
100
  }
101
101
  set.add(RuntimeGlobals.moduleCache);
102
- const analyzable =
103
- compilation.runtimeTemplate.supportsAnalyzable("wasm-relative");
102
+ const analyzable = compilation.runtimeTemplate.supportsAnalyzable(
103
+ "wasm-relative",
104
+ chunkGraph
105
+ );
104
106
  const constant = analyzable
105
107
  ? undefined
106
108
  : compilation.runtimeTemplate.constantPublicPath();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@depup/webpack",
3
- "version": "5.110.1-depup.0",
3
+ "version": "5.110.3-depup.0",
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. (with updated dependencies)",
5
5
  "homepage": "https://github.com/webpack/webpack",
6
6
  "bugs": "https://github.com/webpack/webpack/issues",
@@ -109,14 +109,14 @@
109
109
  "@webassemblyjs/wasm-edit": "^1.14.1",
110
110
  "@webassemblyjs/wasm-parser": "^1.14.1",
111
111
  "acorn": "^8.18.0",
112
- "browserslist": "^4.28.8",
112
+ "browserslist": "^4.28.9",
113
113
  "chrome-trace-event": "^1.0.4",
114
114
  "enhanced-resolve": "^5.24.5",
115
115
  "es-module-lexer": "^2.3.2",
116
116
  "events": "^3.3.0",
117
117
  "graceful-fs": "^4.2.11",
118
118
  "mime-db": "^1.54.0",
119
- "minimizer-webpack-plugin": "^5.8.0",
119
+ "minimizer-webpack-plugin": "^5.9.0",
120
120
  "neo-async": "^2.6.2",
121
121
  "schema-utils": "^4.3.3",
122
122
  "tapable": "^2.3.3",
@@ -249,7 +249,7 @@
249
249
  },
250
250
  "browserslist": {
251
251
  "from": "^4.28.1",
252
- "to": "^4.28.8"
252
+ "to": "^4.28.9"
253
253
  },
254
254
  "chrome-trace-event": {
255
255
  "from": "^1.0.2",
@@ -269,7 +269,7 @@
269
269
  },
270
270
  "minimizer-webpack-plugin": {
271
271
  "from": "^5.7.0",
272
- "to": "^5.8.0"
272
+ "to": "^5.9.0"
273
273
  },
274
274
  "tapable": {
275
275
  "from": "^2.3.0",
@@ -278,8 +278,8 @@
278
278
  },
279
279
  "depsUpdated": 9,
280
280
  "originalPackage": "webpack",
281
- "originalVersion": "5.110.1",
282
- "processedAt": "2026-08-30T01:01:33.378Z",
281
+ "originalVersion": "5.110.3",
282
+ "processedAt": "2026-09-06T01:01:07.553Z",
283
283
  "smokeTest": "passed"
284
284
  }
285
285
  }