webpack 5.77.0 → 5.78.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 (66) hide show
  1. package/bin/webpack.js +0 -0
  2. package/lib/APIPlugin.js +25 -18
  3. package/lib/CompatibilityPlugin.js +53 -52
  4. package/lib/ConstPlugin.js +22 -15
  5. package/lib/ContextModule.js +3 -2
  6. package/lib/DefinePlugin.js +44 -36
  7. package/lib/DelegatedModule.js +2 -1
  8. package/lib/DllModule.js +2 -1
  9. package/lib/ErrorHelpers.js +61 -22
  10. package/lib/ExportsInfoApiPlugin.js +16 -9
  11. package/lib/ExternalModule.js +2 -1
  12. package/lib/FlagAllModulesAsUsedPlugin.js +22 -27
  13. package/lib/FlagDependencyExportsPlugin.js +336 -348
  14. package/lib/FlagDependencyUsagePlugin.js +6 -8
  15. package/lib/FlagEntryExportAsUsedPlugin.js +22 -23
  16. package/lib/HotModuleReplacementPlugin.js +50 -45
  17. package/lib/JavascriptMetaInfoPlugin.js +16 -9
  18. package/lib/ModuleTypeConstants.js +50 -0
  19. package/lib/NodeStuffPlugin.js +35 -31
  20. package/lib/NormalModule.js +2 -1
  21. package/lib/NormalModuleFactory.js +7 -1
  22. package/lib/ProvidePlugin.js +17 -10
  23. package/lib/RawModule.js +2 -1
  24. package/lib/RequireJsStuffPlugin.js +15 -15
  25. package/lib/UseStrictPlugin.js +15 -8
  26. package/lib/WebpackIsIncludedPlugin.js +16 -9
  27. package/lib/config/defaults.js +16 -8
  28. package/lib/config/normalization.js +4 -0
  29. package/lib/container/ContainerEntryModule.js +2 -1
  30. package/lib/css/CssParser.js +22 -2
  31. package/lib/debug/ProfilingPlugin.js +20 -12
  32. package/lib/dependencies/AMDPlugin.js +26 -20
  33. package/lib/dependencies/CommonJsImportsParserPlugin.js +5 -4
  34. package/lib/dependencies/CommonJsPlugin.js +29 -25
  35. package/lib/dependencies/HarmonyDetectionParserPlugin.js +3 -1
  36. package/lib/dependencies/HarmonyModulesPlugin.js +11 -5
  37. package/lib/dependencies/ImportMetaContextPlugin.js +11 -5
  38. package/lib/dependencies/ImportMetaPlugin.js +26 -20
  39. package/lib/dependencies/ImportPlugin.js +14 -7
  40. package/lib/dependencies/RequireContextPlugin.js +12 -6
  41. package/lib/dependencies/RequireEnsurePlugin.js +13 -7
  42. package/lib/dependencies/RequireIncludePlugin.js +11 -5
  43. package/lib/dependencies/SystemPlugin.js +21 -15
  44. package/lib/dependencies/URLPlugin.js +15 -9
  45. package/lib/dependencies/WorkerPlugin.js +14 -8
  46. package/lib/javascript/JavascriptModulesPlugin.js +157 -164
  47. package/lib/json/JsonModulesPlugin.js +13 -5
  48. package/lib/library/AmdLibraryPlugin.js +22 -6
  49. package/lib/node/ReadFileCompileAsyncWasmPlugin.js +2 -1
  50. package/lib/node/ReadFileCompileWasmPlugin.js +2 -1
  51. package/lib/optimize/ConcatenatedModule.js +2 -1
  52. package/lib/optimize/InnerGraphPlugin.js +47 -46
  53. package/lib/optimize/SideEffectsFlagPlugin.js +43 -43
  54. package/lib/sharing/ConsumeSharedPlugin.js +4 -0
  55. package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +9 -6
  56. package/lib/wasm-sync/WebAssemblyModulesPlugin.js +42 -43
  57. package/lib/web/FetchCompileAsyncWasmPlugin.js +2 -1
  58. package/lib/web/FetchCompileWasmPlugin.js +40 -40
  59. package/package.json +1 -1
  60. package/schemas/WebpackOptions.check.js +1 -1
  61. package/schemas/WebpackOptions.json +18 -0
  62. package/schemas/plugins/container/ContainerPlugin.check.js +1 -1
  63. package/schemas/plugins/container/ContainerPlugin.json +8 -0
  64. package/schemas/plugins/container/ModuleFederationPlugin.check.js +1 -1
  65. package/schemas/plugins/container/ModuleFederationPlugin.json +8 -0
  66. package/types.d.ts +10 -0
