webpack 5.88.2 → 5.90.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 (151) hide show
  1. package/README.md +3 -0
  2. package/bin/webpack.js +1 -3
  3. package/hot/log.js +0 -2
  4. package/lib/APIPlugin.js +1 -1
  5. package/lib/ChunkGraph.js +1 -1
  6. package/lib/CleanPlugin.js +12 -12
  7. package/lib/Compilation.js +25 -16
  8. package/lib/Compiler.js +13 -0
  9. package/lib/ConcatenationScope.js +2 -2
  10. package/lib/ContextModule.js +4 -4
  11. package/lib/ContextModuleFactory.js +1 -1
  12. package/lib/DependencyTemplate.js +3 -1
  13. package/lib/EnvironmentNotSupportAsyncWarning.js +52 -0
  14. package/lib/EvalDevToolModulePlugin.js +1 -1
  15. package/lib/EvalSourceMapDevToolPlugin.js +1 -1
  16. package/lib/ExportsInfoApiPlugin.js +2 -2
  17. package/lib/ExternalModule.js +47 -12
  18. package/lib/ExternalModuleFactoryPlugin.js +1 -1
  19. package/lib/FileSystemInfo.js +20 -3
  20. package/lib/FlagDependencyExportsPlugin.js +1 -1
  21. package/lib/Generator.js +1 -0
  22. package/lib/HotModuleReplacementPlugin.js +3 -3
  23. package/lib/LibManifestPlugin.js +4 -1
  24. package/lib/Module.js +2 -1
  25. package/lib/ModuleFilenameHelpers.js +1 -1
  26. package/lib/ModuleInfoHeaderPlugin.js +1 -1
  27. package/lib/MultiStats.js +2 -2
  28. package/lib/NodeStuffPlugin.js +48 -0
  29. package/lib/NormalModule.js +13 -11
  30. package/lib/NormalModuleFactory.js +7 -7
  31. package/lib/RuntimeTemplate.js +15 -11
  32. package/lib/SourceMapDevToolPlugin.js +2 -2
  33. package/lib/WebpackOptionsApply.js +4 -3
  34. package/lib/asset/AssetModulesPlugin.js +2 -3
  35. package/lib/cache/AddManagedPathsPlugin.js +6 -1
  36. package/lib/cache/IdleFileCachePlugin.js +12 -5
  37. package/lib/cache/PackFileCacheStrategy.js +3 -3
  38. package/lib/cache/ResolverCachePlugin.js +2 -2
  39. package/lib/config/browserslistTargetHandler.js +24 -5
  40. package/lib/config/defaults.js +87 -52
  41. package/lib/config/normalization.js +17 -18
  42. package/lib/config/target.js +5 -0
  43. package/lib/container/ContainerReferencePlugin.js +1 -1
  44. package/lib/css/CssExportsGenerator.js +14 -1
  45. package/lib/css/CssGenerator.js +14 -1
  46. package/lib/css/CssLoadingRuntimeModule.js +23 -23
  47. package/lib/css/CssModulesPlugin.js +68 -32
  48. package/lib/css/CssParser.js +8 -3
  49. package/lib/debug/ProfilingPlugin.js +2 -2
  50. package/lib/dependencies/CachedConstDependency.js +8 -1
  51. package/lib/dependencies/CommonJsFullRequireDependency.js +27 -6
  52. package/lib/dependencies/CommonJsImportsParserPlugin.js +21 -5
  53. package/lib/dependencies/ContextElementDependency.js +1 -1
  54. package/lib/dependencies/ExternalModuleDependency.js +98 -0
  55. package/lib/dependencies/ExternalModuleInitFragment.js +124 -0
  56. package/lib/dependencies/HarmonyAcceptDependency.js +1 -1
  57. package/lib/dependencies/HarmonyDetectionParserPlugin.js +7 -1
  58. package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +18 -18
  59. package/lib/dependencies/HarmonyExportInitFragment.js +4 -4
  60. package/lib/dependencies/HarmonyImportDependency.js +4 -4
  61. package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +6 -6
  62. package/lib/dependencies/HarmonyImportSpecifierDependency.js +13 -63
  63. package/lib/dependencies/ImportDependency.js +26 -6
  64. package/lib/dependencies/JsonExportsDependency.js +1 -1
  65. package/lib/dependencies/LoaderPlugin.js +2 -1
  66. package/lib/dependencies/PureExpressionDependency.js +12 -4
  67. package/lib/dependencies/RequireIncludeDependency.js +1 -1
  68. package/lib/dependencies/WebpackIsIncludedDependency.js +1 -1
  69. package/lib/dependencies/WorkerPlugin.js +7 -1
  70. package/lib/esm/ModuleChunkLoadingRuntimeModule.js +6 -6
  71. package/lib/hmr/HotModuleReplacement.runtime.js +3 -5
  72. package/lib/hmr/lazyCompilationBackend.js +4 -4
  73. package/lib/ids/DeterministicModuleIdsPlugin.js +1 -1
  74. package/lib/index.js +4 -0
  75. package/lib/javascript/JavascriptGenerator.js +16 -1
  76. package/lib/javascript/JavascriptModulesPlugin.js +33 -33
  77. package/lib/javascript/JavascriptParser.js +18 -6
  78. package/lib/json/JsonGenerator.js +1 -1
  79. package/lib/library/AmdLibraryPlugin.js +5 -1
  80. package/lib/library/AssignLibraryPlugin.js +1 -1
  81. package/lib/library/SystemLibraryPlugin.js +1 -1
  82. package/lib/library/UmdLibraryPlugin.js +39 -39
  83. package/lib/logging/createConsoleLogger.js +1 -19
  84. package/lib/node/ReadFileChunkLoadingRuntimeModule.js +8 -8
  85. package/lib/node/RequireChunkLoadingRuntimeModule.js +8 -8
  86. package/lib/node/nodeConsole.js +1 -5
  87. package/lib/optimize/ConcatenatedModule.js +7 -7
  88. package/lib/optimize/InnerGraphPlugin.js +9 -1
  89. package/lib/optimize/ModuleConcatenationPlugin.js +2 -2
  90. package/lib/optimize/RemoveParentModulesPlugin.js +123 -47
  91. package/lib/optimize/SideEffectsFlagPlugin.js +15 -3
  92. package/lib/optimize/SplitChunksPlugin.js +16 -16
  93. package/lib/prefetch/ChunkPrefetchStartupRuntimeModule.js +2 -2
  94. package/lib/rules/RuleSetCompiler.js +1 -1
  95. package/lib/runtime/AutoPublicPathRuntimeModule.js +2 -2
  96. package/lib/runtime/GetChunkFilenameRuntimeModule.js +4 -4
  97. package/lib/runtime/GetTrustedTypesPolicyRuntimeModule.js +4 -4
  98. package/lib/runtime/LoadScriptRuntimeModule.js +2 -2
  99. package/lib/runtime/StartupChunkDependenciesRuntimeModule.js +23 -22
  100. package/lib/runtime/StartupEntrypointRuntimeModule.js +2 -2
  101. package/lib/schemes/HttpUriPlugin.js +1 -1
  102. package/lib/serialization/FileMiddleware.js +4 -4
  103. package/lib/serialization/ObjectMiddleware.js +4 -4
  104. package/lib/sharing/ConsumeSharedPlugin.js +5 -5
  105. package/lib/sharing/ConsumeSharedRuntimeModule.js +8 -4
  106. package/lib/sharing/ProvideSharedModule.js +2 -2
  107. package/lib/sharing/SharePlugin.js +2 -2
  108. package/lib/sharing/ShareRuntimeModule.js +1 -1
  109. package/lib/sharing/utils.js +24 -28
  110. package/lib/stats/DefaultStatsFactoryPlugin.js +10 -10
  111. package/lib/stats/DefaultStatsPresetPlugin.js +3 -7
  112. package/lib/stats/DefaultStatsPrinterPlugin.js +34 -31
  113. package/lib/util/chainedImports.js +96 -0
  114. package/lib/util/cleverMerge.js +4 -4
  115. package/lib/util/hash/xxhash64.js +2 -2
  116. package/lib/util/identifier.js +2 -2
  117. package/lib/util/internalSerializables.js +6 -0
  118. package/lib/util/runtime.js +18 -1
  119. package/lib/util/semver.js +19 -24
  120. package/lib/util/smartGrouping.js +1 -1
  121. package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +1 -1
  122. package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +2 -2
  123. package/lib/wasm-async/AsyncWebAssemblyParser.js +6 -0
  124. package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +2 -2
  125. package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +2 -2
  126. package/lib/web/JsonpChunkLoadingRuntimeModule.js +13 -13
  127. package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +6 -6
  128. package/package.json +23 -23
  129. package/schemas/WebpackOptions.check.js +1 -1
  130. package/schemas/WebpackOptions.json +140 -32
  131. package/schemas/plugins/css/CssAutoGeneratorOptions.check.d.ts +7 -0
  132. package/schemas/plugins/css/CssAutoGeneratorOptions.check.js +6 -0
  133. package/schemas/plugins/css/CssAutoGeneratorOptions.json +3 -0
  134. package/schemas/plugins/css/CssAutoParserOptions.check.d.ts +7 -0
  135. package/schemas/plugins/css/CssAutoParserOptions.check.js +6 -0
  136. package/schemas/plugins/css/CssAutoParserOptions.json +3 -0
  137. package/schemas/plugins/css/CssGeneratorOptions.check.js +1 -1
  138. package/schemas/plugins/css/CssGlobalGeneratorOptions.check.d.ts +7 -0
  139. package/schemas/plugins/css/CssGlobalGeneratorOptions.check.js +6 -0
  140. package/schemas/plugins/css/CssGlobalGeneratorOptions.json +3 -0
  141. package/schemas/plugins/css/CssGlobalParserOptions.check.d.ts +7 -0
  142. package/schemas/plugins/css/CssGlobalParserOptions.check.js +6 -0
  143. package/schemas/plugins/css/CssGlobalParserOptions.json +3 -0
  144. package/schemas/plugins/css/CssModuleGeneratorOptions.check.d.ts +7 -0
  145. package/schemas/plugins/css/CssModuleGeneratorOptions.check.js +6 -0
  146. package/schemas/plugins/css/CssModuleGeneratorOptions.json +3 -0
  147. package/schemas/plugins/css/CssModuleParserOptions.check.d.ts +7 -0
  148. package/schemas/plugins/css/CssModuleParserOptions.check.js +6 -0
  149. package/schemas/plugins/css/CssModuleParserOptions.json +3 -0
  150. package/schemas/plugins/css/CssParserOptions.check.js +1 -1
  151. package/types.d.ts +180 -22
