@depup/webpack 5.109.0-depup.0 → 5.109.2-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 (62) hide show
  1. package/README.md +4 -4
  2. package/bin/webpack.js +12 -0
  3. package/changes.json +4 -4
  4. package/lib/ChunkGraph.js +17 -15
  5. package/lib/CleanPlugin.js +11 -9
  6. package/lib/CompatibilityPlugin.js +31 -0
  7. package/lib/Compilation.js +21 -5
  8. package/lib/Compiler.js +16 -4
  9. package/lib/DefinePlugin.js +47 -20
  10. package/lib/ExportsInfo.js +22 -5
  11. package/lib/ExternalModule.js +10 -7
  12. package/lib/FileSystemInfo.js +126 -26
  13. package/lib/FlagDependencyUsagePlugin.js +33 -12
  14. package/lib/InitFragment.js +20 -32
  15. package/lib/ModuleFilenameHelpers.js +13 -2
  16. package/lib/NormalModule.js +80 -71
  17. package/lib/NormalModuleFactory.js +8 -2
  18. package/lib/RuntimePlugin.js +40 -113
  19. package/lib/Template.js +23 -3
  20. package/lib/cache/PackFileCacheStrategy.js +259 -5
  21. package/lib/config/defaults.js +21 -2
  22. package/lib/container/HoistContainerReferencesPlugin.js +47 -55
  23. package/lib/container/ModuleFederationPlugin.js +15 -9
  24. package/lib/css/CssGenerator.js +8 -2
  25. package/lib/css/CssLoadingRuntimeModule.js +25 -12
  26. package/lib/css/CssModulesPlugin.js +29 -18
  27. package/lib/css/CssParser.js +135 -50
  28. package/lib/css/syntax.js +862 -765
  29. package/lib/dependencies/CommonJsExportRequireDependency.js +19 -0
  30. package/lib/dependencies/CommonJsFullRequireDependency.js +33 -4
  31. package/lib/dependencies/CommonJsImportsParserPlugin.js +2 -0
  32. package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +2 -1
  33. package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +17 -9
  34. package/lib/dependencies/HarmonyImportDependency.js +1 -1
  35. package/lib/dependencies/HarmonyImportGuard.js +2 -1
  36. package/lib/dependencies/HarmonyImportSpecifierDependency.js +10 -7
  37. package/lib/esm/ModuleChunkLoadingRuntimeModule.js +15 -9
  38. package/lib/hmr/lazyCompilationBackend.js +19 -4
  39. package/lib/html/HtmlGenerator.js +23 -3
  40. package/lib/html/HtmlModulesPlugin.js +30 -12
  41. package/lib/html/syntax.js +2485 -2399
  42. package/lib/ids/IdHelpers.js +24 -10
  43. package/lib/javascript/JavascriptModulesPlugin.js +83 -49
  44. package/lib/javascript/JavascriptParser.js +49 -13
  45. package/lib/javascript/syntax.js +700 -43
  46. package/lib/node/ReadFileCompileAsyncWasmPlugin.js +10 -2
  47. package/lib/node/ReadFileCompileWasmPlugin.js +10 -2
  48. package/lib/optimize/AggressiveMergingPlugin.js +19 -15
  49. package/lib/optimize/ConcatenatedModule.js +19 -15
  50. package/lib/optimize/ModuleConcatenationPlugin.js +73 -24
  51. package/lib/optimize/RealContentHashPlugin.js +10 -7
  52. package/lib/optimize/SplitChunksPlugin.js +146 -44
  53. package/lib/prefetch/ResourceHintPlugin.js +96 -72
  54. package/lib/serialization/BinaryMiddleware.js +270 -938
  55. package/lib/serialization/FileMiddleware.js +299 -60
  56. package/lib/stats/DefaultStatsFactoryPlugin.js +204 -198
  57. package/lib/stats/DefaultStatsPrinterPlugin.js +24 -166
  58. package/lib/stats/StatsFactory.js +31 -9
  59. package/lib/util/identifier.js +21 -1
  60. package/package.json +10 -10
  61. package/schemas/WebpackOptions.json +110 -55
  62. package/types.d.ts +832 -247