@@ -6,6 +6,7 @@
6
6
  "use strict";
7
7
 
8
8
  const Generator = require("../Generator");
9
+ const { WEBASSEMBLY_MODULE_TYPE_SYNC } = require("../ModuleTypeConstants");
9
10
  const WebAssemblyExportImportedDependency = require("../dependencies/WebAssemblyExportImportedDependency");
10
11
  const WebAssemblyImportDependency = require("../dependencies/WebAssemblyImportDependency");
11
12
  const { compareModulesByIdentifier } = require("../util/comparators");
@@ -26,6 +27,8 @@ const getWebAssemblyJavascriptGenerator = memoize(() =>
26
27
  );
27
28
  const getWebAssemblyParser = memoize(() => require("./WebAssemblyParser"));
28
29
 
30
+ const PLUGIN_NAME = "WebAssemblyModulesPlugin";
31
+
29
32
  class WebAssemblyModulesPlugin {
30
33
  constructor(options) {
31
34
  this.options = options;
@@ -38,7 +41,7 @@ class WebAssemblyModulesPlugin {
38
41
  */
39
42
  apply(compiler) {
40
43
  compiler.hooks.compilation.tap(
41
- "WebAssemblyModulesPlugin",
44
+ PLUGIN_NAME,
42
45
  (compilation, { normalModuleFactory }) => {
43
46
  compilation.dependencyFactories.set(
44
47
  WebAssemblyImportDependency,
@@ -51,16 +54,16 @@ class WebAssemblyModulesPlugin {
51
54
  );
52
55
 
53
56
  normalModuleFactory.hooks.createParser
54
- .for("webassembly/sync")
55
- .tap("WebAssemblyModulesPlugin", () => {
57
+ .for(WEBASSEMBLY_MODULE_TYPE_SYNC)
58
+ .tap(PLUGIN_NAME, () => {
56
59
  const WebAssemblyParser = getWebAssemblyParser();
57
60
 
58
61
  return new WebAssemblyParser();
59
62
  });
60
63
 
61
64
  normalModuleFactory.hooks.createGenerator
62
- .for("webassembly/sync")
63
- .tap("WebAssemblyModulesPlugin", () => {
65
+ .for(WEBASSEMBLY_MODULE_TYPE_SYNC)
66
+ .tap(PLUGIN_NAME, () => {
64
67
  const WebAssemblyJavascriptGenerator =
65
68
  getWebAssemblyJavascriptGenerator();
66
69
  const WebAssemblyGenerator = getWebAssemblyGenerator();
@@ -71,53 +74,49 @@ class WebAssemblyModulesPlugin {
71
74
  });
72
75
  });
73
76
 
74
- compilation.hooks.renderManifest.tap(
75
- "WebAssemblyModulesPlugin",
76
- (result, options) => {
77
- const { chunkGraph } = compilation;
78
- const { chunk, outputOptions, codeGenerationResults } = options;
79
-
80
- for (const module of chunkGraph.getOrderedChunkModulesIterable(
81
- chunk,
82
- compareModulesByIdentifier
83
- )) {
84
- if (module.type === "webassembly/sync") {
85
- const filenameTemplate =
86
- outputOptions.webassemblyModuleFilename;
87
-
88
- result.push({
89
- render: () =>
90
- codeGenerationResults.getSource(
91
- module,
92
- chunk.runtime,
93
- "webassembly"
94
- ),
95
- filenameTemplate,
96
- pathOptions: {
77
+ compilation.hooks.renderManifest.tap(PLUGIN_NAME, (result, options) => {
78
+ const { chunkGraph } = compilation;
79
+ const { chunk, outputOptions, codeGenerationResults } = options;
80
+
81
+ for (const module of chunkGraph.getOrderedChunkModulesIterable(
82
+ chunk,
83
+ compareModulesByIdentifier
84
+ )) {
85
+ if (module.type === WEBASSEMBLY_MODULE_TYPE_SYNC) {
86
+ const filenameTemplate = outputOptions.webassemblyModuleFilename;
87
+
88
+ result.push({
89
+ render: () =>
90
+ codeGenerationResults.getSource(
97
91
  module,
98
- runtime: chunk.runtime,
99
- chunkGraph
100
- },
101
- auxiliary: true,
102
- identifier: `webassemblyModule${chunkGraph.getModuleId(
103
- module
104
- )}`,
105
- hash: chunkGraph.getModuleHash(module, chunk.runtime)
106
- });
107
- }
92
+ chunk.runtime,
93
+ "webassembly"
94
+ ),
95
+ filenameTemplate,
96
+ pathOptions: {
97
+ module,
98
+ runtime: chunk.runtime,
99
+ chunkGraph
100
+ },
101
+ auxiliary: true,
102
+ identifier: `webassemblyModule${chunkGraph.getModuleId(
103
+ module
104
+ )}`,
105
+ hash: chunkGraph.getModuleHash(module, chunk.runtime)
106
+ });
108
107
  }
109
-
110
- return result;
111
108
  }
112
- );
113
109
 
114
- compilation.hooks.afterChunks.tap("WebAssemblyModulesPlugin", () => {
110
+ return result;
111
+ });
112
+
113
+ compilation.hooks.afterChunks.tap(PLUGIN_NAME, () => {
115
114
  const chunkGraph = compilation.chunkGraph;
116
115
  const initialWasmModules = new Set();
117
116
  for (const chunk of compilation.chunks) {
118
117
  if (chunk.canBeInitial()) {
119
118
  for (const module of chunkGraph.getChunkModulesIterable(chunk)) {
120
- if (module.type === "webassembly/sync") {
119
+ if (module.type === WEBASSEMBLY_MODULE_TYPE_SYNC) {
121
120
  initialWasmModules.add(module);
122
121
  }
123
122
  }
@@ -5,6 +5,7 @@
5
5
 
6
6
  "use strict";
7
7
 
8
+ const { WEBASSEMBLY_MODULE_TYPE_ASYNC } = require("../ModuleTypeConstants");
8
9
  const RuntimeGlobals = require("../RuntimeGlobals");
9
10
  const AsyncWasmLoadingRuntimeModule = require("../wasm-async/AsyncWasmLoadingRuntimeModule");
10
11
 
@@ -40,7 +41,7 @@ class FetchCompileAsyncWasmPlugin {
40
41
  if (
41
42
  !chunkGraph.hasModuleInGraph(
42
43
  chunk,
43
- m => m.type === "webassembly/async"
44
+ m => m.type === WEBASSEMBLY_MODULE_TYPE_ASYNC
44
45
  )
45
46
  ) {
46
47
  return;
@@ -5,6 +5,7 @@
5
5
 
6
6
  "use strict";
7
7
 
8
+ const { WEBASSEMBLY_MODULE_TYPE_SYNC } = require("../ModuleTypeConstants");
8
9
  const RuntimeGlobals = require("../RuntimeGlobals");
9
10
  const WasmChunkLoadingRuntimeModule = require("../wasm-sync/WasmChunkLoadingRuntimeModule");
10
11
 
@@ -12,6 +13,8 @@ const WasmChunkLoadingRuntimeModule = require("../wasm-sync/WasmChunkLoadingRunt
12
13
 
13
14
  // TODO webpack 6 remove
14
15
 
16
+ const PLUGIN_NAME = "FetchCompileWasmPlugin";
17
+
15
18
  class FetchCompileWasmPlugin {
16
19
  constructor(options) {
17
20
  this.options = options || {};
@@ -23,48 +26,45 @@ class FetchCompileWasmPlugin {
23
26
  * @returns {void}
24
27
  */
25
28
  apply(compiler) {
26
- compiler.hooks.thisCompilation.tap(
27
- "FetchCompileWasmPlugin",
28
- compilation => {
29
- const globalWasmLoading = compilation.outputOptions.wasmLoading;
30
- const isEnabledForChunk = chunk => {
31
- const options = chunk.getEntryOptions();
32
- const wasmLoading =
33
- options && options.wasmLoading !== undefined
34
- ? options.wasmLoading
35
- : globalWasmLoading;
36
- return wasmLoading === "fetch";
37
- };
38
- const generateLoadBinaryCode = path =>
39
- `fetch(${RuntimeGlobals.publicPath} + ${path})`;
29
+ compiler.hooks.thisCompilation.tap(PLUGIN_NAME, compilation => {
30
+ const globalWasmLoading = compilation.outputOptions.wasmLoading;
31
+ const isEnabledForChunk = chunk => {
32
+ const options = chunk.getEntryOptions();
33
+ const wasmLoading =
34
+ options && options.wasmLoading !== undefined
35
+ ? options.wasmLoading
36
+ : globalWasmLoading;
37
+ return wasmLoading === "fetch";
38
+ };
39
+ const generateLoadBinaryCode = path =>
40
+ `fetch(${RuntimeGlobals.publicPath} + ${path})`;
40
41
 
41
- compilation.hooks.runtimeRequirementInTree
42
- .for(RuntimeGlobals.ensureChunkHandlers)
43
- .tap("FetchCompileWasmPlugin", (chunk, set) => {
44
- if (!isEnabledForChunk(chunk)) return;
45
- const chunkGraph = compilation.chunkGraph;
46
- if (
47
- !chunkGraph.hasModuleInGraph(
48
- chunk,
49
- m => m.type === "webassembly/sync"
50
- )
51
- ) {
52
- return;
53
- }
54
- set.add(RuntimeGlobals.moduleCache);
55
- set.add(RuntimeGlobals.publicPath);
56
- compilation.addRuntimeModule(
42
+ compilation.hooks.runtimeRequirementInTree
43
+ .for(RuntimeGlobals.ensureChunkHandlers)
44
+ .tap(PLUGIN_NAME, (chunk, set) => {
45
+ if (!isEnabledForChunk(chunk)) return;
46
+ const chunkGraph = compilation.chunkGraph;
47
+ if (
48
+ !chunkGraph.hasModuleInGraph(
57
49
  chunk,
58
- new WasmChunkLoadingRuntimeModule({
59
- generateLoadBinaryCode,
60
- supportsStreaming: true,
61
- mangleImports: this.options.mangleImports,
62
- runtimeRequirements: set
63
- })
64
- );
65
- });
66
- }
67
- );
50
+ m => m.type === WEBASSEMBLY_MODULE_TYPE_SYNC
51
+ )
52
+ ) {
53
+ return;
54
+ }
55
+ set.add(RuntimeGlobals.moduleCache);
56
+ set.add(RuntimeGlobals.publicPath);
57
+ compilation.addRuntimeModule(
58
+ chunk,
59
+ new WasmChunkLoadingRuntimeModule({
60
+ generateLoadBinaryCode,
61
+ supportsStreaming: true,
62
+ mangleImports: this.options.mangleImports,
63
+ runtimeRequirements: set
64
+ })
65
+ );
66
+ });
67
+ });
68
68
  }
69
69
  }
70
70
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webpack",
3
- "version": "5.77.0",
3
+ "version": "5.78.0",
4
4
  "author": "Tobias Koppers @sokra",
5
5
  "description": "Packs CommonJs/AMD modules for the browser. Allows to split your codebase into multiple bundles, which can be loaded on demand. Support loaders to preprocess files, i.e. json, jsx, es7, css, less, ... and your custom stuff.",
6
6
  "license": "MIT",