@@ -179,7 +179,7 @@ class ConsumeSharedRuntimeModule extends RuntimeModule {
179
179
  ? runtimeTemplate.basicFunction("", "")
180
180
  : runtimeTemplate.basicFunction("msg", [
181
181
  'if (typeof console !== "undefined" && console.warn) console.warn(msg);'
182
- ])
182
+ ])
183
183
  };`,
184
184
  `var warnInvalidVersion = ${runtimeTemplate.basicFunction(
185
185
  "scope, scopeName, key, requiredVersion",
@@ -312,7 +312,7 @@ class ConsumeSharedRuntimeModule extends RuntimeModule {
312
312
  `module.exports = factory();`
313
313
  ])}`
314
314
  ])});`
315
- ])
315
+ ])
316
316
  : "// no consumes in initial chunks",
317
317
  this._runtimeRequirements.has(RuntimeGlobals.ensureChunkHandlers)
318
318
  ? Template.asString([
@@ -321,6 +321,7 @@ class ConsumeSharedRuntimeModule extends RuntimeModule {
321
321
  null,
322
322
  "\t"
323
323
  )};`,
324
+ "var startedInstallModules = {};",
324
325
  `${
325
326
  RuntimeGlobals.ensureChunkHandlers
326
327
  }.consumes = ${runtimeTemplate.basicFunction("chunkId, promises", [
@@ -330,6 +331,7 @@ class ConsumeSharedRuntimeModule extends RuntimeModule {
330
331
  "id",
331
332
  [
332
333
  `if(${RuntimeGlobals.hasOwnProperty}(installedModules, id)) return promises.push(installedModules[id]);`,
334
+ "if(!startedInstallModules[id]) {",
333
335
  `var onFactory = ${runtimeTemplate.basicFunction(
334
336
  "factory",
335
337
  [
@@ -342,6 +344,7 @@ class ConsumeSharedRuntimeModule extends RuntimeModule {
342
344
  ])}`
343
345
  ]
344
346
  )};`,
347
+ "startedInstallModules[id] = true;",
345
348
  `var onError = ${runtimeTemplate.basicFunction("error", [
346
349
  "delete installedModules[id];",
347
350
  `${
@@ -360,13 +363,14 @@ class ConsumeSharedRuntimeModule extends RuntimeModule {
360
363
  ),
361
364
  "} else onFactory(promise);"
362
365
  ]),
363
- "} catch(e) { onError(e); }"
366
+ "} catch(e) { onError(e); }",
367
+ "}"
364
368
  ]
365
369
  )});`
366
370
  ]),
367
371
  "}"
368
372
  ])}`
369
- ])
373
+ ])
370
374
  : "// no chunk loading of consumes"
371
375
  ]);
372
376
  }
@@ -141,13 +141,13 @@ class ProvideSharedModule extends Module {
141
141
  chunkGraph,
142
142
  request: this._request,
143
143
  runtimeRequirements
144
- })
144
+ })
145
145
  : runtimeTemplate.asyncModuleFactory({
146
146
  block: this.blocks[0],
147
147
  chunkGraph,
148
148
  request: this._request,
149
149
  runtimeRequirements
150
- })
150
+ })
151
151
  }${this._eager ? ", 1" : ""});`;
152
152
  const sources = new Map();
153
153
  const data = new Map();
@@ -34,11 +34,11 @@ class SharePlugin {
34
34
  item === key || !isRequiredVersion(item)
35
35
  ? {
36
36
  import: item
37
- }
37
+ }
38
38
  : {
39
39
  import: key,
40
40
  requiredVersion: item
41
- };
41
+ };
42
42
  return config;
