webpack 5.85.1 → 5.87.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.

Potentially problematic release.


This version of webpack might be problematic. Click here for more details.

Files changed (140) hide show
  1. package/README.md +5 -2
  2. package/lib/APIPlugin.js +150 -99
  3. package/lib/CaseSensitiveModulesWarning.js +3 -1
  4. package/lib/Chunk.js +35 -17
  5. package/lib/ChunkGroup.js +11 -6
  6. package/lib/Compiler.js +4 -3
  7. package/lib/ConcatenationScope.js +2 -2
  8. package/lib/ConditionalInitFragment.js +11 -1
  9. package/lib/ConstPlugin.js +57 -29
  10. package/lib/ContextModule.js +4 -2
  11. package/lib/ContextModuleFactory.js +1 -0
  12. package/lib/DependenciesBlock.js +1 -1
  13. package/lib/DllModule.js +6 -0
  14. package/lib/EvalSourceMapDevToolPlugin.js +2 -1
  15. package/lib/ExternalModule.js +15 -8
  16. package/lib/FlagEntryExportAsUsedPlugin.js +4 -0
  17. package/lib/Module.js +7 -1
  18. package/lib/ModuleDependencyError.js +4 -2
  19. package/lib/ModuleDependencyWarning.js +4 -2
  20. package/lib/ModuleGraph.js +31 -24
  21. package/lib/ModuleGraphConnection.js +19 -6
  22. package/lib/ModuleInfoHeaderPlugin.js +9 -2
  23. package/lib/ModuleNotFoundError.js +5 -2
  24. package/lib/ModuleStoreError.js +2 -1
  25. package/lib/ModuleTypeConstants.js +7 -0
  26. package/lib/MultiWatching.js +4 -0
  27. package/lib/ProgressPlugin.js +71 -15
  28. package/lib/RuntimeGlobals.js +5 -0
  29. package/lib/RuntimePlugin.js +2 -1
  30. package/lib/RuntimeTemplate.js +20 -2
  31. package/lib/WebpackError.js +6 -5
  32. package/lib/WebpackOptionsApply.js +4 -2
  33. package/lib/WebpackOptionsDefaulter.js +10 -3
  34. package/lib/config/defaults.js +31 -2
  35. package/lib/css/CssExportsGenerator.js +9 -0
  36. package/lib/css/CssGenerator.js +1 -1
  37. package/lib/css/CssLoadingRuntimeModule.js +13 -6
  38. package/lib/css/CssModulesPlugin.js +42 -14
  39. package/lib/css/CssParser.js +12 -0
  40. package/lib/dependencies/ConstDependency.js +2 -2
  41. package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +19 -0
  42. package/lib/dependencies/ImportParserPlugin.js +25 -1
  43. package/lib/dependencies/JsonExportsDependency.js +1 -1
  44. package/lib/ids/SyncModuleIdsPlugin.js +1 -0
  45. package/lib/javascript/BasicEvaluatedExpression.js +23 -15
  46. package/lib/javascript/CommonJsChunkFormatPlugin.js +6 -2
  47. package/lib/javascript/JavascriptModulesPlugin.js +1 -0
  48. package/lib/javascript/JavascriptParser.js +118 -58
  49. package/lib/javascript/JavascriptParserHelpers.js +37 -15
  50. package/lib/json/JsonData.js +2 -2
  51. package/lib/json/JsonParser.js +25 -12
  52. package/lib/node/ReadFileCompileAsyncWasmPlugin.js +2 -1
  53. package/lib/optimize/AggressiveMergingPlugin.js +8 -0
  54. package/lib/optimize/AggressiveSplittingPlugin.js +9 -2
  55. package/lib/optimize/EnsureChunkConditionsPlugin.js +3 -0
  56. package/lib/optimize/FlagIncludedChunksPlugin.js +11 -5
  57. package/lib/optimize/InnerGraph.js +4 -4
  58. package/lib/optimize/LimitChunkCountPlugin.js +29 -4
  59. package/lib/optimize/MangleExportsPlugin.js +1 -1
  60. package/lib/optimize/MinMaxSizeWarning.js +5 -0
  61. package/lib/optimize/ModuleConcatenationPlugin.js +59 -2
  62. package/lib/optimize/RealContentHashPlugin.js +80 -30
  63. package/lib/optimize/RemoveParentModulesPlugin.js +6 -0
  64. package/lib/optimize/RuntimeChunkPlugin.js +9 -1
  65. package/lib/optimize/SideEffectsFlagPlugin.js +10 -1
  66. package/lib/optimize/SplitChunksPlugin.js +71 -31
  67. package/lib/performance/SizeLimitsPlugin.js +7 -4
  68. package/lib/prefetch/ChunkPrefetchFunctionRuntimeModule.js +3 -1
  69. package/lib/prefetch/ChunkPrefetchPreloadPlugin.js +3 -1
  70. package/lib/prefetch/ChunkPrefetchStartupRuntimeModule.js +5 -2
  71. package/lib/prefetch/ChunkPrefetchTriggerRuntimeModule.js +3 -1
  72. package/lib/prefetch/ChunkPreloadTriggerRuntimeModule.js +3 -1
  73. package/lib/rules/BasicEffectRulePlugin.js +4 -0
  74. package/lib/rules/BasicMatcherRulePlugin.js +5 -0
  75. package/lib/rules/RuleSetCompiler.js +3 -3
  76. package/lib/rules/UseEffectRulePlugin.js +6 -4
  77. package/lib/runtime/AsyncModuleRuntimeModule.js +4 -1
  78. package/lib/runtime/AutoPublicPathRuntimeModule.js +3 -1
  79. package/lib/runtime/BaseUriRuntimeModule.js +2 -2
  80. package/lib/runtime/CompatGetDefaultExportRuntimeModule.js +4 -1
  81. package/lib/runtime/CompatRuntimeModule.js +6 -1
  82. package/lib/runtime/CreateFakeNamespaceObjectRuntimeModule.js +4 -1
  83. package/lib/runtime/CreateScriptRuntimeModule.js +3 -1
  84. package/lib/runtime/CreateScriptUrlRuntimeModule.js +3 -1
  85. package/lib/runtime/DefinePropertyGettersRuntimeModule.js +4 -1
  86. package/lib/runtime/EnsureChunkRuntimeModule.js +14 -3
  87. package/lib/runtime/GetChunkFilenameRuntimeModule.js +5 -9
  88. package/lib/runtime/GetFullHashRuntimeModule.js +3 -2
  89. package/lib/runtime/GetMainFilenameRuntimeModule.js +4 -1
  90. package/lib/runtime/GetTrustedTypesPolicyRuntimeModule.js +3 -1
  91. package/lib/runtime/HasOwnPropertyRuntimeModule.js +4 -1
  92. package/lib/runtime/LoadScriptRuntimeModule.js +63 -47
  93. package/lib/runtime/MakeNamespaceObjectRuntimeModule.js +4 -1
  94. package/lib/runtime/OnChunksLoadedRuntimeModule.js +3 -1
  95. package/lib/runtime/PublicPathRuntimeModule.js +3 -1
  96. package/lib/runtime/RelativeUrlRuntimeModule.js +4 -1
  97. package/lib/runtime/RuntimeIdRuntimeModule.js +5 -1
  98. package/lib/runtime/StartupChunkDependenciesRuntimeModule.js +8 -2
  99. package/lib/runtime/StartupEntrypointRuntimeModule.js +2 -1
  100. package/lib/serialization/BinaryMiddleware.js +143 -1
  101. package/lib/serialization/ErrorObjectSerializer.js +3 -0
  102. package/lib/serialization/ObjectMiddleware.js +9 -3
  103. package/lib/serialization/types.js +1 -1
  104. package/lib/sharing/ConsumeSharedFallbackDependency.js +3 -0
  105. package/lib/sharing/ConsumeSharedRuntimeModule.js +13 -4
  106. package/lib/sharing/ProvideSharedDependency.js +11 -0
  107. package/lib/sharing/ProvideSharedModule.js +4 -0
  108. package/lib/sharing/ProvideSharedPlugin.js +22 -21
  109. package/lib/sharing/ShareRuntimeModule.js +11 -4
  110. package/lib/sharing/resolveMatchedConfigs.js +1 -1
  111. package/lib/sharing/utils.js +32 -5
  112. package/lib/util/AsyncQueue.js +4 -2
  113. package/lib/util/ParallelismFactorCalculator.js +10 -0
  114. package/lib/util/Semaphore.js +1 -1
  115. package/lib/util/createHash.js +30 -9
  116. package/lib/util/deprecation.js +10 -3
  117. package/lib/util/deterministicGrouping.js +50 -11
  118. package/lib/util/findGraphRoots.js +4 -2
  119. package/lib/util/memoize.js +3 -3
  120. package/lib/util/processAsyncTree.js +7 -1
  121. package/lib/util/registerExternalSerializer.js +1 -1
  122. package/lib/util/runtime.js +14 -1
  123. package/lib/util/smartGrouping.js +1 -1
  124. package/lib/validateSchema.js +6 -2
  125. package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +5 -1
  126. package/lib/wasm-async/AsyncWebAssemblyParser.js +7 -3
  127. package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +13 -6
  128. package/lib/wasm-sync/WasmFinalizeExportsPlugin.js +3 -1
  129. package/lib/wasm-sync/WebAssemblyGenerator.js +1 -0
  130. package/lib/wasm-sync/WebAssemblyParser.js +6 -2
  131. package/lib/web/JsonpChunkLoadingRuntimeModule.js +13 -3
  132. package/lib/webpack.js +11 -2
  133. package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +14 -15
  134. package/module.d.ts +1 -0
  135. package/package.json +4 -4
  136. package/schemas/WebpackOptions.check.js +1 -1
  137. package/schemas/WebpackOptions.json +51 -5
  138. package/schemas/plugins/css/CssGeneratorOptions.json +1 -1
  139. package/schemas/plugins/css/CssParserOptions.json +1 -1
  140. package/types.d.ts +476 -218
