webpack 5.70.0 → 5.72.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 (55) hide show
  1. package/hot/poll.js +1 -1
  2. package/hot/signal.js +1 -1
  3. package/lib/BannerPlugin.js +3 -1
  4. package/lib/Chunk.js +1 -1
  5. package/lib/ChunkGraph.js +93 -6
  6. package/lib/ChunkGroup.js +1 -1
  7. package/lib/Compilation.js +10 -8
  8. package/lib/Compiler.js +16 -3
  9. package/lib/ConstPlugin.js +2 -2
  10. package/lib/ContextModule.js +31 -8
  11. package/lib/ContextModuleFactory.js +7 -11
  12. package/lib/DelegatedModuleFactoryPlugin.js +1 -1
  13. package/lib/Dependency.js +7 -0
  14. package/lib/ErrorHelpers.js +2 -2
  15. package/lib/ExportsInfo.js +1 -1
  16. package/lib/ExternalModuleFactoryPlugin.js +4 -4
  17. package/lib/FileSystemInfo.js +8 -0
  18. package/lib/LoaderOptionsPlugin.js +1 -1
  19. package/lib/Module.js +3 -0
  20. package/lib/ModuleFilenameHelpers.js +3 -3
  21. package/lib/NormalModule.js +5 -4
  22. package/lib/NormalModuleFactory.js +2 -2
  23. package/lib/RuntimePlugin.js +18 -0
  24. package/lib/asset/AssetGenerator.js +36 -9
  25. package/lib/asset/AssetParser.js +1 -0
  26. package/lib/asset/AssetSourceGenerator.js +31 -6
  27. package/lib/asset/AssetSourceParser.js +1 -0
  28. package/lib/cache/PackFileCacheStrategy.js +8 -4
  29. package/lib/config/defaults.js +9 -1
  30. package/lib/container/RemoteRuntimeModule.js +8 -7
  31. package/lib/dependencies/CommonJsExportsParserPlugin.js +1 -2
  32. package/lib/dependencies/ContextDependencyHelpers.js +2 -2
  33. package/lib/dependencies/ContextElementDependency.js +33 -1
  34. package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +95 -0
  35. package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +127 -43
  36. package/lib/dependencies/HarmonyImportSpecifierDependency.js +22 -8
  37. package/lib/dependencies/HarmonyModulesPlugin.js +10 -0
  38. package/lib/esm/ModuleChunkLoadingPlugin.js +3 -1
  39. package/lib/hmr/HotModuleReplacement.runtime.js +29 -14
  40. package/lib/hmr/JavascriptHotModuleReplacement.runtime.js +4 -3
  41. package/lib/ids/HashedModuleIdsPlugin.js +2 -2
  42. package/lib/ids/IdHelpers.js +1 -1
  43. package/lib/javascript/BasicEvaluatedExpression.js +5 -2
  44. package/lib/javascript/JavascriptParser.js +66 -40
  45. package/lib/library/UmdLibraryPlugin.js +5 -3
  46. package/lib/optimize/ConcatenatedModule.js +2 -1
  47. package/lib/optimize/ModuleConcatenationPlugin.js +20 -1
  48. package/lib/runtime/BaseUriRuntimeModule.js +31 -0
  49. package/lib/stats/DefaultStatsFactoryPlugin.js +1 -1
  50. package/lib/util/internalSerializables.js +2 -0
  51. package/lib/web/JsonpChunkLoadingRuntimeModule.js +2 -1
  52. package/package.json +1 -1
  53. package/schemas/plugins/BannerPlugin.check.js +1 -1
  54. package/schemas/plugins/BannerPlugin.json +4 -0
  55. package/types.d.ts +38 -11
@@ -57,7 +57,7 @@ const BasicEvaluatedExpression = require("./BasicEvaluatedExpression");
57
57
  /** @typedef {import("../Parser").ParserState} ParserState */
58
58
  /** @typedef {import("../Parser").PreparsedAst} PreparsedAst */
59
59
  /** @typedef {{declaredScope: ScopeInfo, freeName: string | true, tagInfo: TagInfo | undefined}} VariableInfoInterface */
60
- /** @typedef {{ name: string | VariableInfo, rootInfo: string | VariableInfo, getMembers: () => string[] }} GetInfoResult */
60
+ /** @typedef {{ name: string | VariableInfo, rootInfo: string | VariableInfo, getMembers: () => string[], getMembersOptionals: () => boolean[] }} GetInfoResult */
61
61
 
62
62
  const EMPTY_ARRAY = [];
63
63
  const ALLOWED_MEMBER_TYPES_CALL_EXPRESSION = 0b01;