43
43
  },
44
44
  item => item
@@ -89,7 +89,7 @@ class ShareRuntimeModule extends RuntimeModule {
89
89
  ? runtimeTemplate.basicFunction("", "")
90
90
  : runtimeTemplate.basicFunction("msg", [
91
91
  'if (typeof console !== "undefined" && console.warn) console.warn(msg);'
92
- ])
92
+ ])
93
93
  };`,
94
94
  `var uniqueName = ${JSON.stringify(uniqueName || undefined)};`,
95
95
  `var register = ${runtimeTemplate.basicFunction(
@@ -371,33 +371,29 @@ const getDescriptionFile = (fs, directory, descriptionFiles, callback) => {
371
371
  };
372
372
  exports.getDescriptionFile = getDescriptionFile;
373
373
 
374
- exports.getRequiredVersionFromDescriptionFile = (data, packageName) => {
375
- if (
376
- data.optionalDependencies &&
377
- typeof data.optionalDependencies === "object" &&
378
- packageName in data.optionalDependencies
379
- ) {
380
- return normalizeVersion(data.optionalDependencies[packageName]);
381
- }
382
- if (
383
- data.dependencies &&
384
- typeof data.dependencies === "object" &&
385
- packageName in data.dependencies
386
- ) {
387
- return normalizeVersion(data.dependencies[packageName]);
388
- }
389
- if (
390
- data.peerDependencies &&
391
- typeof data.peerDependencies === "object" &&
392
- packageName in data.peerDependencies
393
- ) {
394
- return normalizeVersion(data.peerDependencies[packageName]);
395
- }
396
- if (
397
- data.devDependencies &&
398
- typeof data.devDependencies === "object" &&
399
- packageName in data.devDependencies
400
- ) {
401
- return normalizeVersion(data.devDependencies[packageName]);
374
+ /**
375
+ *
376
+ * @param {object} data description file data i.e.: package.json
377
+ * @param {string} packageName name of the dependency
378
+ * @returns {string} normalized version
379
+ */
380
+ const getRequiredVersionFromDescriptionFile = (data, packageName) => {
381
+ const dependencyTypes = [
382
+ "optionalDependencies",
383
+ "dependencies",
384
+ "peerDependencies",
385
+ "devDependencies"
386
+ ];
387
+
388
+ for (const dependencyType of dependencyTypes) {
389
+ if (
390
+ data[dependencyType] &&
391
+ typeof data[dependencyType] === "object" &&
392
+ packageName in data[dependencyType]
393
+ ) {
394
+ return normalizeVersion(data[dependencyType][packageName]);
395
+ }
402
396
  }
403
397
  };
398
+ exports.getRequiredVersionFromDescriptionFile =
399
+ getRequiredVersionFromDescriptionFile;
@@ -1068,7 +1068,7 @@ const SIMPLE_EXTRACTORS = {
1068
1068
 
1069
1069
  return childStatsChunkGroup;
1070
1070
  })
1071
- )
1071
+ )
1072
1072
  : undefined,
1073
1073
  childAssets: children
1074
1074
  ? mapObject(children, groups => {
@@ -1082,7 +1082,7 @@ const SIMPLE_EXTRACTORS = {
1082
1082
  }
1083
1083
  }
1084
1084
  return Array.from(set);
1085
- })
1085
+ })
1086
1086
  : undefined