package/lib/webpack.js CHANGED
@@ -61,7 +61,10 @@ const createMultiCompiler = (childOptions, options) => {
61
61
  const createCompiler = rawOptions => {
62
62
  const options = getNormalizedWebpackOptions(rawOptions);
63
63
  applyWebpackOptionsBaseDefaults(options);
64
- const compiler = new Compiler(options.context, options);
64
+ const compiler = new Compiler(
65
+ /** @type {string} */ (options.context),
66
+ options
67
+ );
65
68
  new NodeEnvironmentPlugin({
66
69
  infrastructureLogging: options.infrastructureLogging
67
70
  }).apply(compiler);
@@ -69,7 +72,7 @@ const createCompiler = rawOptions => {
69
72
  for (const plugin of options.plugins) {
70
73
  if (typeof plugin === "function") {
71
74
  plugin.call(compiler, compiler);
72
- } else {
75
+ } else if (plugin) {
73
76
  plugin.apply(compiler);
74
77
  }
75
78
  }
@@ -96,6 +99,11 @@ const createCompiler = rawOptions => {
96
99
  * @returns {MultiCompiler} the multi compiler object
97
100
  */
98
101
 
102
+ /**
103
+ * @template T
104
+ * @param {Array<T> | T} options options
105
+ * @returns {Array<T>} array of options
106
+ */
99
107
  const asArray = options =>
100
108
  Array.isArray(options) ? Array.from(options) : [options];
101
109
 
@@ -117,6 +125,7 @@ const webpack = /** @type {WebpackFunctionSingle & WebpackFunctionMulti} */ (
117
125
  }
118
126
  /** @type {MultiCompiler|Compiler} */
119
127
  let compiler;
128
+ /** @type {boolean | undefined} */
120
129
  let watch = false;
121
130
  /** @type {WatchOptions|WatchOptions[]} */
122
131
  let watchOptions;
@@ -16,6 +16,8 @@ const compileBooleanMatcher = require("../util/compileBooleanMatcher");
16
16
  const { getUndoPath } = require("../util/identifier");
17
17
 
18
18
  /** @typedef {import("../Chunk")} Chunk */
19
+ /** @typedef {import("../ChunkGraph")} ChunkGraph */
20
+ /** @typedef {import("../Compilation")} Compilation */
19
21
 
20
22
  class ImportScriptsChunkLoadingRuntimeModule extends RuntimeModule {
21
23
  /**
@@ -38,8 +40,9 @@ class ImportScriptsChunkLoadingRuntimeModule extends RuntimeModule {
38
40
  if (options && options.baseUri) {
39
41
  return `${RuntimeGlobals.baseURI} = ${JSON.stringify(options.baseUri)};`;
40
42
  }
41
- const outputName = this.compilation.getPath(
42
- getChunkFilenameTemplate(chunk, this.compilation.outputOptions),
43
+ const compilation = /** @type {Compilation} */ (this.compilation);
44
+ const outputName = compilation.getPath(
45
+ getChunkFilenameTemplate(chunk, compilation.outputOptions),
43
46
  {
44
47
  chunk,
45
48
  contentHashType: "javascript"
@@ -47,7 +50,7 @@ class ImportScriptsChunkLoadingRuntimeModule extends RuntimeModule {
47
50
  );
48
51
  const rootOutputDir = getUndoPath(
49
52
  outputName,
50
- /** @type {string} */ (this.compilation.outputOptions.path),
53
+ /** @type {string} */ (compilation.outputOptions.path),
51
54
  false
52
55
  );
53
56
  return `${RuntimeGlobals.baseURI} = self.location + ${JSON.stringify(
@@ -59,16 +62,7 @@ class ImportScriptsChunkLoadingRuntimeModule extends RuntimeModule {
59
62
  * @returns {string} runtime code
60
63
  */
61
64
  generate() {
62
- const {
63
- chunk,
64
- chunkGraph,
65
- compilation: {
66
- runtimeTemplate,
67
- outputOptions: { chunkLoadingGlobal, hotUpdateGlobal }
68
- },
69
- _withCreateScriptUrl: withCreateScriptUrl
70
- } = this;
71
- const globalObject = runtimeTemplate.globalObject;
65
+ const compilation = /** @type {Compilation} */ (this.compilation);
72
66
  const fn = RuntimeGlobals.ensureChunkHandlers;
73
67
  const withBaseURI = this.runtimeRequirements.has(RuntimeGlobals.baseURI);
74
68
  const withLoading = this.runtimeRequirements.has(
@@ -80,9 +74,12 @@ class ImportScriptsChunkLoadingRuntimeModule extends RuntimeModule {
80
74
  const withHmrManifest = this.runtimeRequirements.has(
81
75
  RuntimeGlobals.hmrDownloadManifest
82
76
  );
77
+ const globalObject = compilation.runtimeTemplate.globalObject;
83
78
  const chunkLoadingGlobalExpr = `${globalObject}[${JSON.stringify(
84
- chunkLoadingGlobal
79
+ compilation.outputOptions.chunkLoadingGlobal
85
80
  )}]`;
81
+ const chunkGraph = /** @type {ChunkGraph} */ (this.chunkGraph);
82
+ const chunk = /** @type {Chunk} */ (this.chunk);
86
83
  const hasJsMatcher = compileBooleanMatcher(
87
84
  chunkGraph.getChunkConditionMap(chunk, chunkHasJs)
88
85
  );
@@ -91,6 +88,8 @@ class ImportScriptsChunkLoadingRuntimeModule extends RuntimeModule {
91
88
  const stateExpression = withHmr
92
89
  ? `${RuntimeGlobals.hmrRuntimeStatePrefix}_importScripts`
93
90
  : undefined;
91
+ const runtimeTemplate = compilation.runtimeTemplate;
92
+ const { _withCreateScriptUrl: withCreateScriptUrl } = this;
94
93
 
95
94
  return Template.asString([
96
95
  withBaseURI ? this._generateBaseUri(chunk) : "// no baseURI",
@@ -169,7 +168,7 @@ class ImportScriptsChunkLoadingRuntimeModule extends RuntimeModule {
169
168
  Template.indent([
170
169
  "var success = false;",
171
170
  `${globalObject}[${JSON.stringify(
172
- hotUpdateGlobal
171
+ compilation.outputOptions.hotUpdateGlobal
173
172
  )}] = ${runtimeTemplate.basicFunction("_, moreModules, runtime", [
174
173
  "for(var moduleId in moreModules) {",
175
174
  Template.indent([
package/module.d.ts CHANGED
@@ -174,6 +174,7 @@ interface ImportMeta {
174
174
  exclude?: RegExp;
175
175
  preload?: boolean | number;
176
176
  prefetch?: boolean | number;
177
+ fetchPriority?: "low" | "high" | "auto";
177
178
  chunkName?: string;
178
179
  exports?: string | string[][];
179
180
  mode?: "sync" | "eager" | "weak" | "lazy" | "lazy-once";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webpack",
3
- "version": "5.85.1",
3
+ "version": "5.87.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",
@@ -14,7 +14,7 @@
14
14
  "acorn-import-assertions": "^1.9.0",
15
15
  "browserslist": "^4.14.5",
16
16
  "chrome-trace-event": "^1.0.2",
17
- "enhanced-resolve": "^5.14.1",
17
+ "enhanced-resolve": "^5.15.0",
18
18
  "es-module-lexer": "^1.2.1",
19
19
  "eslint-scope": "5.1.1",
20
20
  "events": "^3.2.0",
@@ -24,7 +24,7 @@
24
24
  "loader-runner": "^4.2.0",
25
25
  "mime-types": "^2.1.27",
26
26
  "neo-async": "^2.6.2",
27
- "schema-utils": "^3.1.2",
27
+ "schema-utils": "^3.2.0",
28
28
  "tapable": "^2.1.1",
29
29
  "terser-webpack-plugin": "^5.3.7",
30
30
  "watchpack": "^2.4.0",
@@ -97,7 +97,7 @@
97
97
  "style-loader": "^2.0.0",
98
98
  "terser": "^5.17.0",
99
99
  "toml": "^3.0.0",
100
- "tooling": "webpack/tooling#v1.22.1",
100
+ "tooling": "webpack/tooling#v1.23.0",
101
101
  "ts-loader": "^9.4.2",
102
102
  "typescript": "^5.0.4",
103
103
  "url-loader": "^4.1.0",