webpack 5.108.4 → 5.109.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 (200) hide show
  1. package/bin/webpack.js +12 -0
  2. package/lib/APIPlugin.js +48 -29
  3. package/lib/CacheFacade.js +8 -0
  4. package/lib/ChunkGraph.js +17 -15
  5. package/lib/ChunkGroup.js +1 -0
  6. package/lib/CompatibilityPlugin.js +62 -29
  7. package/lib/Compilation.js +58 -6
  8. package/lib/ConstPlugin.js +11 -11
  9. package/lib/ContextModule.js +239 -6
  10. package/lib/ContextModuleFactory.js +139 -14
  11. package/lib/DefinePlugin.js +433 -112
  12. package/lib/Entrypoint.js +1 -1
  13. package/lib/ExportsInfo.js +22 -5
  14. package/lib/ExportsInfoApiPlugin.js +2 -2
  15. package/lib/ExternalModule.js +107 -5
  16. package/lib/ExternalModuleFactoryPlugin.js +20 -1
  17. package/lib/FileSystemInfo.js +256 -100
  18. package/lib/FlagDependencyUsagePlugin.js +33 -12
  19. package/lib/HotModuleReplacementPlugin.js +18 -15
  20. package/lib/InitFragment.js +20 -32
  21. package/lib/Module.js +3 -0
  22. package/lib/ModuleFilenameHelpers.js +2 -2
  23. package/lib/ModuleTypeConstants.js +8 -1
  24. package/lib/MultiCompiler.js +13 -2
  25. package/lib/MultiWatching.js +1 -0
  26. package/lib/NodeStuffPlugin.js +51 -33
  27. package/lib/NormalModule.js +175 -401
  28. package/lib/NormalModuleFactory.js +76 -2
  29. package/lib/ProgressPlugin.js +211 -119
  30. package/lib/ProvidePlugin.js +2 -2
  31. package/lib/RuntimeGlobals.js +47 -0
  32. package/lib/RuntimePlugin.js +67 -107
  33. package/lib/RuntimeTemplate.js +304 -16
  34. package/lib/Template.js +23 -3
  35. package/lib/UseStrictPlugin.js +1 -1
  36. package/lib/WebpackIsIncludedPlugin.js +1 -1
  37. package/lib/WebpackOptionsApply.js +24 -19
  38. package/lib/asset/AssetGenerator.js +110 -28
  39. package/lib/asset/AssetModulesPlugin.js +92 -2
  40. package/lib/asset/WebManifestGenerator.js +164 -0
  41. package/lib/asset/WebManifestParser.js +130 -0
  42. package/lib/async-modules/AwaitDependenciesInitFragment.js +14 -4
  43. package/lib/async-modules/isGeneratorLowered.js +26 -0
  44. package/lib/cache/PackFileCacheStrategy.js +9 -3
  45. package/lib/config/browserslistTargetHandler.js +40 -0
  46. package/lib/config/defaults.js +219 -29
  47. package/lib/config/normalization.js +26 -0
  48. package/lib/config/target.js +9 -1
  49. package/lib/container/HoistContainerReferencesPlugin.js +47 -55
  50. package/lib/css/CssGenerator.js +40 -31
  51. package/lib/css/CssLoadingRuntimeModule.js +5 -1
  52. package/lib/css/CssModulesPlugin.js +13 -0
  53. package/lib/css/CssParser.js +729 -313
  54. package/lib/css/syntax.js +1371 -861
  55. package/lib/dependencies/AMDDefineDependencyParserPlugin.js +6 -6
  56. package/lib/dependencies/AMDPlugin.js +2 -2
  57. package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +13 -13
  58. package/lib/dependencies/CommonJsDependencyHelpers.js +39 -0
  59. package/lib/dependencies/CommonJsExportRequireDependency.js +19 -0
  60. package/lib/dependencies/CommonJsExportsDependency.js +47 -2
  61. package/lib/dependencies/CommonJsExportsParserPlugin.js +10 -10
  62. package/lib/dependencies/CommonJsImportsParserPlugin.js +18 -18
  63. package/lib/dependencies/CommonJsPlugin.js +2 -2
  64. package/lib/dependencies/CommonJsRequireDependency.js +26 -1
  65. package/lib/dependencies/CommonJsSelfReferenceDependency.js +32 -1
  66. package/lib/dependencies/ContextDependencyHelpers.js +3 -3
  67. package/lib/dependencies/CreateRequireParserPlugin.js +6 -6
  68. package/lib/dependencies/CssIcssExportDependency.js +162 -71
  69. package/lib/dependencies/CssUrlDependency.js +35 -4
  70. package/lib/dependencies/ExternalModuleInitFragmentDependency.js +2 -2
  71. package/lib/dependencies/HarmonyCompatibilityDependency.js +32 -14
  72. package/lib/dependencies/HarmonyDetectionParserPlugin.js +43 -13
  73. package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +2 -1
  74. package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +7 -19
  75. package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +17 -9
  76. package/lib/dependencies/HarmonyImportDependency.js +13 -2
  77. package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +11 -11
  78. package/lib/dependencies/HarmonyImportSpecifierDependency.js +10 -7
  79. package/lib/dependencies/HarmonyModulesPlugin.js +6 -0
  80. package/lib/dependencies/HarmonyTopLevelThisParserPlugin.js +1 -1
  81. package/lib/dependencies/HtmlEntryDependency.js +797 -172
  82. package/lib/dependencies/HtmlSourceDependency.js +26 -0
  83. package/lib/dependencies/ImportDependency.js +43 -1
  84. package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +31 -18
  85. package/lib/dependencies/ImportMetaContextPlugin.js +38 -7
  86. package/lib/dependencies/ImportMetaGlobDependency.js +81 -0
  87. package/lib/dependencies/ImportMetaGlobDependencyParserPlugin.js +78 -0
  88. package/lib/dependencies/ImportMetaGlobHelpers.js +660 -0
  89. package/lib/dependencies/ImportMetaPlugin.js +532 -180
  90. package/lib/dependencies/ImportMetaResolveDependency.js +90 -0
  91. package/lib/dependencies/ImportParserPlugin.js +80 -17
  92. package/lib/dependencies/ImportPhase.js +10 -8
  93. package/lib/dependencies/LoaderPlugin.js +5 -1
  94. package/lib/dependencies/RequireContextDependencyParserPlugin.js +1 -1
  95. package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +3 -6
  96. package/lib/dependencies/RequireIncludeDependencyParserPlugin.js +4 -11
  97. package/lib/dependencies/SystemPlugin.js +2 -4
  98. package/lib/dependencies/TopLevelAwaitDependency.js +93 -0
  99. package/lib/dependencies/URLDependency.js +141 -21
  100. package/lib/dependencies/{WorkerPlugin.js → WorkerAndWorkletPlugin.js} +324 -112
  101. package/lib/dependencies/WorkerDependency.js +86 -18
  102. package/lib/dependencies/WorkletDependency.js +278 -0
  103. package/lib/dll/DelegatedModuleFactoryPlugin.js +19 -0
  104. package/lib/errors/EnvironmentNotSupportAsyncWarning.js +1 -1
  105. package/lib/errors/LoaderLoadingError.js +20 -0
  106. package/lib/errors/ModuleParseError.js +39 -22
  107. package/lib/errors/NodeStuffInWebError.js +1 -1
  108. package/lib/esm/ModuleChunkFormatPlugin.js +47 -14
  109. package/lib/esm/ModuleChunkLoadingPlugin.js +8 -1
  110. package/lib/esm/ModuleChunkLoadingRuntimeModule.js +29 -1
  111. package/lib/hmr/lazyCompilationBackend.js +51 -12
  112. package/lib/html/HtmlGenerator.js +907 -15
  113. package/lib/html/HtmlModule.js +2 -2
  114. package/lib/html/HtmlModulesPlugin.js +610 -166
  115. package/lib/html/HtmlParser.js +603 -247
  116. package/lib/html/favicon.svg +1 -0
  117. package/lib/html/syntax.js +3451 -2762
  118. package/lib/ids/IdHelpers.js +25 -11
  119. package/lib/index.js +6 -0
  120. package/lib/javascript/ArrayPushCallbackChunkFormatPlugin.js +4 -5
  121. package/lib/javascript/BasicEvaluatedExpression.js +366 -48
  122. package/lib/javascript/JavascriptGenerator.js +197 -49
  123. package/lib/javascript/JavascriptModulesPlugin.js +178 -24
  124. package/lib/javascript/JavascriptParser.js +704 -355
  125. package/lib/javascript/JavascriptParserHelpers.js +3 -6
  126. package/lib/javascript/syntax.js +5037 -0
  127. package/lib/library/ModuleLibraryPlugin.js +38 -1
  128. package/lib/loaders/LoaderRunner.js +714 -0
  129. package/lib/loaders/loadLoader.js +100 -0
  130. package/lib/node/ReadFileCompileAsyncWasmPlugin.js +29 -2
  131. package/lib/node/ReadFileCompileWasmPlugin.js +24 -2
  132. package/lib/optimize/AggressiveMergingPlugin.js +19 -15
  133. package/lib/optimize/ConcatenatedModule.js +139 -31
  134. package/lib/optimize/FlagIncludedChunksPlugin.js +13 -3
  135. package/lib/optimize/InnerGraphPlugin.js +50 -30
  136. package/lib/optimize/ModuleConcatenationPlugin.js +139 -24
  137. package/lib/optimize/SideEffectsFlagPlugin.js +86 -43
  138. package/lib/optimize/SplitChunksPlugin.js +146 -44
  139. package/lib/prefetch/ChunkPrefetchPreloadPlugin.js +15 -0
  140. package/lib/prefetch/ChunkPreloadTriggerRuntimeModule.js +24 -13
  141. package/lib/prefetch/ResourceHintPlugin.js +687 -0
  142. package/lib/prefetch/ResourceHintRuntimeModule.js +149 -0
  143. package/lib/prefetch/StartupAssetHintRuntimeModule.js +210 -0
  144. package/lib/prefetch/parseResourceHintOptions.js +103 -0
  145. package/lib/rules/RuleSetCompiler.js +114 -0
  146. package/lib/runtime/AsyncModuleGeneratorRuntimeModule.js +56 -0
  147. package/lib/runtime/AsyncModuleRuntimeModule.js +24 -8
  148. package/lib/runtime/AutoPublicPathRuntimeModule.js +7 -1
  149. package/lib/runtime/CommonJsWrapRuntimeModule.js +37 -0
  150. package/lib/runtime/GetWorkletBootstrapRuntimeModule.js +59 -0
  151. package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +204 -8
  152. package/lib/runtime/SetAnonymousDefaultNameRuntimeModule.js +4 -1
  153. package/lib/schemes/HttpUriPlugin.js +40 -1
  154. package/lib/schemes/VirtualUrlPlugin.js +1 -2
  155. package/lib/serialization/BinaryMiddleware.js +270 -938
  156. package/lib/serialization/FileMiddleware.js +29 -3
  157. package/lib/stats/DefaultStatsFactoryPlugin.js +229 -194
  158. package/lib/stats/DefaultStatsPresetPlugin.js +2 -0
  159. package/lib/stats/DefaultStatsPrinterPlugin.js +36 -168
  160. package/lib/stats/StatsFactory.js +46 -17
  161. package/lib/url/URLParserPlugin.js +66 -13
  162. package/lib/util/AsyncQueue.js +122 -72
  163. package/lib/util/SetHelpers.js +1 -1
  164. package/lib/util/StackedMap.js +122 -48
  165. package/lib/util/binarySearchBounds.js +2 -2
  166. package/lib/util/concatenate.js +40 -14
  167. package/lib/util/createHooksRegistry.js +13 -5
  168. package/lib/util/dataURL.js +2 -2
  169. package/lib/util/deterministicGrouping.js +7 -5
  170. package/lib/util/formatSize.js +6 -2
  171. package/lib/util/globUtils.js +710 -0
  172. package/lib/util/identifier.js +23 -6
  173. package/lib/util/implicitTypeLoaderFallback.js +62 -0
  174. package/lib/util/internalSerializables.js +88 -71
  175. package/lib/util/magicComment.js +121 -25
  176. package/lib/util/numberHash.js +2 -2
  177. package/lib/wasm-async/AsyncWasmCompileRuntimeModule.js +24 -18
  178. package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +33 -22
  179. package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +79 -16
  180. package/lib/web/FetchCompileAsyncWasmPlugin.js +19 -0
  181. package/lib/web/FetchCompileWasmPlugin.js +14 -0
  182. package/lib/web/JsonpChunkLoadingRuntimeModule.js +2 -0
  183. package/lib/webpack.js +65 -0
  184. package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +3 -0
  185. package/module.d.ts +21 -0
  186. package/package.json +12 -11
  187. package/schemas/WebpackOptions.check.js +1 -1
  188. package/schemas/WebpackOptions.json +759 -36
  189. package/schemas/plugins/HtmlParserOptions.check.js +1 -1
  190. package/schemas/plugins/ProgressPlugin.check.js +1 -1
  191. package/schemas/plugins/ProgressPlugin.json +17 -1
  192. package/schemas/plugins/container/ContainerReferencePlugin.check.js +1 -1
  193. package/schemas/plugins/container/ContainerReferencePlugin.json +1 -0
  194. package/schemas/plugins/container/ExternalsType.check.js +1 -1
  195. package/schemas/plugins/container/ModuleFederationPlugin.check.js +1 -1
  196. package/schemas/plugins/container/ModuleFederationPlugin.json +1 -0
  197. package/schemas/plugins/css/CssAutoOrModuleParserOptions.check.js +1 -1
  198. package/schemas/plugins/css/CssModuleParserOptions.check.js +1 -1
  199. package/schemas/plugins/css/CssParserOptions.check.js +1 -1
  200. package/types.d.ts +1212 -99