1087
1087
  };
1088
1088
  Object.assign(object, statsChunkGroup);
@@ -1379,8 +1379,8 @@ const SIMPLE_EXTRACTORS = {
1379
1379
  chunk.runtime === undefined
1380
1380
  ? undefined
1381
1381
  : typeof chunk.runtime === "string"
1382
- ? [makePathsRelative(chunk.runtime)]
1383
- : Array.from(chunk.runtime.sort(), makePathsRelative),
1382
+ ? [makePathsRelative(chunk.runtime)]
1383
+ : Array.from(chunk.runtime.sort(), makePathsRelative),
1384
1384
  files: Array.from(chunk.files),
1385
1385
  auxiliaryFiles: Array.from(chunk.auxiliaryFiles).sort(compareIds),
1386
1386
  hash: chunk.renderedHash,
@@ -1633,8 +1633,8 @@ const getItemSize = item => {
1633
1633
  return !item.children
1634
1634
  ? 1
1635
1635
  : item.filteredChildren
1636
- ? 2 + getTotalSize(item.children)
1637
- : 1 + getTotalSize(item.children);
1636
+ ? 2 + getTotalSize(item.children)
1637
+ : 1 + getTotalSize(item.children);
1638
1638
  };
1639
1639
 
1640
1640
  const getTotalSize = children => {
@@ -1912,13 +1912,13 @@ const ASSETS_GROUPERS = {
1912
1912
  [name]: !!key,
1913
1913
  filteredChildren: assets.length,
1914
1914
  ...assetGroup(children, assets)
1915
- }
1915
+ }
1916
1916
  : {
1917
1917
  type: "assets by status",
1918
1918
  [name]: !!key,
1919
1919
  children,
1920
1920
  ...assetGroup(children, assets)
1921
- };
1921
+ };
1922
1922
  }
1923
1923
  });
1924
1924
  };