@@ -262,9 +262,9 @@ class JavascriptParser extends Parser {
262
262
  /** @type {HookMap<SyncBailHook<[ExpressionNode], boolean | void>>} */
263
263
  call: new HookMap(() => new SyncBailHook(["expression"])),
264
264
  /** Something like "a.b()" */
265
- /** @type {HookMap<SyncBailHook<[CallExpressionNode, string[]], boolean | void>>} */
265
+ /** @type {HookMap<SyncBailHook<[CallExpressionNode, string[], boolean[]], boolean | void>>} */
266
266
  callMemberChain: new HookMap(
267
- () => new SyncBailHook(["expression", "members"])
267
+ () => new SyncBailHook(["expression", "members", "membersOptionals"])
268
268
  ),
269
269
  /** Something like "a.b().c.d" */
270
270
  /** @type {HookMap<SyncBailHook<[ExpressionNode, string[], CallExpressionNode, string[]], boolean | void>>} */
@@ -292,11 +292,13 @@ class JavascriptParser extends Parser {
292
292
  optionalChaining: new SyncBailHook(["optionalChaining"]),
293
293
  /** @type {HookMap<SyncBailHook<[NewExpressionNode], boolean | void>>} */
294
294
  new: new HookMap(() => new SyncBailHook(["expression"])),
295
+ /** @type {SyncBailHook<[BinaryExpressionNode], boolean | void>} */
296
+ binaryExpression: new SyncBailHook(["binaryExpression"]),
295
297
  /** @type {HookMap<SyncBailHook<[ExpressionNode], boolean | void>>} */
296
298
  expression: new HookMap(() => new SyncBailHook(["expression"])),
297
- /** @type {HookMap<SyncBailHook<[ExpressionNode, string[]], boolean | void>>} */
299
+ /** @type {HookMap<SyncBailHook<[ExpressionNode, string[], boolean[]], boolean | void>>} */
298
300
  expressionMemberChain: new HookMap(
299
- () => new SyncBailHook(["expression", "members"])
301
+ () => new SyncBailHook(["expression", "members", "membersOptionals"])
300
302
  ),
301
303
  /** @type {HookMap<SyncBailHook<[ExpressionNode, string[]], boolean | void>>} */
302
304
  unhandledExpressionMemberChain: new HookMap(
@@ -416,7 +418,6 @@ class JavascriptParser extends Parser {
416
418
  const expr = /** @type {LogicalExpressionNode} */ (_expr);
417
419
 
418
420
  const left = this.evaluateExpression(expr.left);
419
- if (!left) return;
420
421
  let returnRight = false;
421
422
  /** @type {boolean|undefined} */
422
423
  let allowedRight;
@@ -437,7 +438,6 @@ class JavascriptParser extends Parser {
437
438
  returnRight = true;
438
439
  } else return;
439
440
  const right = this.evaluateExpression(expr.right);
440
- if (!right) return;
441
441
  if (returnRight) {
442
442
  if (left.couldHaveSideEffects()) right.setSideEffects();
443
443
  return right.setRange(expr.range);
@@ -486,10 +486,10 @@ class JavascriptParser extends Parser {
486
486
 
487
487
  const handleConstOperation = fn => {
488
488
  const left = this.evaluateExpression(expr.left);
489
- if (!left || !left.isCompileTimeValue()) return;
489
+ if (!left.isCompileTimeValue()) return;
490
490
 
491
491
  const right = this.evaluateExpression(expr.right);
492
- if (!right || !right.isCompileTimeValue()) return;
492
+ if (!right.isCompileTimeValue()) return;
493
493
 
494
494
  const result = fn(
495
495
  left.asCompileTimeValue(),
@@ -545,9 +545,7 @@ class JavascriptParser extends Parser {
545
545
 
546
546
  const handleStrictEqualityComparison = eql => {
547
547
  const left = this.evaluateExpression(expr.left);
548
- if (!left) return;
549
548
  const right = this.evaluateExpression(expr.right);
550
- if (!right) return;
551
549
  const res = new BasicEvaluatedExpression();
552
550
  res.setRange(expr.range);
553
551
 
@@ -600,9 +598,7 @@ class JavascriptParser extends Parser {
600
598
 
601
599
  const handleAbstractEqualityComparison = eql => {
602
600
  const left = this.evaluateExpression(expr.left);
603
- if (!left) return;
604
601
  const right = this.evaluateExpression(expr.right);
605
- if (!right) return;
606
602
  const res = new BasicEvaluatedExpression();
607
603
  res.setRange(expr.range);
608
604
 
@@ -635,9 +631,7 @@ class JavascriptParser extends Parser {
635
631
 
636
632
  if (expr.operator === "+") {
637
633
  const left = this.evaluateExpression(expr.left);
638
- if (!left) return;
639
634
  const right = this.evaluateExpression(expr.right);
640
- if (!right) return;
641
635
  const res = new BasicEvaluatedExpression();
642
636
  if (left.isString()) {
643
637
  if (right.isString()) {
@@ -816,7 +810,7 @@ class JavascriptParser extends Parser {
816
810
 
817
811
  const handleConstOperation = fn => {
818
812
  const argument = this.evaluateExpression(expr.argument);
819
- if (!argument || !argument.isCompileTimeValue()) return;
813
+ if (!argument.isCompileTimeValue()) return;
820
814
  const result = fn(argument.asCompileTimeValue());
821
815
  return valueAsExpression(
822
816
  result,
@@ -915,7 +909,6 @@ class JavascriptParser extends Parser {
915
909
  }
916
910
  } else if (expr.operator === "!") {
917
911
  const argument = this.evaluateExpression(expr.argument);
918
- if (!argument) return;
919
912
  const bool = argument.asBool();
920
913
  if (typeof bool !== "boolean") return;
921
914
  return new BasicEvaluatedExpression()
@@ -980,7 +973,12 @@ class JavascriptParser extends Parser {
980
973
  const info = cachedExpression === expr ? cachedInfo : getInfo(expr);
981
974
  if (info !== undefined) {
982
975
  return new BasicEvaluatedExpression()
983
- .setIdentifier(info.name, info.rootInfo, info.getMembers)
976
+ .setIdentifier(
977
+ info.name,
978
+ info.rootInfo,
979
+ info.getMembers,
980
+ info.getMembersOptionals
981
+ )
984
982
  .setRange(expr.range);
985
983
  }
986
984
  });
@@ -997,7 +995,12 @@ class JavascriptParser extends Parser {
997
995
  typeof info === "string" ||
998
996
  (info instanceof VariableInfo && typeof info.freeName === "string")
999
997
  ) {
1000
- return { name: info, rootInfo: info, getMembers: () => [] };
998
+ return {
999
+ name: info,
1000
+ rootInfo: info,
1001
+ getMembers: () => [],
1002
+ getMembersOptionals: () => []
1003
+ };
1001
1004
  }
1002
1005
  });
1003
1006
  tapEvaluateWithVariableInfo("ThisExpression", expr => {
@@ -1006,7 +1009,12 @@ class JavascriptParser extends Parser {
1006
1009
  typeof info === "string" ||
1007
1010
  (info instanceof VariableInfo && typeof info.freeName === "string")
1008
1011
  ) {
1009
- return { name: info, rootInfo: info, getMembers: () => [] };
1012
+ return {
1013
+ name: info,
1014
+ rootInfo: info,
1015
+ getMembers: () => [],
1016
+ getMembersOptionals: () => []
1017
+ };
1010
1018
  }
1011
1019
  });
1012
1020
  this.hooks.evaluate.for("MetaProperty").tap("JavascriptParser", expr => {
@@ -1039,7 +1047,6 @@ class JavascriptParser extends Parser {
1039
1047
  const param = this.evaluateExpression(
1040
1048
  /** @type {ExpressionNode} */ (expr.callee.object)
1041
1049
  );
1042
- if (!param) return;
1043
1050
  const property =
1044
1051
  expr.callee.property.type === "Literal"
1045
1052
  ? `${expr.callee.property.value}`
@@ -1306,7 +1313,6 @@ class JavascriptParser extends Parser {
1306
1313
  if (conditionValue === undefined) {
1307
1314
  const consequent = this.evaluateExpression(expr.consequent);
1308
1315
  const alternate = this.evaluateExpression(expr.alternate);
1309
- if (!consequent || !alternate) return;
1310
1316
  res = new BasicEvaluatedExpression();
1311
1317
  if (consequent.isConditional()) {
1312
1318
  res.setOptions(consequent.options);
@@ -1380,7 +1386,7 @@ class JavascriptParser extends Parser {
1380
1386
  const expression = optionalExpressionsStack.pop();
1381
1387
  const evaluated = this.evaluateExpression(expression);
1382
1388
 
1383
- if (evaluated && evaluated.asNullish()) {
1389
+ if (evaluated.asNullish()) {
1384
1390
  return evaluated.setRange(_expr.range);
1385
1391
  }
1386
1392
  }
@@ -1390,7 +1396,7 @@ class JavascriptParser extends Parser {
1390
1396
 
1391
1397
  getRenameIdentifier(expr) {
1392
1398
  const result = this.evaluateExpression(expr);
1393
- if (result && result.isIdentifier()) {
1399
+ if (result.isIdentifier()) {
1394
1400
  return result.identifier;
1395
1401
  }
1396
1402
  }
@@ -2457,7 +2463,9 @@ class JavascriptParser extends Parser {
2457
2463
  }
2458
2464
 
2459
2465
  walkBinaryExpression(expression) {
2460
- this.walkLeftRightExpression(expression);
2466
+ if (this.hooks.binaryExpression.call(expression) === undefined) {
2467
+ this.walkLeftRightExpression(expression);
2468
+ }
2461
2469
  }
2462
2470
 
2463
2471
  walkLogicalExpression(expression) {
@@ -2492,7 +2500,9 @@ class JavascriptParser extends Parser {
2492
2500
  ) {
2493
2501
  this.setVariable(
2494
2502
  expression.left.name,
2495
- this.getVariableInfo(renameIdentifier)
2503
+ typeof renameIdentifier === "string"
2504
+ ? this.getVariableInfo(renameIdentifier)
2505
+ : renameIdentifier
2496
2506
  );
2497
2507
  }
2498
2508
  return;
@@ -2627,7 +2637,9 @@ class JavascriptParser extends Parser {
2627
2637
  argOrThis
2628
2638
  )
2629
2639
  ) {
2630
- return this.getVariableInfo(renameIdentifier);
2640
+ return typeof renameIdentifier === "string"
2641
+ ? this.getVariableInfo(renameIdentifier)
2642
+ : renameIdentifier;
2631
2643
  }
2632
2644
  }
2633
2645
  }
@@ -2727,7 +2739,10 @@ class JavascriptParser extends Parser {
2727
2739
  this.hooks.callMemberChain,
2728
2740
  callee.rootInfo,
2729
2741
  expression,
2730
- callee.getMembers()
2742
+ callee.getMembers(),
2743
+ callee.getMembersOptionals
2744
+ ? callee.getMembersOptionals()
2745
+ : callee.getMembers().map(() => false)
2731
2746
  );
2732
2747
  if (result1 === true) return;
2733
2748
  const result2 = this.callHooksForInfo(
@@ -2767,11 +2782,13 @@ class JavascriptParser extends Parser {
2767
2782
  );
2768
2783
  if (result1 === true) return;
2769
2784
  const members = exprInfo.getMembers();
2785
+ const membersOptionals = exprInfo.getMembersOptionals();
2770
2786
  const result2 = this.callHooksForInfo(
2771
2787
  this.hooks.expressionMemberChain,
2772
2788
  exprInfo.rootInfo,
2773
2789
  expression,
2774
- members
2790
+ members,
2791
+ membersOptionals
2775
2792
  );
2776
2793
  if (result2 === true) return;
2777
2794
  this.walkMemberExpressionWithExpressionName(
@@ -3167,17 +3184,15 @@ class JavascriptParser extends Parser {
3167
3184
 
3168
3185
  /**
3169
3186
  * @param {ExpressionNode} expression expression node
3170
- * @returns {BasicEvaluatedExpression | undefined} evaluation result
3187
+ * @returns {BasicEvaluatedExpression} evaluation result
3171
3188
  */
3172
3189
  evaluateExpression(expression) {
3173
3190
  try {
3174
3191
  const hook = this.hooks.evaluate.get(expression.type);
3175
3192
  if (hook !== undefined) {
3176
3193
  const result = hook.call(expression);
3177
- if (result !== undefined) {
3178
- if (result) {
3179
- result.setExpression(expression);
3180
- }
3194
+ if (result !== undefined && result !== null) {
3195
+ result.setExpression(expression);
3181
3196
  return result;
3182
3197
  }
3183
3198
  }
@@ -3348,6 +3363,10 @@ class JavascriptParser extends Parser {
3348
3363
  return state;
3349
3364
  }
3350
3365
 
3366
+ /**
3367
+ * @param {string} source source code
3368
+ * @returns {BasicEvaluatedExpression} evaluation result
3369
+ */
3351
3370
  evaluate(source) {
3352
3371
  const ast = JavascriptParser._parse("(" + source + ")", {
3353
3372
  sourceType: this.sourceType,
@@ -3609,12 +3628,13 @@ class JavascriptParser extends Parser {
3609
3628
 
3610
3629
  /**
3611
3630
  * @param {MemberExpressionNode} expression a member expression
3612
- * @returns {{ members: string[], object: ExpressionNode | SuperNode }} member names (reverse order) and remaining object
3631
+ * @returns {{ members: string[], object: ExpressionNode | SuperNode, membersOptionals: boolean[] }} member names (reverse order) and remaining object
3613
3632
  */
3614
3633
  extractMemberExpressionChain(expression) {
3615
3634
  /** @type {AnyNode} */
3616
3635
  let expr = expression;
3617
3636
  const members = [];
3637
+ const membersOptionals = [];
3618
3638
  while (expr.type === "MemberExpression") {
3619
3639
  if (expr.computed) {
3620
3640
  if (expr.property.type !== "Literal") break;
@@ -3623,10 +3643,13 @@ class JavascriptParser extends Parser {
3623
3643
  if (expr.property.type !== "Identifier") break;
3624
3644
  members.push(expr.property.name);
3625
3645
  }
3646
+ membersOptionals.push(expr.optional);
3626
3647
  expr = expr.object;
3627
3648
  }
3649
+
3628
3650
  return {
3629
3651
  members,
3652
+ membersOptionals,
3630
3653
  object: expr
3631
3654
  };
3632
3655
  }
@@ -3649,8 +3672,8 @@ class JavascriptParser extends Parser {
3649
3672
  return { info, name };
3650
3673
  }
3651
3674
 
3652
- /** @typedef {{ type: "call", call: CallExpressionNode, calleeName: string, rootInfo: string | VariableInfo, getCalleeMembers: () => string[], name: string, getMembers: () => string[]}} CallExpressionInfo */
3653
- /** @typedef {{ type: "expression", rootInfo: string | VariableInfo, name: string, getMembers: () => string[]}} ExpressionExpressionInfo */
3675
+ /** @typedef {{ type: "call", call: CallExpressionNode, calleeName: string, rootInfo: string | VariableInfo, getCalleeMembers: () => string[], name: string, getMembers: () => string[], getMembersOptionals: () => boolean[]}} CallExpressionInfo */
3676
+ /** @typedef {{ type: "expression", rootInfo: string | VariableInfo, name: string, getMembers: () => string[], getMembersOptionals: () => boolean[]}} ExpressionExpressionInfo */
3654
3677
 
3655
3678
  /**
3656
3679
  * @param {MemberExpressionNode} expression a member expression
@@ -3658,7 +3681,8 @@ class JavascriptParser extends Parser {
3658
3681
  * @returns {CallExpressionInfo | ExpressionExpressionInfo | undefined} expression info
3659
3682
  */
3660
3683
  getMemberExpressionInfo(expression, allowedTypes) {
3661
- const { object, members } = this.extractMemberExpressionChain(expression);
3684
+ const { object, members, membersOptionals } =
3685
+ this.extractMemberExpressionChain(expression);
3662
3686
  switch (object.type) {
3663
3687
  case "CallExpression": {
3664
3688
  if ((allowedTypes & ALLOWED_MEMBER_TYPES_CALL_EXPRESSION) === 0)
@@ -3682,7 +3706,8 @@ class JavascriptParser extends Parser {
3682
3706
  rootInfo,
3683
3707
  getCalleeMembers: memoize(() => rootMembers.reverse()),
3684
3708
  name: objectAndMembersToName(`${calleeName}()`, members),
3685
- getMembers: memoize(() => members.reverse())
3709
+ getMembers: memoize(() => members.reverse()),
3710
+ getMembersOptionals: memoize(() => membersOptionals.reverse())
3686
3711
  };
3687
3712
  }
3688
3713
  case "Identifier":
@@ -3700,7 +3725,8 @@ class JavascriptParser extends Parser {
3700
3725
  type: "expression",
3701
3726
  name: objectAndMembersToName(resolvedRoot, members),
3702
3727
  rootInfo,
3703
- getMembers: memoize(() => members.reverse())
3728
+ getMembers: memoize(() => members.reverse()),
3729
+ getMembersOptionals: memoize(() => membersOptionals.reverse())
3704
3730
  };
3705
3731
  }
3706
3732
  }
@@ -310,9 +310,11 @@ class UmdLibraryPlugin extends AbstractLibraryPlugin {
310
310
  : " var a = factory();\n") +
311
311
  " for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];\n" +
312
312
  " }\n") +
313
- `})(${
314
- runtimeTemplate.outputOptions.globalObject
315
- }, function(${externalsArguments(externals)}) {\nreturn `,
313
+ `})(${runtimeTemplate.outputOptions.globalObject}, ${
314
+ runtimeTemplate.supportsArrowFunction()
315
+ ? `(${externalsArguments(externals)}) =>`
316
+ : `function(${externalsArguments(externals)})`
317
+ } {\nreturn `,
316
318
  "webpack/universalModuleDefinition"
317
319
  ),
318
320
  source,
@@ -1669,7 +1669,8 @@ ${defineGetters}`
1669
1669
  chunkGraph,
1670
1670
  runtime,
1671
1671
  concatenationScope,
1672
- codeGenerationResults
1672
+ codeGenerationResults,
1673
+ sourceTypes: TYPES
1673
1674
  });
1674
1675
  const source = codeGenResult.sources.get("javascript");
1675
1676
  const data = codeGenResult.data;
@@ -58,6 +58,11 @@ class ModuleConcatenationPlugin {
58
58
  apply(compiler) {
59
59
  const { _backCompat: backCompat } = compiler;
60
60
  compiler.hooks.compilation.tap("ModuleConcatenationPlugin", compilation => {
61
+ if (compilation.moduleMemCaches) {
62
+ throw new Error(
63
+ "optimization.concatenateModules can't be used with cacheUnaffected as module concatenation is a global effect"
64
+ );
65
+ }
61
66
  const moduleGraph = compilation.moduleGraph;
62
67
  const bailoutReasonMap = new Map();
63
68
 
@@ -425,7 +430,21 @@ class ModuleConcatenationPlugin {
425
430
  for (const chunk of chunkGraph.getModuleChunksIterable(
426
431
  rootModule
427
432
  )) {
428
- chunkGraph.disconnectChunkAndModule(chunk, m);
433
+ const sourceTypes = chunkGraph.getChunkModuleSourceTypes(
434
+ chunk,
435
+ m
436
+ );
437
+ if (sourceTypes.size === 1) {
438
+ chunkGraph.disconnectChunkAndModule(chunk, m);
439
+ } else {
440
+ const newSourceTypes = new Set(sourceTypes);
441
+ newSourceTypes.delete("javascript");
442
+ chunkGraph.setChunkModuleSourceTypes(
443
+ chunk,
444
+ m,
445
+ newSourceTypes
446
+ );
447
+ }
429
448
  }
430
449
  }
431
450
  }
@@ -0,0 +1,31 @@
1
+ /*
2
+ MIT License http://www.opensource.org/licenses/mit-license.php
3
+ Author Ivan Kopeykin @vankop
4
+ */
5
+
6
+ "use strict";
7
+
8
+ const RuntimeGlobals = require("../RuntimeGlobals");
9
+ const RuntimeModule = require("../RuntimeModule");
10
+
11
+ class BaseUriRuntimeModule extends RuntimeModule {
12
+ constructor() {
13
+ super("base uri", RuntimeModule.STAGE_ATTACH);
14
+ }
15
+
16
+ /**
17
+ * @returns {string} runtime code
18
+ */
19
+ generate() {
20
+ const { chunk } = this;
21
+
22
+ const options = chunk.getEntryOptions();
23
+ return `${RuntimeGlobals.baseURI} = ${
24
+ options.baseUri === undefined
25
+ ? "undefined"
26
+ : JSON.stringify(options.baseUri)
27
+ };`;
28
+ }
29
+ }
30
+
31
+ module.exports = BaseUriRuntimeModule;
@@ -2155,7 +2155,7 @@ const RESULT_GROUPERS = {
2155
2155
  // remove a prefixed "!" that can be specified to reverse sort order
2156
2156
  const normalizeFieldKey = field => {
2157
2157
  if (field[0] === "!") {
2158
- return field.substr(1);
2158
+ return field.slice(1);
2159
2159
  }
2160
2160
  return field;
2161
2161
  };
@@ -103,6 +103,8 @@ module.exports = {
103
103
  require("../dependencies/HarmonyImportSideEffectDependency"),
104
104
  "dependencies/HarmonyImportSpecifierDependency": () =>
105
105
  require("../dependencies/HarmonyImportSpecifierDependency"),
106
+ "dependencies/HarmonyEvaluatedImportSpecifierDependency": () =>
107
+ require("../dependencies/HarmonyEvaluatedImportSpecifierDependency"),
106
108
  "dependencies/ImportContextDependency": () =>
107
109
  require("../dependencies/ImportContextDependency"),
108
110
  "dependencies/ImportDependency": () =>
@@ -286,8 +286,9 @@ class JsonpChunkLoadingRuntimeModule extends RuntimeModule {
286
286
  ? Template.asString([
287
287
  "var currentUpdatedModulesList;",
288
288
  "var waitingUpdateResolves = {};",
289
- "function loadUpdateChunk(chunkId) {",
289
+ "function loadUpdateChunk(chunkId, updatedModulesList) {",
290
290
  Template.indent([
291
+ "currentUpdatedModulesList = updatedModulesList;",
291
292
  `return new Promise(${runtimeTemplate.basicFunction(
292
293
  "resolve, reject",
293
294
  [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webpack",
3
- "version": "5.70.0",
3
+ "version": "5.72.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",
@@ -3,4 +3,4 @@
3
3
  * DO NOT MODIFY BY HAND.
4
4
  * Run `yarn special-lint-fix` to update
5
5
  */
6
- "use strict";function n(t,{instancePath:l="",parentData:s,parentDataProperty:e,rootData:a=t}={}){let r=null,o=0;const u=o;let i=!1;const p=o;if(o===p)if(Array.isArray(t)){const n=t.length;for(let l=0;l<n;l++){let n=t[l];const s=o,e=o;let a=!1,u=null;const i=o,p=o;let f=!1;const h=o;if(!(n instanceof RegExp)){const n={params:{}};null===r?r=[n]:r.push(n),o++}var c=h===o;if(f=f||c,!f){const t=o;if(o===t)if("string"==typeof n){if(n.length<1){const n={params:{}};null===r?r=[n]:r.push(n),o++}}else{const n={params:{type:"string"}};null===r?r=[n]:r.push(n),o++}c=t===o,f=f||c}if(f)o=p,null!==r&&(p?r.length=p:r=null);else{const n={params:{}};null===r?r=[n]:r.push(n),o++}if(i===o&&(a=!0,u=0),a)o=e,null!==r&&(e?r.length=e:r=null);else{const n={params:{passingSchemas:u}};null===r?r=[n]:r.push(n),o++}if(s!==o)break}}else{const n={params:{type:"array"}};null===r?r=[n]:r.push(n),o++}var f=p===o;if(i=i||f,!i){const n=o,l=o;let s=!1;const e=o;if(!(t instanceof RegExp)){const n={params:{}};null===r?r=[n]:r.push(n),o++}var h=e===o;if(s=s||h,!s){const n=o;if(o===n)if("string"==typeof t){if(t.length<1){const n={params:{}};null===r?r=[n]:r.push(n),o++}}else{const n={params:{type:"string"}};null===r?r=[n]:r.push(n),o++}h=n===o,s=s||h}if(s)o=l,null!==r&&(l?r.length=l:r=null);else{const n={params:{}};null===r?r=[n]:r.push(n),o++}f=n===o,i=i||f}if(!i){const t={params:{}};return null===r?r=[t]:r.push(t),o++,n.errors=r,!1}return o=u,null!==r&&(u?r.length=u:r=null),n.errors=r,0===o}function t(l,{instancePath:s="",parentData:e,parentDataProperty:a,rootData:r=l}={}){let o=null,u=0;const i=u;let p=!1;const c=u;if(u===c)if("string"==typeof l){if(l.length<1){const n={params:{}};null===o?o=[n]:o.push(n),u++}}else{const n={params:{type:"string"}};null===o?o=[n]:o.push(n),u++}var f=c===u;if(p=p||f,!p){const t=u;if(u===t)if(l&&"object"==typeof l&&!Array.isArray(l)){let t;if(void 0===l.banner&&(t="banner")){const n={params:{missingProperty:t}};null===o?o=[n]:o.push(n),u++}else{const t=u;for(const n in l)if("banner"!==n&&"entryOnly"!==n&&"exclude"!==n&&"include"!==n&&"raw"!==n&&"test"!==n){const t={params:{additionalProperty:n}};null===o?o=[t]:o.push(t),u++;break}if(t===u){if(void 0!==l.banner){let n=l.banner;const t=u,s=u;let e=!1;const a=u;if("string"!=typeof n){const n={params:{type:"string"}};null===o?o=[n]:o.push(n),u++}var h=a===u;if(e=e||h,!e){const t=u;if(!(n instanceof Function)){const n={params:{}};null===o?o=[n]:o.push(n),u++}h=t===u,e=e||h}if(e)u=s,null!==o&&(s?o.length=s:o=null);else{const n={params:{}};null===o?o=[n]:o.push(n),u++}var m=t===u}else m=!0;if(m){if(void 0!==l.entryOnly){const n=u;if("boolean"!=typeof l.entryOnly){const n={params:{type:"boolean"}};null===o?o=[n]:o.push(n),u++}m=n===u}else m=!0;if(m){if(void 0!==l.exclude){const t=u,e=u;let a=!1,i=null;const p=u;if(n(l.exclude,{instancePath:s+"/exclude",parentData:l,parentDataProperty:"exclude",rootData:r})||(o=null===o?n.errors:o.concat(n.errors),u=o.length),p===u&&(a=!0,i=0),a)u=e,null!==o&&(e?o.length=e:o=null);else{const n={params:{passingSchemas:i}};null===o?o=[n]:o.push(n),u++}m=t===u}else m=!0;if(m){if(void 0!==l.include){const t=u,e=u;let a=!1,i=null;const p=u;if(n(l.include,{instancePath:s+"/include",parentData:l,parentDataProperty:"include",rootData:r})||(o=null===o?n.errors:o.concat(n.errors),u=o.length),p===u&&(a=!0,i=0),a)u=e,null!==o&&(e?o.length=e:o=null);else{const n={params:{passingSchemas:i}};null===o?o=[n]:o.push(n),u++}m=t===u}else m=!0;if(m){if(void 0!==l.raw){const n=u;if("boolean"!=typeof l.raw){const n={params:{type:"boolean"}};null===o?o=[n]:o.push(n),u++}m=n===u}else m=!0;if(m)if(void 0!==l.test){const t=u,e=u;let a=!1,i=null;const p=u;if(n(l.test,{instancePath:s+"/test",parentData:l,parentDataProperty:"test",rootData:r})||(o=null===o?n.errors:o.concat(n.errors),u=o.length),p===u&&(a=!0,i=0),a)u=e,null!==o&&(e?o.length=e:o=null);else{const n={params:{passingSchemas:i}};null===o?o=[n]:o.push(n),u++}m=t===u}else m=!0}}}}}}}else{const n={params:{type:"object"}};null===o?o=[n]:o.push(n),u++}if(f=t===u,p=p||f,!p){const n=u;if(!(l instanceof Function)){const n={params:{}};null===o?o=[n]:o.push(n),u++}f=n===u,p=p||f}}if(!p){const n={params:{}};return null===o?o=[n]:o.push(n),u++,t.errors=o,!1}return u=i,null!==o&&(i?o.length=i:o=null),t.errors=o,0===u}module.exports=t,module.exports.default=t;
6
+ "use strict";function n(t,{instancePath:l="",parentData:e,parentDataProperty:s,rootData:a=t}={}){let r=null,o=0;const u=o;let i=!1;const p=o;if(o===p)if(Array.isArray(t)){const n=t.length;for(let l=0;l<n;l++){let n=t[l];const e=o,s=o;let a=!1,u=null;const i=o,p=o;let f=!1;const h=o;if(!(n instanceof RegExp)){const n={params:{}};null===r?r=[n]:r.push(n),o++}var c=h===o;if(f=f||c,!f){const t=o;if(o===t)if("string"==typeof n){if(n.length<1){const n={params:{}};null===r?r=[n]:r.push(n),o++}}else{const n={params:{type:"string"}};null===r?r=[n]:r.push(n),o++}c=t===o,f=f||c}if(f)o=p,null!==r&&(p?r.length=p:r=null);else{const n={params:{}};null===r?r=[n]:r.push(n),o++}if(i===o&&(a=!0,u=0),a)o=s,null!==r&&(s?r.length=s:r=null);else{const n={params:{passingSchemas:u}};null===r?r=[n]:r.push(n),o++}if(e!==o)break}}else{const n={params:{type:"array"}};null===r?r=[n]:r.push(n),o++}var f=p===o;if(i=i||f,!i){const n=o,l=o;let e=!1;const s=o;if(!(t instanceof RegExp)){const n={params:{}};null===r?r=[n]:r.push(n),o++}var h=s===o;if(e=e||h,!e){const n=o;if(o===n)if("string"==typeof t){if(t.length<1){const n={params:{}};null===r?r=[n]:r.push(n),o++}}else{const n={params:{type:"string"}};null===r?r=[n]:r.push(n),o++}h=n===o,e=e||h}if(e)o=l,null!==r&&(l?r.length=l:r=null);else{const n={params:{}};null===r?r=[n]:r.push(n),o++}f=n===o,i=i||f}if(!i){const t={params:{}};return null===r?r=[t]:r.push(t),o++,n.errors=r,!1}return o=u,null!==r&&(u?r.length=u:r=null),n.errors=r,0===o}function t(l,{instancePath:e="",parentData:s,parentDataProperty:a,rootData:r=l}={}){let o=null,u=0;const i=u;let p=!1;const c=u;if(u===c)if("string"==typeof l){if(l.length<1){const n={params:{}};null===o?o=[n]:o.push(n),u++}}else{const n={params:{type:"string"}};null===o?o=[n]:o.push(n),u++}var f=c===u;if(p=p||f,!p){const t=u;if(u===t)if(l&&"object"==typeof l&&!Array.isArray(l)){let t;if(void 0===l.banner&&(t="banner")){const n={params:{missingProperty:t}};null===o?o=[n]:o.push(n),u++}else{const t=u;for(const n in l)if("banner"!==n&&"entryOnly"!==n&&"exclude"!==n&&"footer"!==n&&"include"!==n&&"raw"!==n&&"test"!==n){const t={params:{additionalProperty:n}};null===o?o=[t]:o.push(t),u++;break}if(t===u){if(void 0!==l.banner){let n=l.banner;const t=u,e=u;let s=!1;const a=u;if("string"!=typeof n){const n={params:{type:"string"}};null===o?o=[n]:o.push(n),u++}var h=a===u;if(s=s||h,!s){const t=u;if(!(n instanceof Function)){const n={params:{}};null===o?o=[n]:o.push(n),u++}h=t===u,s=s||h}if(s)u=e,null!==o&&(e?o.length=e:o=null);else{const n={params:{}};null===o?o=[n]:o.push(n),u++}var y=t===u}else y=!0;if(y){if(void 0!==l.entryOnly){const n=u;if("boolean"!=typeof l.entryOnly){const n={params:{type:"boolean"}};null===o?o=[n]:o.push(n),u++}y=n===u}else y=!0;if(y){if(void 0!==l.exclude){const t=u,s=u;let a=!1,i=null;const p=u;if(n(l.exclude,{instancePath:e+"/exclude",parentData:l,parentDataProperty:"exclude",rootData:r})||(o=null===o?n.errors:o.concat(n.errors),u=o.length),p===u&&(a=!0,i=0),a)u=s,null!==o&&(s?o.length=s:o=null);else{const n={params:{passingSchemas:i}};null===o?o=[n]:o.push(n),u++}y=t===u}else y=!0;if(y){if(void 0!==l.footer){const n=u;if("boolean"!=typeof l.footer){const n={params:{type:"boolean"}};null===o?o=[n]:o.push(n),u++}y=n===u}else y=!0;if(y){if(void 0!==l.include){const t=u,s=u;let a=!1,i=null;const p=u;if(n(l.include,{instancePath:e+"/include",parentData:l,parentDataProperty:"include",rootData:r})||(o=null===o?n.errors:o.concat(n.errors),u=o.length),p===u&&(a=!0,i=0),a)u=s,null!==o&&(s?o.length=s:o=null);else{const n={params:{passingSchemas:i}};null===o?o=[n]:o.push(n),u++}y=t===u}else y=!0;if(y){if(void 0!==l.raw){const n=u;if("boolean"!=typeof l.raw){const n={params:{type:"boolean"}};null===o?o=[n]:o.push(n),u++}y=n===u}else y=!0;if(y)if(void 0!==l.test){const t=u,s=u;let a=!1,i=null;const p=u;if(n(l.test,{instancePath:e+"/test",parentData:l,parentDataProperty:"test",rootData:r})||(o=null===o?n.errors:o.concat(n.errors),u=o.length),p===u&&(a=!0,i=0),a)u=s,null!==o&&(s?o.length=s:o=null);else{const n={params:{passingSchemas:i}};null===o?o=[n]:o.push(n),u++}y=t===u}else y=!0}}}}}}}}else{const n={params:{type:"object"}};null===o?o=[n]:o.push(n),u++}if(f=t===u,p=p||f,!p){const n=u;if(!(l instanceof Function)){const n={params:{}};null===o?o=[n]:o.push(n),u++}f=n===u,p=p||f}}if(!p){const n={params:{}};return null===o?o=[n]:o.push(n),u++,t.errors=o,!1}return u=i,null!==o&&(i?o.length=i:o=null),t.errors=o,0===u}module.exports=t,module.exports.default=t;
@@ -73,6 +73,10 @@
73
73
  }
74
74
  ]
75
75
  },
76
+ "footer": {
77
+ "description": "If true, banner will be placed at the end of the output.",
78
+ "type": "boolean"
79
+ },
76
80
  "include": {
77
81
  "description": "Include all modules matching any of these conditions.",
78
82
  "oneOf": [
package/types.d.ts CHANGED
@@ -430,6 +430,11 @@ declare interface BannerPluginOptions {
430
430
  */
431
431
  exclude?: string | RegExp | Rule[];
432
432
 
433
+ /**
434
+ * If true, banner will be placed at the end of the output.
435
+ */
436
+ footer?: boolean;
437
+
433
438
  /**
434
439
  * Include all modules matching any of these conditions.
435
440
  */
@@ -474,9 +479,10 @@ declare abstract class BasicEvaluatedExpression {
474
479
  prefix?: BasicEvaluatedExpression;
475
480
  postfix?: BasicEvaluatedExpression;
476
481
  wrappedInnerExpressions: any;
477
- identifier?: string;
482
+ identifier?: string | VariableInfoInterface;
478
483
  rootInfo: VariableInfoInterface;
479
484
  getMembers: () => string[];
485
+ getMembersOptionals: () => boolean[];
480
486
  expression: NodeEstreeIndex;
481
487
  isUnknown(): boolean;
482
488
  isNull(): boolean;
@@ -528,7 +534,8 @@ declare abstract class BasicEvaluatedExpression {
528
534
  setIdentifier(
529
535
  identifier?: any,
530
536
  rootInfo?: any,
531
- getMembers?: any
537
+ getMembers?: any,
538
+ getMembersOptionals?: any
532
539
  ): BasicEvaluatedExpression;
533
540
  setWrapped(
534
541
  prefix?: any,
@@ -681,6 +688,7 @@ declare interface CallExpressionInfo {
681
688
  getCalleeMembers: () => string[];
682
689
  name: string;
683
690
  getMembers: () => string[];
691
+ getMembersOptionals: () => boolean[];
684
692
  }
685
693
  declare interface CallbackAsyncQueue<T> {
686
694
  (err?: null | WebpackError, result?: T): any;
@@ -809,6 +817,13 @@ declare class ChunkGraph {
809
817
  chunk: Chunk,
810
818
  sourceType: string
811
819
  ): undefined | Iterable<Module>;
820
+ setChunkModuleSourceTypes(
821
+ chunk: Chunk,
822
+ module: Module,
823
+ sourceTypes: Set<string>
824
+ ): void;
825
+ getChunkModuleSourceTypes(chunk: Chunk, module: Module): Set<string>;
826
+ getModuleSourceTypes(module: Module): Set<string>;
812
827
  getOrderedChunkModulesIterable(
813
828
  chunk: Chunk,
814
829
  comparator: (arg0: Module, arg1: Module) => 0 | 1 | -1
@@ -1239,6 +1254,16 @@ declare interface CodeGenerationContext {
1239
1254
  * code generation results of other modules (need to have a codeGenerationDependency to use that)
1240
1255
  */
1241
1256
  codeGenerationResults: CodeGenerationResults;
1257
+
1258
+ /**
1259
+ * the compilation
1260
+ */
1261
+ compilation?: Compilation;
1262
+
1263
+ /**
1264
+ * source types
1265
+ */
1266
+ sourceTypes?: ReadonlySet<string>;
1242
1267
  }
1243
1268
  declare interface CodeGenerationResult {
1244
1269
  /**
@@ -2454,7 +2479,7 @@ declare interface ContainerReferencePluginOptions {
2454
2479
  shareScope?: string;
2455
2480
  }
2456
2481
  declare abstract class ContextElementDependency extends ModuleDependency {
2457
- referencedExports: any;
2482
+ referencedExports?: string[][];
2458
2483
  }
2459
2484
  declare class ContextExclusionPlugin {
2460
2485
  constructor(negativeMatcher: RegExp);
@@ -2637,6 +2662,7 @@ declare class Dependency {
2637
2662
  endLine?: any,
2638
2663
  endColumn?: any
2639
2664
  ): void;
2665
+ getContext(): undefined | string;
2640
2666
  getResourceIdentifier(): null | string;
2641
2667
  couldAffectReferencingModule(): boolean | typeof TRANSITIVE;
2642
2668
 
@@ -3819,6 +3845,7 @@ declare interface ExpressionExpressionInfo {
3819
3845
  rootInfo: string | VariableInfo;
3820
3846
  name: string;
3821
3847
  getMembers: () => string[];
3848
+ getMembersOptionals: () => boolean[];
3822
3849
  }
3823
3850
  type ExternalItem =
3824
3851
  | string
@@ -5097,7 +5124,7 @@ declare class JavascriptParser extends Parser {
5097
5124
  topLevelAwait: SyncBailHook<[Expression], boolean | void>;
5098
5125
  call: HookMap<SyncBailHook<[Expression], boolean | void>>;
5099
5126
  callMemberChain: HookMap<
5100
- SyncBailHook<[CallExpression, string[]], boolean | void>
5127
+ SyncBailHook<[CallExpression, string[], boolean[]], boolean | void>
5101
5128
  >;
5102
5129
  memberChainOfCallMemberChain: HookMap<
5103
5130
  SyncBailHook<
@@ -5113,9 +5140,10 @@ declare class JavascriptParser extends Parser {
5113
5140
  >;
5114
5141
  optionalChaining: SyncBailHook<[ChainExpression], boolean | void>;
5115
5142
  new: HookMap<SyncBailHook<[NewExpression], boolean | void>>;
5143
+ binaryExpression: SyncBailHook<[BinaryExpression], boolean | void>;
5116
5144
  expression: HookMap<SyncBailHook<[Expression], boolean | void>>;
5117
5145
  expressionMemberChain: HookMap<
5118
- SyncBailHook<[Expression, string[]], boolean | void>
5146
+ SyncBailHook<[Expression, string[], boolean[]], boolean | void>
5119
5147
  >;
5120
5148
  unhandledExpressionMemberChain: HookMap<
5121
5149
  SyncBailHook<[Expression, string[]], boolean | void>
@@ -5183,7 +5211,7 @@ declare class JavascriptParser extends Parser {
5183
5211
  )[];
5184
5212
  prevStatement: any;
5185
5213
  currentTagData: any;
5186
- getRenameIdentifier(expr?: any): undefined | string;
5214
+ getRenameIdentifier(expr?: any): undefined | string | VariableInfoInterface;
5187
5215
  walkClass(classy: ClassExpression | ClassDeclaration): void;
5188
5216
  preWalkStatements(statements?: any): void;
5189
5217
  blockPreWalkStatements(statements?: any): void;
@@ -5330,12 +5358,10 @@ declare class JavascriptParser extends Parser {
5330
5358
  enterArrayPattern(pattern?: any, onIdent?: any): void;
5331
5359
  enterRestElement(pattern?: any, onIdent?: any): void;
5332
5360
  enterAssignmentPattern(pattern?: any, onIdent?: any): void;
5333
- evaluateExpression(
5334
- expression: Expression
5335
- ): undefined | BasicEvaluatedExpression;
5361
+ evaluateExpression(expression: Expression): BasicEvaluatedExpression;
5336
5362
  parseString(expression?: any): any;
5337
5363
  parseCalculatedString(expression?: any): any;
5338
- evaluate(source?: any): undefined | BasicEvaluatedExpression;
5364
+ evaluate(source: string): BasicEvaluatedExpression;
5339
5365
  isPure(
5340
5366
  expr:
5341
5367
  | undefined
@@ -5418,6 +5444,7 @@ declare class JavascriptParser extends Parser {
5418
5444
  | ImportExpression
5419
5445
  | ChainExpression
5420
5446
  | Super;
5447
+ membersOptionals: boolean[];
5421
5448
  };
5422
5449
  getFreeInfoFromVariable(varName: string): {
5423
5450
  name: string;
@@ -7481,11 +7508,11 @@ type NodeEstreeIndex =
7481
7508
  | PropertyDefinition
7482
7509
  | VariableDeclarator
7483
7510
  | Program
7484
- | Super
7485
7511
  | SwitchCase
7486
7512
  | CatchClause
7487
7513
  | Property
7488
7514
  | AssignmentProperty
7515
+ | Super
7489
7516
  | TemplateElement
7490
7517
  | SpreadElement
7491
7518
  | ObjectPattern