@@ -15,6 +15,13 @@ module.exports.amdDefine = "__webpack_require__.amdD";
15
15
  */
16
16
  module.exports.amdOptions = "__webpack_require__.amdO";
17
17
 
18
+ /**
19
+ * analyzable single-chunk `import()` that keeps `ensureChunk` timing and deduplication:
20
+ * resolves immediately for an installed chunk, else runs the literal import and installs it
21
+ * Signature: (chunkId, () => Promise) => Promise
22
+ */
23
+ module.exports.analyzableChunkImport = "__webpack_require__.ei";
24
+
18
25
  /**
19
26
  * Creates an async module. The body function must be a async function.
20
27
  * "module.exports" will be decorated with an AsyncModulePromise.
@@ -39,6 +46,15 @@ module.exports.asyncModuleDoneSymbol = "__webpack_require__.aD";
39
46
  */
40
47
  module.exports.asyncModuleExportSymbol = "__webpack_require__.aE";
41
48
 
49
+ /**
50
+ * Drives an async module body written as a generator function (used when the
51
+ * target environment supports generators but not `async`/`await`).
52
+ * It runs the generator, resolving each `yield`ed dependency promise, so the
53
+ * body reads like a plain `async` function without emitting `async`/`await`.
54
+ * Signature: function(body: GeneratorFunction) => (handleDependencies, result) => void
55
+ */
56
+ module.exports.asyncModuleGenerator = "__webpack_require__.aG";
57
+
42
58
  /**
43
59
  * the baseURI of current document
44
60
  */