@@ -2169,8 +2169,8 @@ const MODULES_GROUPERS = type => ({
2169
2169
  type: isDataUrl
2170
2170
  ? "modules by mime type"
2171
2171
  : groupModulesByPath
2172
- ? "modules by path"
2173
- : "modules by extension",
2172
+ ? "modules by path"
2173
+ : "modules by extension",
2174
2174
  name: isDataUrl ? key.slice(/* 'data:'.length */ 5) : key,
2175
2175
  children,
2176
2176
  ...moduleGroup(children, modules)
@@ -197,8 +197,8 @@ const DEFAULTS = {
197
197
  runtime !== undefined
198
198
  ? runtime
199
199
  : forToString
200
- ? all === true
201
- : all !== false,
200
+ ? all === true
201
+ : all !== false,
202
202
  cachedModules: ({ all, cached }, { forToString }) =>
203
203
  cached !== undefined ? cached : forToString ? all === true : all !== false,
204
204
  moduleAssets: OFF_FOR_TO_STRING,
@@ -238,11 +238,7 @@ const DEFAULTS = {
238
238
  const normalizeFilter = item => {
239
239
  if (typeof item === "string") {
240
240
  const regExp = new RegExp(
241
- `[\\\\/]${item.replace(
242
- // eslint-disable-next-line no-useless-escape
243
- /[-[\]{}()*+?.\\^$|]/g,
244
- "\\$&"
245
- )}([\\\\/]|$|!|\\?)`
241
+ `[\\\\/]${item.replace(/[-[\]{}()*+?.\\^$|]/g, "\\$&")}([\\\\/]|$|!|\\?)`
246
242
  );
247
243
  return ident => regExp.test(ident);
248
244
  }
@@ -128,7 +128,7 @@ const SIMPLE_PRINTERS = {
128
128
  warningsCount > 0
129
129
  ? yellow(
130
130
  `${warningsCount} ${plural(warningsCount, "warning", "warnings")}`
131
- )
131
+ )
132
132
  : "";
133
133
  const errorsMessage =
134
134
  errorsCount > 0
@@ -143,10 +143,10 @@ const SIMPLE_PRINTERS = {
143
143
  root && name
144
144
  ? bold(name)
145
145
  : name
146
- ? `Child ${bold(name)}`
147
- : root
148
- ? ""
149
- : "Child";
146
+ ? `Child ${bold(name)}`
147
+ : root
148
+ ? ""
149
+ : "Child";
150
150
  const subjectMessage =
151
151
  nameMessage && versionMessage
152
152
  ? `${nameMessage} (${versionMessage})`
@@ -180,7 +180,7 @@ const SIMPLE_PRINTERS = {
180
180
  count,
181
181
  "warning has",
182
182
  "warnings have"
183
- )} detailed information that is not shown.\nUse 'stats.errorDetails: true' resp. '--stats-error-details' to show it.`
183
+ )} detailed information that is not shown.\nUse 'stats.errorDetails: true' resp. '--stats-error-details' to show it.`
184
184
  : undefined,
185
185
  "compilation.filteredErrorDetailsCount": (count, { yellow }) =>
186
186
  count
@@ -190,7 +190,7 @@ const SIMPLE_PRINTERS = {
190
190
  "error has",
191
191
  "errors have"
192
192
  )} detailed information that is not shown.\nUse 'stats.errorDetails: true' resp. '--stats-error-details' to show it.`
193
- )
193
+ )
194
194
  : undefined,
195
195
  "compilation.env": (env, { bold }) =>
196
196
  env
@@ -204,7 +204,7 @@ const SIMPLE_PRINTERS = {
204
204
  : printer.print(context.type, Object.values(entrypoints), {
205
205
  ...context,
206
206
  chunkGroupKind: "Entrypoint"
207
- }),
207
+ }),
208
208
  "compilation.namedChunkGroups": (namedChunkGroups, context, printer) => {
209
209
  if (!Array.isArray(namedChunkGroups)) {
210
210
  const {
@@ -234,15 +234,18 @@ const SIMPLE_PRINTERS = {
234
234
  filteredModules,
235
235
  "module",
236
236
  "modules"
237
- )}`
237
+ )}`
238
238
  : undefined,
239
- "compilation.filteredAssets": (filteredAssets, { compilation: { assets } }) =>
239
+ "compilation.filteredAssets": (
240
+ filteredAssets,
241
+ { compilation: { assets } }
242
+ ) =>
240
243
  filteredAssets > 0
241
244
  ? `${moreCount(assets, filteredAssets)} ${plural(
242
245
  filteredAssets,
243
246
  "asset",
244
247
  "assets"
245
- )}`
248
+ )}`
246
249
  : undefined,
247
250
  "compilation.logging": (logging, context, printer) =>
248
251
  Array.isArray(logging)
@@ -251,7 +254,7 @@ const SIMPLE_PRINTERS = {
251
254
  context.type,
252
255
  Object.entries(logging).map(([name, value]) => ({ ...value, name })),
253
256
  context
254
- ),
257
+ ),
255
258
  "compilation.warningsInChildren!": (_, { yellow, compilation }) => {
256
259
  if (
257
260
  !compilation.children &&
@@ -324,7 +327,7 @@ const SIMPLE_PRINTERS = {
324
327
  sourceFilename === true
325
328
  ? "from source file"
326
329
  : `from: ${sourceFilename}`
327
- )
330
+ )
328
331
  : undefined,
329
332
  "asset.info.development": (development, { green, formatFlag }) =>
330
333
  development ? green(formatFlag("dev")) : undefined,
@@ -339,7 +342,7 @@ const SIMPLE_PRINTERS = {
339
342
  filteredRelated,
340
343
  "asset",
341
344
  "assets"
342
- )}`
345
+ )}`
343
346
  : undefined,
344
347
  "asset.filteredChildren": (filteredChildren, { asset: { children } }) =>
345
348
  filteredChildren > 0
@@ -347,7 +350,7 @@ const SIMPLE_PRINTERS = {
347
350
  filteredChildren,
348
351
  "asset",
349
352
  "assets"
350
- )}`
353
+ )}`
351
354
  : undefined,
352
355
 
353
356
  assetChunk: (id, { formatChunkId }) => formatChunkId(id),
@@ -393,22 +396,22 @@ const SIMPLE_PRINTERS = {
393
396
  formatFlag(
394
397
  `${assets.length} ${plural(assets.length, "asset", "assets")}`
395
398
  )
396
- )
399
+ )
397
400
  : undefined,
398
401
  "module.warnings": (warnings, { formatFlag, yellow }) =>
399
402
  warnings === true
400
403
  ? yellow(formatFlag("warnings"))
401
404
  : warnings
402
- ? yellow(
403
- formatFlag(`${warnings} ${plural(warnings, "warning", "warnings")}`)
404
- )
405
- : undefined,
405
+ ? yellow(
406
+ formatFlag(`${warnings} ${plural(warnings, "warning", "warnings")}`)
407
+ )
408
+ : undefined,
406
409
  "module.errors": (errors, { formatFlag, red }) =>