@@ -1695,172 +1695,30 @@ class DefaultStatsPrinterPlugin {
1695
1695
  context.timeReference = compilation.time;
1696
1696
  });
1697
1697
 
1698
- for (const key of /** @type {(keyof CompilationSimplePrinters)[]} */ (
1699
- Object.keys(COMPILATION_SIMPLE_PRINTERS)
1700
- )) {
1701
- stats.hooks.print.for(key).tap(PLUGIN_NAME, (obj, ctx) =>
1702
- /** @type {NonNullable<CompilationSimplePrinters[keyof CompilationSimplePrinters]>} */
1703
- (COMPILATION_SIMPLE_PRINTERS[key])(
1704
- obj,
1705
- /** @type {DefineStatsPrinterContext<"compilation">} */
1706
- (ctx),
1707
- stats
1708
- )
1709
- );
1710
- }
1711
-
1712
- for (const key of /** @type {(keyof AssetSimplePrinters)[]} */ (
1713
- Object.keys(ASSET_SIMPLE_PRINTERS)
1714
- )) {
1715
- stats.hooks.print.for(key).tap(PLUGIN_NAME, (obj, ctx) =>
1716
- /** @type {NonNullable<AssetSimplePrinters[keyof AssetSimplePrinters]>} */
1717
- (ASSET_SIMPLE_PRINTERS[key])(
1718
- obj,
1719
- /** @type {DefineStatsPrinterContext<"asset" | "asset.info">} */
1720
- (ctx),
1721
- stats
1722
- )
1723
- );
1724
- }
1725
-
1726
- for (const key of /** @type {(keyof ModuleSimplePrinters)[]} */ (
1727
- Object.keys(MODULE_SIMPLE_PRINTERS)
1728
- )) {
1729
- stats.hooks.print.for(key).tap(PLUGIN_NAME, (obj, ctx) =>
1730
- /** @type {SimplePrinter<EXPECTED_ANY, "module">} */
1731
- (MODULE_SIMPLE_PRINTERS[key])(
1732
- obj,
1733
- /** @type {DefineStatsPrinterContext<"module">} */
1734
- (ctx),
1735
- stats
1736
- )
1737
- );
1738
- }
1739
-
1740
- for (const key of /** @type {(keyof ModuleIssuerPrinters)[]} */ (
1741
- Object.keys(MODULE_ISSUER_PRINTERS)
1742
- )) {
1743
- stats.hooks.print.for(key).tap(PLUGIN_NAME, (obj, ctx) =>
1744
- /** @type {NonNullable<ModuleIssuerPrinters[keyof ModuleIssuerPrinters]>} */
1745
- (MODULE_ISSUER_PRINTERS[key])(
1746
- obj,
1747
- /** @type {DefineStatsPrinterContext<"moduleIssuer">} */
1748
- (ctx),
1749
- stats
1750
- )
1751
- );
1752
- }
1753
-
1754
- for (const key of /** @type {(keyof ModuleReasonsPrinters)[]} */ (
1755
- Object.keys(MODULE_REASON_PRINTERS)
1756
- )) {
1757
- stats.hooks.print.for(key).tap(PLUGIN_NAME, (obj, ctx) =>
1758
- /** @type {SimplePrinter<EXPECTED_ANY, "moduleReason">} */
1759
- (MODULE_REASON_PRINTERS[key])(
1760
- obj,
1761
- /** @type {DefineStatsPrinterContext<"moduleReason">} */
1762
- (ctx),
1763
- stats
1764
- )
1765
- );
1766
- }
1767
-
1768
- for (const key of /** @type {(keyof ModuleProfilePrinters)[]} */ (
1769
- Object.keys(MODULE_PROFILE_PRINTERS)
1770
- )) {
1771
- stats.hooks.print.for(key).tap(PLUGIN_NAME, (obj, ctx) =>
1772
- /** @type {NonNullable<ModuleProfilePrinters[keyof ModuleProfilePrinters]>} */
1773
- (MODULE_PROFILE_PRINTERS[key])(
1774
- obj,
1775
- /** @type {DefineStatsPrinterContext<"profile">} */
1776
- (ctx),
1777
- stats
1778
- )
1779
- );
1780
- }
1781
-
1782
- for (const key of /** @type {(keyof ChunkGroupPrinters)[]} */ (
1783
- Object.keys(CHUNK_GROUP_PRINTERS)
1784
- )) {
1785
- stats.hooks.print.for(key).tap(PLUGIN_NAME, (obj, ctx) =>
1786
- /** @type {SimplePrinter<EXPECTED_ANY, "chunkGroupKind" | "chunkGroup">} */
1787
- (CHUNK_GROUP_PRINTERS[key])(
1788
- obj,
1789
- /** @type {DefineStatsPrinterContext<"chunkGroupKind" | "chunkGroup">} */
1790
- (ctx),
1791
- stats
1792
- )
1793
- );
1794
- }
1795
-
1796
- for (const key of /** @type {(keyof ChunkPrinters)[]} */ (
1797
- Object.keys(CHUNK_PRINTERS)
1798
- )) {
1799
- stats.hooks.print.for(key).tap(PLUGIN_NAME, (obj, ctx) =>
1800
- /** @type {SimplePrinter<EXPECTED_ANY, "chunk">} */
1801
- (CHUNK_PRINTERS[key])(
1802
- obj,
1803
- /** @type {DefineStatsPrinterContext<"chunk">} */
1804
- (ctx),
1805
- stats
1806
- )
1807
- );
1808
- }
1809
-
1810
- for (const key of /** @type {(keyof ErrorPrinters)[]} */ (
1811
- Object.keys(ERROR_PRINTERS)
1812
- )) {
1813
- stats.hooks.print.for(key).tap(PLUGIN_NAME, (obj, ctx) =>
1814
- /** @type {SimplePrinter<EXPECTED_ANY, "error">} */
1815
- (ERROR_PRINTERS[key])(
1816
- obj,
1817
- /** @type {DefineStatsPrinterContext<"error">} */
1818
- (ctx),
1819
- stats
1820
- )
1821
- );
1822
- }
1823
-
1824
- for (const key of /** @type {(keyof LogEntryPrinters)[]} */ (
1825
- Object.keys(LOG_ENTRY_PRINTERS)
1826
- )) {
1827
- stats.hooks.print.for(key).tap(PLUGIN_NAME, (obj, ctx) =>
1828
- /** @type {SimplePrinter<EXPECTED_ANY, "logging">} */
1829
- (LOG_ENTRY_PRINTERS[key])(
1830
- obj,
1831
- /** @type {DefineStatsPrinterContext<"logging">} */
1832
- (ctx),
1833
- stats
1834
- )
1835
- );
1836
- }
1837
-
1838
- for (const key of /** @type {(keyof ModuleTraceDependencyPrinters)[]} */ (
1839
- Object.keys(MODULE_TRACE_DEPENDENCY_PRINTERS)
1840
- )) {
1841
- stats.hooks.print.for(key).tap(PLUGIN_NAME, (obj, ctx) =>
1842
- /** @type {NonNullable<ModuleTraceDependencyPrinters[keyof ModuleTraceDependencyPrinters]>} */
1843
- (MODULE_TRACE_DEPENDENCY_PRINTERS[key])(
1844
- obj,
1845
- /** @type {DefineStatsPrinterContext<"moduleTraceDependency">} */
1846
- (ctx),
1847
- stats
1848
- )
1849
- );
1850
- }
1851
-
1852
- for (const key of /** @type {(keyof ModuleTraceItemPrinters)[]} */ (
1853
- Object.keys(MODULE_TRACE_ITEM_PRINTERS)
1854
- )) {
1855
- stats.hooks.print.for(key).tap(PLUGIN_NAME, (obj, ctx) =>
1856
- /** @type {NonNullable<ModuleTraceItemPrinters[keyof ModuleTraceItemPrinters]>} */
1857
- (MODULE_TRACE_ITEM_PRINTERS[key])(
1858
- obj,
1859
- /** @type {DefineStatsPrinterContext<"moduleTraceItem">} */
1860
- (ctx),
1861
- stats
1862
- )
1863
- );
1698
+ // Every `*_SIMPLE_PRINTERS` map registers identically: tap
1699
+ // `print.for(key)` with a formatter called as `(obj, ctx, stats)`.
1700
+ // One loop over all maps replaces a dozen near-identical blocks.
1701
+ for (const simplePrinters of /** @type {Record<string, EXPECTED_ANY>[]} */ ([
1702
+ COMPILATION_SIMPLE_PRINTERS,
1703
+ ASSET_SIMPLE_PRINTERS,
1704
+ MODULE_SIMPLE_PRINTERS,
1705
+ MODULE_ISSUER_PRINTERS,
1706
+ MODULE_REASON_PRINTERS,
1707
+ MODULE_PROFILE_PRINTERS,
1708
+ CHUNK_GROUP_PRINTERS,
1709
+ CHUNK_PRINTERS,
1710
+ ERROR_PRINTERS,
1711
+ LOG_ENTRY_PRINTERS,
1712
+ MODULE_TRACE_DEPENDENCY_PRINTERS,
1713
+ MODULE_TRACE_ITEM_PRINTERS
1714
+ ])) {
1715
+ for (const key of Object.keys(simplePrinters)) {
1716
+ stats.hooks.print
1717
+ .for(key)
1718
+ .tap(PLUGIN_NAME, (obj, ctx) =>
1719
+ simplePrinters[key](obj, ctx, stats)
1720
+ );
1721
+ }
1864
1722
  }
1865
1723
 
1866
1724
  for (const key of Object.keys(PREFERRED_ORDERS)) {
@@ -6,7 +6,6 @@
6
6
  "use strict";
7
7
 
8
8
  const { HookMap, SyncBailHook, SyncWaterfallHook } = require("tapable");
9
- const { concatComparators, keepOriginalOrder } = require("../util/comparators");
10
9
  const smartGrouping = require("../util/smartGrouping");
11
10
 
12
11
  /** @typedef {import("../Chunk")} Chunk */
@@ -294,10 +293,7 @@ class StatsFactory {
294
293
  h.call(comparators, context)
295
294
  );
296
295
  if (comparators.length > 0) {
297
- items.sort(
298
- // @ts-expect-error number of arguments is correct
299
- concatComparators(...comparators, keepOriginalOrder(items))
300
- );
296
+ sortWithOriginalOrder(items, comparators);
301
297
  }
302
298
 
303
299
  // run filter on sorted items
@@ -358,10 +354,7 @@ class StatsFactory {
358
354
  (h) => h.call(comparators2, context)
359
355
  );
360
356
  if (comparators2.length > 0) {
361
- resultItems.sort(
362
- // @ts-expect-error number of arguments is correct
363
- concatComparators(...comparators2, keepOriginalOrder(resultItems))
364
- );
357
+ sortWithOriginalOrder(resultItems, comparators2);
365
358
  }
366
359
 
367
360
  // group result items
@@ -424,4 +417,33 @@ class StatsFactory {
424
417
  }
425
418
  }
426
419
 
420
+ /**
421
+ * Stable in-place sort applying comparators in order, keeping the original order
422
+ * for equal items. Inlined instead of `concatComparators(...c, keepOriginalOrder())`
423
+ * because that combination is single-use per sort and only thrashes the comparator
424
+ * caches (a fresh tiebreaker closure every call allocates a new cache entry).
425
+ * @param {EXPECTED_ANY[]} items items to sort in place
426
+ * @param {Comparator[]} comparators comparators applied in order
427
+ * @returns {void}
428
+ */
429
+ const sortWithOriginalOrder = (items, comparators) => {
430
+ // original-index tiebreaker keeps the sort stable on engines without a stable Array.sort
431
+ /** @type {Map<EXPECTED_ANY, number>} */
432
+ const originalOrder = new Map();
433
+ for (let i = 0; i < items.length; i++) {
434
+ originalOrder.set(items[i], i);
435
+ }
436
+ const count = comparators.length;
437
+ items.sort((a, b) => {
438
+ for (let i = 0; i < count; i++) {
439
+ const res = comparators[i](a, b);
440
+ if (res !== 0) return res;
441
+ }
442
+ return (
443
+ /** @type {number} */ (originalOrder.get(a)) -
444
+ /** @type {number} */ (originalOrder.get(b))
445
+ );
446
+ });
447
+ };
448
+
427
449
  module.exports = StatsFactory;
@@ -532,6 +532,25 @@ const escapeHashInPathRequest = (request) => {
532
532
  return pathPart.replace(HASH_REGEXP, "\0#") + request.slice(lastSep);
533
533
  };
534
534
 
535
+ const makePathsRelative = makeCacheableWithContext(_makePathsRelative);
536
+
537
+ /**
538
+ * Turns a source path into a `webpack://`-prefixed, context-relative source
539
+ * URL, as used for the `sources` of module-level source maps.
540
+ * @param {string} context absolute context path
541
+ * @param {string} source a source path
542
+ * @param {AssociatedObjectForCache=} associatedObjectForCache an object to which the cache will be attached
543
+ * @returns {string} new source path
544
+ */
545
+ const contextifySourceUrl = (context, source, associatedObjectForCache) => {
546
+ if (source.startsWith("webpack://")) return source;
547
+ return `webpack://${makePathsRelative(
548
+ context,
549
+ source,
550
+ associatedObjectForCache
551
+ )}`;
552
+ };
553
+
535
554
  const LINE_SEPARATOR_REGEXP = /[\u2028\u2029]/g;
536
555
 
537
556
  /**
@@ -550,11 +569,12 @@ module.exports.ABSOLUTE_PATH_REGEXP = ABSOLUTE_PATH_REGEXP;
550
569
  module.exports.WINDOWS_ABS_PATH_REGEXP = WINDOWS_ABS_PATH_REGEXP;
551
570
  module.exports.absolutify = absolutify;
552
571
  module.exports.contextify = contextify;
572
+ module.exports.contextifySourceUrl = contextifySourceUrl;
553
573
  module.exports.escapeHashInPathRequest = escapeHashInPathRequest;
554
574
  module.exports.getUndoPath = getUndoPath;
555
575
  module.exports.makeCacheable = makeCacheable;
556
576
  module.exports.makePathsAbsolute = makeCacheableWithContext(_makePathsAbsolute);
557
- module.exports.makePathsRelative = makeCacheableWithContext(_makePathsRelative);
577
+ module.exports.makePathsRelative = makePathsRelative;
558
578
  module.exports.parseResource = makeCacheable(_parseResource);
559
579
  module.exports.parseResourceWithoutFragment = makeCacheable(
560
580
  _parseResourceWithoutFragment
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@depup/webpack",
3
- "version": "5.109.0-depup.0",
3
+ "version": "5.109.2-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",
@@ -66,7 +66,7 @@
66
66
  "test:test262": "yarn test:base --testMatch \"<rootDir>/test/test262.spectest.js\"",
67
67
  "test:html5lib": "yarn test:base --testMatch \"<rootDir>/test/html5lib.spectest.js\"",
68
68
  "test:css-parsing": "yarn test:base --testMatch \"<rootDir>/test/cssParsing-webpack.spectest.js\"",
69
- "test:deno": "yarn test:base:deno --reporters default --reporters \"<rootDir>/test/runtimeCrashReporter.js\" --testMatch \"<rootDir>/test/*.{basictest,longtest,test,unittest}.js\" --testPathIgnorePatterns \"/node_modules/|test/HotTestCases\"",
69
+ "test:deno": "yarn test:base:deno --reporters default --reporters \"<rootDir>/test/runtimeCrashReporter.js\" --testMatch \"<rootDir>/test/*.{basictest,longtest,test,unittest}.js\" --testPathIgnorePatterns \"/node_modules/\"",
70
70
  "test:base:deno": "deno --allow-read --allow-env --allow-sys --allow-ffi --allow-write --allow-run --allow-net --import-map=test/deno-import-map.json --v8-flags='--max-old-space-size=4096' ./node_modules/jest-cli/bin/jest.js --workerIdleMemoryLimit=512MB --logHeapUsage",
71
71
  "test:bun": "yarn test:base:bun --reporters default --reporters \"<rootDir>/test/runtimeCrashReporter.js\" --testMatch \"<rootDir>/test/*.{basictest,longtest,test,unittest}.js\" --testPathIgnorePatterns \"/node_modules/\"",
72
72
  "test:base:bun": "bun --bun --smol --preload ./test/bun-preload.js ./node_modules/jest-cli/bin/jest.js --workerThreads --workerIdleMemoryLimit=512MB --logHeapUsage",
@@ -103,10 +103,10 @@
103
103
  "@webassemblyjs/ast": "^1.14.1",
104
104
  "@webassemblyjs/wasm-edit": "^1.14.1",
105
105
  "@webassemblyjs/wasm-parser": "^1.14.1",
106
- "acorn": "^8.17.0",
106
+ "acorn": "^8.18.0",
107
107
  "browserslist": "^4.28.7",
108
108
  "chrome-trace-event": "^1.0.4",
109
- "enhanced-resolve": "^5.24.3",
109
+ "enhanced-resolve": "^5.24.5",
110
110
  "es-module-lexer": "^2.3.1",
111
111
  "eslint-scope": "^9.1.2",
112
112
  "events": "^3.3.0",
@@ -201,7 +201,7 @@
201
201
  "three": "^0.185.1",
202
202
  "tinybench": "^6.0.1",
203
203
  "toml": "^4.1.1",
204
- "tooling": "webpack/tooling#v1.26.4",
204
+ "tooling": "webpack/tooling#v1.27.0",
205
205
  "ts-loader": "^9.6.0",
206
206
  "typescript": "^6.0.3",
207
207
  "unified": "^11.0.5",
@@ -238,7 +238,7 @@
238
238
  },
239
239
  "acorn": {
240
240
  "from": "^8.16.0",
241
- "to": "^8.17.0"
241
+ "to": "^8.18.0"
242
242
  },
243
243
  "browserslist": {
244
244
  "from": "^4.28.1",
@@ -249,8 +249,8 @@
249
249
  "to": "^1.0.4"
250
250
  },
251
251
  "enhanced-resolve": {
252
- "from": "^5.24.2",
253
- "to": "^5.24.3"
252
+ "from": "^5.24.4",
253
+ "to": "^5.24.5"
254
254
  },
255
255
  "es-module-lexer": {
256
256
  "from": "^2.1.0",
@@ -271,8 +271,8 @@
271
271
  },
272
272
  "depsUpdated": 9,
273
273
  "originalPackage": "webpack",
274
- "originalVersion": "5.109.0",
275
- "processedAt": "2026-07-26T01:00:20.392Z",
274
+ "originalVersion": "5.109.2",
275
+ "processedAt": "2026-08-02T00:59:27.551Z",
276
276
  "smokeTest": "passed"
277
277
  }
278
278
  }