@@ -54,6 +70,11 @@ module.exports.chunkCallback = "webpackChunk";
54
70
  */
55
71
  module.exports.chunkName = "__webpack_require__.cn";
56
72
 
73
+ /**
74
+ * wrap and eagerly execute a CommonJS module body, returning its exports
75
+ */
76
+ module.exports.commonJsWrap = "__webpack_require__.cjs";
77
+
57
78
  /**
58
79
  * compatibility get default export
59
80
  */
@@ -195,6 +216,12 @@ module.exports.getTrustedTypesPolicy = "__webpack_require__.tt";
195
216
  */
196
217
  module.exports.getUpdateManifestFilename = "__webpack_require__.hmrF";
197
218
 
219
+ /**
220
+ * the object url of the worklet bootstrap script (sets up `self`, `location` and
221
+ * a throwing `importScripts` before worklet chunks are added)
222
+ */
223
+ module.exports.getWorkletBootstrap = "__webpack_require__.wb";
224
+
198
225
  /**
199
226
  * the global object
200
227
  */
@@ -331,6 +358,12 @@ module.exports.nodeModuleDecorator = "__webpack_require__.nmd";
331
358
  */
332
359
  module.exports.onChunksLoaded = "__webpack_require__.O";
333
360
 
361
+ /**
362
+ * the asset prefetch function: injects a
363
+ * `<link rel="prefetch">` for an asset module URL
364
+ */
365
+ module.exports.prefetchAsset = "__webpack_require__.PA";
366
+
334
367
  /**
335
368
  * the chunk prefetch function
336
369
  */