407
410
  errors === true
408
411
  ? red(formatFlag("errors"))
409
412
  : errors
410
- ? red(formatFlag(`${errors} ${plural(errors, "error", "errors")}`))
411
- : undefined,
413
+ ? red(formatFlag(`${errors} ${plural(errors, "error", "errors")}`))
414
+ : undefined,
412
415
  "module.providedExports": (providedExports, { formatFlag, cyan }) => {
413
416
  if (Array.isArray(providedExports)) {
414
417
  if (providedExports.length === 0) return cyan(formatFlag("no exports"));
@@ -449,7 +452,7 @@ const SIMPLE_PRINTERS = {
449
452
  filteredModules,
450
453
  "module",
451
454
  "modules"
452
- )}`
455
+ )}`
453
456
  : undefined,
454
457
  "module.filteredReasons": (filteredReasons, { module: { reasons } }) =>
455
458
  filteredReasons > 0
@@ -457,7 +460,7 @@ const SIMPLE_PRINTERS = {
457
460
  filteredReasons,
458
461
  "reason",
459
462
  "reasons"
460
- )}`
463
+ )}`
461
464
  : undefined,
462
465
  "module.filteredChildren": (filteredChildren, { module: { children } }) =>
463
466
  filteredChildren > 0
@@ -465,7 +468,7 @@ const SIMPLE_PRINTERS = {
465
468
  filteredChildren,
466
469
  "module",
467
470
  "modules"
468
- )}`
471
+ )}`
469
472
  : undefined,
470
473
  "module.separator!": () => "\n",
471
474
 
@@ -492,7 +495,7 @@ const SIMPLE_PRINTERS = {
492
495
  filteredChildren,
493
496
  "reason",
494
497
  "reasons"
495
- )}`
498
+ )}`
496
499
  : undefined,
497
500
 
498
501
  "module.profile.total": (value, { formatTime }) => formatTime(value),
@@ -533,7 +536,7 @@ const SIMPLE_PRINTERS = {
533
536
  n,
534
537
  "asset",
535
538
  "assets"
536
- )}`
539
+ )}`
537
540
  : undefined,
538
541
  "chunkGroup.is!": () => "=",
539
542
  "chunkGroupAsset.name": (asset, { green }) => green(asset),
@@ -552,7 +555,7 @@ const SIMPLE_PRINTERS = {
552
555
  children: children[key]
553
556
  })),
554
557
  context
555
- ),
558
+ ),
556
559
  "chunkGroupChildGroup.type": type => `${type}:`,
557
560
  "chunkGroupChild.assets[]": (file, { formatFilename }) =>
558
561
  formatFilename(file),
@@ -581,7 +584,7 @@ const SIMPLE_PRINTERS = {
581
584
  children: childrenByOrder[key]
582
585
  })),
583
586
  context
584
- ),
587
+ ),
585
588
  "chunk.childrenByOrder[].type": type => `${type}:`,
586
589
  "chunk.childrenByOrder[].children[]": (id, { formatChunkId }) =>
587
590
  isValidId(id) ? formatChunkId(id) : undefined,
@@ -600,7 +603,7 @@ const SIMPLE_PRINTERS = {
600
603
  filteredModules,
601
604
  "module",
602
605
  "modules"
603
- )}`
606
+ )}`
604
607
  : undefined,
605
608
  "chunk.separator!": () => "\n",
606
609
 
@@ -1354,7 +1357,7 @@ class DefaultStatsPrinterPlugin {
1354
1357
  ? str.replace(
1355
1358
  /((\u001b\[39m|\u001b\[22m|\u001b\[0m)+)/g,
1356
1359
  `$1${start}`
1357
- )
1360
+ )
1358
1361
  : str
1359
1362
  }\u001b[39m\u001b[22m`;
1360
1363
  } else {
@@ -0,0 +1,96 @@
1
+ /*
2
+ MIT License http://www.opensource.org/licenses/mit-license.php
3
+ Author Tobias Koppers @sokra
4
+ */
5
+
6
+ "use strict";
7
+
8
+ /** @typedef {import("../Dependency")} Dependency */
9
+ /** @typedef {import("../ModuleGraph")} ModuleGraph */
10
+ /** @typedef {import("../javascript/JavascriptParser").Range} Range */
11
+
12
+ /**
13
+ * @summary Get the subset of ids and their corresponding range in an id chain that should be re-rendered by webpack.
14
+ * Only those in the chain that are actually referring to namespaces or imports should be re-rendered.
15
+ * Deeper member accessors on the imported object should not be re-rendered. If deeper member accessors are re-rendered,
16
+ * there is a potential loss of meaning with rendering a quoted accessor as an unquoted accessor, or vice versa,
17
+ * because minifiers treat quoted accessors differently. e.g. import { a } from "./module"; a["b"] vs a.b
18
+ * @param {string[]} untrimmedIds chained ids
19
+ * @param {Range} untrimmedRange range encompassing allIds
20
+ * @param {Range[]} ranges cumulative range of ids for each of allIds
21
+ * @param {ModuleGraph} moduleGraph moduleGraph
22
+ * @param {Dependency} dependency dependency
23
+ * @returns {{trimmedIds: string[], trimmedRange: Range}} computed trimmed ids and cumulative range of those ids
24
+ */
25
+ exports.getTrimmedIdsAndRange = (
26
+ untrimmedIds,
27
+ untrimmedRange,
28
+ ranges,
29
+ moduleGraph,
30
+ dependency
31
+ ) => {
32
+ let trimmedIds = trimIdsToThoseImported(
33
+ untrimmedIds,
34
+ moduleGraph,
35
+ dependency
36
+ );
37
+ let trimmedRange = untrimmedRange;
38
+ if (trimmedIds.length !== untrimmedIds.length) {
39
+ // The array returned from dep.idRanges is right-aligned with the array returned from dep.names.
40
+ // Meaning, the two arrays may not always have the same number of elements, but the last element of
41
+ // dep.idRanges corresponds to [the expression fragment to the left of] the last element of dep.names.
42
+ // Use this to find the correct replacement range based on the number of ids that were trimmed.
43
+ const idx =
44
+ ranges === undefined
45
+ ? -1 /* trigger failure case below */
46
+ : ranges.length + (trimmedIds.length - untrimmedIds.length);
47
+ if (idx < 0 || idx >= ranges.length) {
48
+ // cspell:ignore minifiers
49
+ // Should not happen but we can't throw an error here because of backward compatibility with
50
+ // external plugins in wp5. Instead, we just disable trimming for now. This may break some minifiers.
51
+ trimmedIds = untrimmedIds;
52
+ // TODO webpack 6 remove the "trimmedIds = ids" above and uncomment the following line instead.
53
+ // throw new Error("Missing range starts data for id replacement trimming.");
54
+ } else {
55
+ trimmedRange = ranges[idx];
56
+ }
57
+ }
58
+
59
+ return { trimmedIds, trimmedRange };
60
+ };
61
+
62
+ /**
63
+ * @summary Determine which IDs in the id chain are actually referring to namespaces or imports,
64
+ * and which are deeper member accessors on the imported object.
65
+ * @param {string[]} ids untrimmed ids
66
+ * @param {ModuleGraph} moduleGraph moduleGraph
67
+ * @param {Dependency} dependency dependency
68
+ * @returns {string[]} trimmed ids
69
+ */
70
+ function trimIdsToThoseImported(ids, moduleGraph, dependency) {
71
+ let trimmedIds = [];
72
+ const exportsInfo = moduleGraph.getExportsInfo(
73
+ moduleGraph.getModule(dependency)
74
+ );
75
+ let currentExportsInfo = /** @type {ExportsInfo=} */ exportsInfo;
76
+ for (let i = 0; i < ids.length; i++) {
77
+ if (i === 0 && ids[i] === "default") {
78
+ continue; // ExportInfo for the next level under default is still at the root ExportsInfo, so don't advance currentExportsInfo
79
+ }
80
+ const exportInfo = currentExportsInfo.getExportInfo(ids[i]);
81
+ if (exportInfo.provided === false) {
82
+ // json imports have nested ExportInfo for elements that things that are not actually exported, so check .provided
83
+ trimmedIds = ids.slice(0, i);
84
+ break;
85
+ }
86
+ const nestedInfo = exportInfo.getNestedExportsInfo();
87
+ if (!nestedInfo) {
88
+ // once all nested exports are traversed, the next item is the actual import so stop there
89
+ trimmedIds = ids.slice(0, i + 1);
90
+ break;
91
+ }
92
+ currentExportsInfo = nestedInfo;
93
+ }
94
+ // Never trim to nothing. This can happen for invalid imports (e.g. import { notThere } from "./module", or import { anything } from "./missingModule")
95
+ return trimmedIds.length ? trimmedIds : ids;
96
+ }
@@ -457,8 +457,8 @@ const mergeSingleValue = (a, b, internalCaching) => {
457
457
  return aType !== VALUE_TYPE_OBJECT
458
458
  ? b
459
459
  : internalCaching
460
- ? cachedCleverMerge(a, b)
461
- : cleverMerge(a, b);
460
+ ? cachedCleverMerge(a, b)
461
+ : cleverMerge(a, b);
462
462
  }
463
463
  case VALUE_TYPE_UNDEFINED:
464
464
  return a;
@@ -467,8 +467,8 @@ const mergeSingleValue = (a, b, internalCaching) => {
467
467
  aType !== VALUE_TYPE_ATOM
468
468
  ? aType
469
469
  : Array.isArray(a)
470
- ? VALUE_TYPE_ARRAY_EXTEND
471
- : VALUE_TYPE_OBJECT
470
+ ? VALUE_TYPE_ARRAY_EXTEND
471
+ : VALUE_TYPE_OBJECT
472
472
  ) {
473
473
  case VALUE_TYPE_UNDEFINED:
474
474
  return b;
@@ -10,8 +10,8 @@ const create = require("./wasm-hash");
10
10
  //#region wasm code: xxhash64 (../../../assembly/hash/xxhash64.asm.ts) --initialMemory 1
11
11
  const xxhash64 = new WebAssembly.Module(
12
12
  Buffer.from(
13
- // 1170 bytes
14
- "AGFzbQEAAAABCAJgAX8AYAAAAwQDAQAABQMBAAEGGgV+AUIAC34BQgALfgFCAAt+AUIAC34BQgALByIEBGluaXQAAAZ1cGRhdGUAAQVmaW5hbAACBm1lbW9yeQIACrIIAzAAQtbrgu7q/Yn14AAkAELP1tO+0ser2UIkAUIAJAJC+erQ0OfJoeThACQDQgAkBAvUAQIBfwR+IABFBEAPCyMEIACtfCQEIwAhAiMBIQMjAiEEIwMhBQNAIAIgASkDAELP1tO+0ser2UJ+fEIfiUKHla+vmLbem55/fiECIAMgASkDCELP1tO+0ser2UJ+fEIfiUKH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LIAFBBGoiAiAATQRAIAMgATUCAEKHla+vmLbem55/foVCF4lCz9bTvtLHq9lCfkL5893xmfaZqxZ8IQMgAiEBCwNAIAAgAUcEQCADIAExAABCxc/ZsvHluuonfoVCC4lCh5Wvr5i23puef34hAyABQQFqIQEMAQsLQQAgAyADQiGIhULP1tO+0ser2UJ+IgNCHYggA4VC+fPd8Zn2masWfiIDQiCIIAOFIgNCIIgiBEL//wODQiCGIARCgID8/w+DQhCIhCIEQv+BgIDwH4NCEIYgBEKA/oOAgOA/g0IIiIQiBEKPgLyA8IHAB4NCCIYgBELwgcCHgJ6A+ACDQgSIhCIEQoaMmLDgwIGDBnxCBIhCgYKEiJCgwIABg0InfiAEQrDgwIGDhoyYMIR8NwMAQQggA0L/////D4MiA0L//wODQiCGIANCgID8/w+DQhCIhCIDQv+BgIDwH4NCEIYgA0KA/oOAgOA/g0IIiIQiA0KPgLyA8IHAB4NCCIYgA0LwgcCHgJ6A+ACDQgSIhCIDQoaMmLDgwIGDBnxCBIhCgYKEiJCgwIABg0InfiADQrDgwIGDhoyYMIR8NwMACw==",
15
15
  "base64"
16
16
  )
17
17
  );
@@ -376,6 +376,6 @@ exports.getUndoPath = (filename, outputPath, enforceRelative) => {
376
376
  return depth > 0
377
377
  ? `${"../".repeat(depth)}${append}`
378
378
  : enforceRelative
379
- ? `./${append}`
380
- : append;
379
+ ? `./${append}`
380
+ : append;
381
381
  };
@@ -45,6 +45,10 @@ module.exports = {
45
45
  require("../dependencies/AMDRequireItemDependency"),
46
46
  "dependencies/CachedConstDependency": () =>
47
47
  require("../dependencies/CachedConstDependency"),
48
+ "dependencies/ExternalModuleDependency": () =>
49
+ require("../dependencies/ExternalModuleDependency"),
50
+ "dependencies/ExternalModuleInitFragment": () =>
51
+ require("../dependencies/ExternalModuleInitFragment"),
48
52
  "dependencies/CreateScriptUrlDependency": () =>
49
53
  require("../dependencies/CreateScriptUrlDependency"),
50
54
  "dependencies/CommonJsRequireContextDependency": () =>
@@ -206,6 +210,8 @@ module.exports = {
206
210
  "util/LazySet": () => require("../util/LazySet"),
207
211
  UnhandledSchemeError: () => require("../UnhandledSchemeError"),
208
212
  NodeStuffInWebError: () => require("../NodeStuffInWebError"),
213
+ EnvironmentNotSupportAsyncWarning: () =>
214
+ require("../EnvironmentNotSupportAsyncWarning"),
209
215
  WebpackError: () => require("../WebpackError"),
210
216
 
211
217
  "util/registerExternalSerializer": () => {
@@ -57,7 +57,7 @@ exports.getEntryRuntime = (compilation, name, options) => {
57
57
  * @param {boolean} deterministicOrder enforce a deterministic order
58
58
  * @returns {void}
59
59
  */
60
- exports.forEachRuntime = (runtime, fn, deterministicOrder = false) => {
60
+ const forEachRuntime = (runtime, fn, deterministicOrder = false) => {
61
61
  if (runtime === undefined) {
62
62
  fn(undefined);
63
63
  } else if (typeof runtime === "string") {
@@ -69,6 +69,7 @@ exports.forEachRuntime = (runtime, fn, deterministicOrder = false) => {
69
69
  }
70
70
  }
71
71
  };
72
+ exports.forEachRuntime = forEachRuntime;
72
73
 
73
74
  /**
74
75
  * @template T
@@ -228,6 +229,22 @@ const mergeRuntime = (a, b) => {
228
229
  };
229
230
  exports.mergeRuntime = mergeRuntime;
230
231
 
232
+ /**
233
+ * @param {RuntimeSpec[]} runtimes first
234
+ * @param {RuntimeSpec} runtime second
235
+ * @returns {RuntimeSpec} merged
236
+ */
237
+ exports.deepMergeRuntime = (runtimes, runtime) => {
238
+ if (!Array.isArray(runtimes)) {
239
+ return runtime;
240
+ }
241
+ let merged = runtime;
242
+ for (const r of runtimes) {
243
+ merged = mergeRuntime(runtime, r);
244
+ }
245
+ return merged;
246
+ };
247
+
231
248
  /**
232
249
  * @param {RuntimeCondition} a first
233
250
  * @param {RuntimeCondition} b second