@@ -341,6 +374,12 @@ module.exports.prefetchChunk = "__webpack_require__.E";
341
374
  */
342
375
  module.exports.prefetchChunkHandlers = "__webpack_require__.F";
343
376
 
377
+ /**
378
+ * the asset preload function: injects a
379
+ * `<link rel="preload">` for an asset module URL
380
+ */
381
+ module.exports.preloadAsset = "__webpack_require__.LA";
382
+
344
383
  /**
345
384
  * the chunk preload function
346
385
  */
@@ -402,6 +441,14 @@ module.exports.shareScopeMap = "__webpack_require__.S";
402
441
  */
403
442
  module.exports.startup = "__webpack_require__.x";
404
443
 
444
+ /**
445
+ * marker requirement that adds the startup runtime module which fires
446
+ * `<link rel="prefetch|preload">` for `new URL(..., import.meta.url)`
447
+ * assets with `webpackPrefetch` / `webpackPreload` hints, before any
448
+ * chunk module evaluates
449
+ */
450
+ module.exports.startupAssetHints = "__webpack_require__.SAH";
451
+
405
452
  /**
406
453
  * method to startup an entrypoint with needed chunks.
407
454
  * Signature: (moduleId: Id, chunkIds: Id[]) => any.
@@ -9,9 +9,11 @@ const RuntimeGlobals = require("./RuntimeGlobals");
9
9
  const { getPresentKinds } = require("./TemplatedPathPlugin");
10
10
  const RuntimeRequirementsDependency = require("./dependencies/RuntimeRequirementsDependency");
11
11
  const JavascriptModulesPlugin = require("./javascript/JavascriptModulesPlugin");
12
+ const AsyncModuleGeneratorRuntimeModule = require("./runtime/AsyncModuleGeneratorRuntimeModule");
12
13
  const AsyncModuleRuntimeModule = require("./runtime/AsyncModuleRuntimeModule");
13
14
  const AutoPublicPathRuntimeModule = require("./runtime/AutoPublicPathRuntimeModule");
14
15
  const BaseUriRuntimeModule = require("./runtime/BaseUriRuntimeModule");
16
+ const CommonJsWrapRuntimeModule = require("./runtime/CommonJsWrapRuntimeModule");
15
17
  const CompatGetDefaultExportRuntimeModule = require("./runtime/CompatGetDefaultExportRuntimeModule");
16
18
  const CompatRuntimeModule = require("./runtime/CompatRuntimeModule");
17
19
  const CreateFakeNamespaceObjectRuntimeModule = require("./runtime/CreateFakeNamespaceObjectRuntimeModule");
@@ -22,6 +24,7 @@ const EnsureChunkRuntimeModule = require("./runtime/EnsureChunkRuntimeModule");
22
24
  const GetChunkFilenameRuntimeModule = require("./runtime/GetChunkFilenameRuntimeModule");
23
25
  const GetMainFilenameRuntimeModule = require("./runtime/GetMainFilenameRuntimeModule");
24
26
  const GetTrustedTypesPolicyRuntimeModule = require("./runtime/GetTrustedTypesPolicyRuntimeModule");
27
+ const GetWorkletBootstrapRuntimeModule = require("./runtime/GetWorkletBootstrapRuntimeModule");
25
28
  const GlobalRuntimeModule = require("./runtime/GlobalRuntimeModule");
26
29
  const HasOwnPropertyRuntimeModule = require("./runtime/HasOwnPropertyRuntimeModule");
27
30
  const LoadScriptRuntimeModule = require("./runtime/LoadScriptRuntimeModule");
@@ -77,6 +80,7 @@ const GLOBALS_ON_REQUIRE = [
77
80
  RuntimeGlobals.scriptNonce,
78
81
  RuntimeGlobals.uncaughtErrorHandler,
79
82
  RuntimeGlobals.asyncModule,
83
+ RuntimeGlobals.asyncModuleGenerator,
80
84
  RuntimeGlobals.wasmInstances,
81
85
  RuntimeGlobals.instantiateWasm,
82
86
  RuntimeGlobals.shareScopeMap,
@@ -115,6 +119,33 @@ const TREE_DEPENDENCIES = {
115
119
  [RuntimeGlobals.shareScopeMap]: [RuntimeGlobals.hasOwnProperty]
116
120
  };
117
121
 
122
+ // Tree runtime requirements whose only effect is attaching a zero-arg runtime
123
+ // module to the chunk. Conditional / argument-taking ones stay as explicit taps.
124
+ /** @type {[string, (new () => import("./RuntimeModule"))][]} */
125
+ const SIMPLE_TREE_RUNTIME_MODULES = [
126
+ [RuntimeGlobals.definePropertyGetters, DefinePropertyGettersRuntimeModule],
127
+ [RuntimeGlobals.makeNamespaceObject, MakeNamespaceObjectRuntimeModule],
128
+ [
129
+ RuntimeGlobals.createFakeNamespaceObject,
130
+ CreateFakeNamespaceObjectRuntimeModule
131
+ ],
132
+ [RuntimeGlobals.hasOwnProperty, HasOwnPropertyRuntimeModule],
133
+ [RuntimeGlobals.compatGetDefaultExport, CompatGetDefaultExportRuntimeModule],
134
+ [RuntimeGlobals.commonJsWrap, CommonJsWrapRuntimeModule],
135
+ [
136
+ RuntimeGlobals.setAnonymousDefaultName,
137
+ SetAnonymousDefaultNameRuntimeModule
138
+ ],
139
+ [RuntimeGlobals.runtimeId, RuntimeIdRuntimeModule],
140
+ [RuntimeGlobals.global, GlobalRuntimeModule],
141
+ [RuntimeGlobals.shareScopeMap, ShareRuntimeModule],
142
+ [RuntimeGlobals.relativeUrl, RelativeUrlRuntimeModule],
143
+ [RuntimeGlobals.worker, WorkerRuntimeModule],
144
+ [RuntimeGlobals.onChunksLoaded, OnChunksLoadedRuntimeModule],
145
+ [RuntimeGlobals.scriptNonce, NonceRuntimeModule],
146
+ [RuntimeGlobals.toBinary, ToBinaryRuntimeModule]
147
+ ];
148
+
118
149
  /**
119
150
  * @param {string} template path template
120
151
  * @returns {boolean} true when it references the compilation `[fullhash]`/`[hash]`
@@ -194,36 +225,20 @@ class RuntimePlugin {
194
225
  for (const dep of deps) set.add(dep);
195
226
  });
196
227
  }
197
- compilation.hooks.runtimeRequirementInTree
198
- .for(RuntimeGlobals.definePropertyGetters)
199
- .tap(PLUGIN_NAME, (chunk) => {
200
- compilation.addRuntimeModule(
201
- chunk,
202
- new DefinePropertyGettersRuntimeModule()
203
- );
204
- return true;
205
- });
206
- compilation.hooks.runtimeRequirementInTree
207
- .for(RuntimeGlobals.makeNamespaceObject)
208
- .tap(PLUGIN_NAME, (chunk) => {
209
- compilation.addRuntimeModule(
210
- chunk,
211
- new MakeNamespaceObjectRuntimeModule()
212
- );
213
- return true;
214
- });
215
- compilation.hooks.runtimeRequirementInTree
216
- .for(RuntimeGlobals.createFakeNamespaceObject)
217
- .tap(PLUGIN_NAME, (chunk) => {
218
- compilation.addRuntimeModule(
219
- chunk,
220
- new CreateFakeNamespaceObjectRuntimeModule()
221
- );
222
- return true;
223
- });
228
+ for (const [
229
+ runtimeGlobal,
230
+ RuntimeModule
231
+ ] of SIMPLE_TREE_RUNTIME_MODULES) {
232
+ compilation.hooks.runtimeRequirementInTree
233
+ .for(runtimeGlobal)
234
+ .tap(PLUGIN_NAME, (chunk) => {
235
+ compilation.addRuntimeModule(chunk, new RuntimeModule());
236
+ return true;
237
+ });
238
+ }
224
239
  compilation.hooks.runtimeRequirementInTree
225
240
  .for(RuntimeGlobals.makeOptimizedDeferredNamespaceObject)
226
- .tap("RuntimePlugin", (chunk, runtimeRequirement) => {
241
+ .tap(PLUGIN_NAME, (chunk, runtimeRequirement) => {
227
242
  compilation.addRuntimeModule(
228
243
  chunk,
229
244
  new MakeOptimizedDeferredNamespaceObjectRuntimeModule(
@@ -234,7 +249,7 @@ class RuntimePlugin {
234
249
  });
235
250
  compilation.hooks.runtimeRequirementInTree
236
251
  .for(RuntimeGlobals.makeDeferredNamespaceObject)
237
- .tap("RuntimePlugin", (chunk, runtimeRequirement) => {
252
+ .tap(PLUGIN_NAME, (chunk, runtimeRequirement) => {
238
253
  compilation.addRuntimeModule(
239
254
  chunk,
240
255
  new MakeDeferredNamespaceObjectRuntimeModule(
@@ -243,39 +258,6 @@ class RuntimePlugin {
243
258
  );
244
259
  return true;
245
260
  });
246
- compilation.hooks.runtimeRequirementInTree
247
- .for(RuntimeGlobals.hasOwnProperty)
248
- .tap(PLUGIN_NAME, (chunk) => {
249
- compilation.addRuntimeModule(
250
- chunk,
251
- new HasOwnPropertyRuntimeModule()
252
- );
253
- return true;
254
- });
255
- compilation.hooks.runtimeRequirementInTree
256
- .for(RuntimeGlobals.compatGetDefaultExport)
257
- .tap(PLUGIN_NAME, (chunk) => {
258
- compilation.addRuntimeModule(
259
- chunk,
260
- new CompatGetDefaultExportRuntimeModule()
261
- );
262
- return true;
263
- });
264
- compilation.hooks.runtimeRequirementInTree
265
- .for(RuntimeGlobals.setAnonymousDefaultName)
266
- .tap(PLUGIN_NAME, (chunk) => {
267
- compilation.addRuntimeModule(
268
- chunk,
269
- new SetAnonymousDefaultNameRuntimeModule()
270
- );
271
- return true;
272
- });
273
- compilation.hooks.runtimeRequirementInTree
274
- .for(RuntimeGlobals.runtimeId)
275
- .tap(PLUGIN_NAME, (chunk) => {
276
- compilation.addRuntimeModule(chunk, new RuntimeIdRuntimeModule());
277
- return true;
278
- });
279
261
  compilation.hooks.runtimeRequirementInTree
280
262
  .for(RuntimeGlobals.publicPath)
281
263
  .tap(PLUGIN_NAME, (chunk, set) => {
@@ -289,8 +271,11 @@ class RuntimePlugin {
289
271
 
290
272
  if (publicPath === "auto") {
291
273
  const module = new AutoPublicPathRuntimeModule();
274
+ // A worklet chunk reads `import.meta.url`, so it needs neither the
275
+ // worker-scope detection nor the `globalThis` polyfill.
292
276
  if (
293
277
  scriptType !== "module" &&
278
+ !(entryOptions && entryOptions.worklet) &&
294
279
  !outputOptions.environment.globalThis
295
280
  ) {
296
281
  set.add(RuntimeGlobals.global);
@@ -308,12 +293,6 @@ class RuntimePlugin {
308
293
  }
309
294
  return true;
310
295
  });
311
- compilation.hooks.runtimeRequirementInTree
312
- .for(RuntimeGlobals.global)
313
- .tap(PLUGIN_NAME, (chunk) => {
314
- compilation.addRuntimeModule(chunk, new GlobalRuntimeModule());
315
- return true;
316
- });
317
296
  compilation.hooks.runtimeRequirementInTree
318
297
  .for(RuntimeGlobals.asyncModule)
319
298
  .tap(PLUGIN_NAME, (chunk) => {
@@ -324,6 +303,16 @@ class RuntimePlugin {
324
303
  );
325
304
  return true;
326
305
  });
306
+ compilation.hooks.runtimeRequirementInTree
307
+ .for(RuntimeGlobals.asyncModuleGenerator)
308
+ .tap(PLUGIN_NAME, (chunk, set) => {
309
+ set.add(RuntimeGlobals.asyncModule);
310
+ compilation.addRuntimeModule(
311
+ chunk,
312
+ new AsyncModuleGeneratorRuntimeModule()
313
+ );
314
+ return true;
315
+ });
327
316
  compilation.hooks.runtimeRequirementInTree
328
317
  .for(RuntimeGlobals.systemContext)
329
318
  .tap(PLUGIN_NAME, (chunk) => {
@@ -375,6 +364,16 @@ class RuntimePlugin {
375
364
  );
376
365
  return true;
377
366
  });
367
+ compilation.hooks.runtimeRequirementInTree
368
+ .for(RuntimeGlobals.getWorkletBootstrap)
369
+ .tap(PLUGIN_NAME, (chunk, set) => {
370
+ set.add(RuntimeGlobals.baseURI);
371
+ compilation.addRuntimeModule(
372
+ chunk,
373
+ new GetWorkletBootstrapRuntimeModule()
374
+ );
375
+ return true;
376
+ });
378
377
  compilation.hooks.runtimeRequirementInTree
379
378
  .for(RuntimeGlobals.getChunkCssFilename)
380
379
  .tap(PLUGIN_NAME, (chunk, set, { chunkGraph }) => {
@@ -467,12 +466,6 @@ class RuntimePlugin {
467
466
  .tap(PLUGIN_NAME, (chunk, set) => {
468
467
  set.add(RuntimeGlobals.ensureChunkHandlers);
469
468
  });
470
- compilation.hooks.runtimeRequirementInTree
471
- .for(RuntimeGlobals.shareScopeMap)
472
- .tap(PLUGIN_NAME, (chunk, set) => {
473
- compilation.addRuntimeModule(chunk, new ShareRuntimeModule());
474
- return true;
475
- });
476
469
  compilation.hooks.runtimeRequirementInTree
477
470
  .for(RuntimeGlobals.loadScript)
478
471
  .tap(PLUGIN_NAME, (chunk, set) => {
@@ -519,27 +512,6 @@ class RuntimePlugin {
519
512
  );
520
513
  return true;
521
514
  });
522
- compilation.hooks.runtimeRequirementInTree
523
- .for(RuntimeGlobals.relativeUrl)
524
- .tap(PLUGIN_NAME, (chunk, _set) => {
525
- compilation.addRuntimeModule(chunk, new RelativeUrlRuntimeModule());
526
- return true;
527
- });
528
- compilation.hooks.runtimeRequirementInTree
529
- .for(RuntimeGlobals.worker)
530
- .tap(PLUGIN_NAME, (chunk, _set) => {
531
- compilation.addRuntimeModule(chunk, new WorkerRuntimeModule());
532
- return true;
533
- });
534
- compilation.hooks.runtimeRequirementInTree
535
- .for(RuntimeGlobals.onChunksLoaded)
536
- .tap(PLUGIN_NAME, (chunk, _set) => {
537
- compilation.addRuntimeModule(
538
- chunk,
539
- new OnChunksLoadedRuntimeModule()
540
- );
541
- return true;
542
- });
543
515
  compilation.hooks.runtimeRequirementInTree
544
516
  .for(RuntimeGlobals.baseURI)
545
517
  .tap(PLUGIN_NAME, (chunk) => {
@@ -548,18 +520,6 @@ class RuntimePlugin {
548
520
  return true;
549
521
  }
550
522
  });
551
- compilation.hooks.runtimeRequirementInTree
552
- .for(RuntimeGlobals.scriptNonce)
553
- .tap(PLUGIN_NAME, (chunk) => {
554
- compilation.addRuntimeModule(chunk, new NonceRuntimeModule());
555
- return true;
556
- });
557
- compilation.hooks.runtimeRequirementInTree
558
- .for(RuntimeGlobals.toBinary)
559
- .tap(PLUGIN_NAME, (chunk) => {
560
- compilation.addRuntimeModule(chunk, new ToBinaryRuntimeModule());
561
- return true;
562
- });
563
523
  // TODO webpack 6: remove CompatRuntimeModule
564
524
  compilation.hooks.additionalTreeRuntimeRequirements.tap(
565
525
  PLUGIN_NAME,