webpack 5.37.0 → 5.39.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 (139) hide show
  1. package/README.md +5 -8
  2. package/bin/webpack.js +20 -5
  3. package/lib/AsyncDependencyToInitialChunkError.js +0 -2
  4. package/lib/CacheFacade.js +3 -3
  5. package/lib/CaseSensitiveModulesWarning.js +0 -2
  6. package/lib/Chunk.js +8 -5
  7. package/lib/ChunkRenderError.js +0 -2
  8. package/lib/CodeGenerationError.js +0 -2
  9. package/lib/CommentCompilationWarning.js +0 -2
  10. package/lib/Compilation.js +43 -55
  11. package/lib/Compiler.js +7 -4
  12. package/lib/ConcatenationScope.js +2 -1
  13. package/lib/ConcurrentCompilationError.js +0 -2
  14. package/lib/ContextModule.js +5 -4
  15. package/lib/ContextModuleFactory.js +3 -1
  16. package/lib/ContextReplacementPlugin.js +4 -3
  17. package/lib/DefinePlugin.js +16 -12
  18. package/lib/DllReferencePlugin.js +0 -2
  19. package/lib/EntryPlugin.js +3 -3
  20. package/lib/EvalSourceMapDevToolPlugin.js +3 -1
  21. package/lib/ExportsInfo.js +20 -13
  22. package/lib/FileSystemInfo.js +24 -30
  23. package/lib/FlagDependencyExportsPlugin.js +8 -7
  24. package/lib/FlagDependencyUsagePlugin.js +2 -4
  25. package/lib/HarmonyLinkingError.js +0 -2
  26. package/lib/HookWebpackError.js +0 -1
  27. package/lib/HotModuleReplacementPlugin.js +27 -32
  28. package/lib/InvalidDependenciesModuleWarning.js +0 -2
  29. package/lib/JavascriptMetaInfoPlugin.js +2 -1
  30. package/lib/MainTemplate.js +2 -3
  31. package/lib/ModuleBuildError.js +0 -2
  32. package/lib/ModuleDependencyError.js +0 -2
  33. package/lib/ModuleDependencyWarning.js +0 -2
  34. package/lib/ModuleError.js +0 -2
  35. package/lib/ModuleFilenameHelpers.js +4 -2
  36. package/lib/ModuleGraphConnection.js +6 -2
  37. package/lib/ModuleInfoHeaderPlugin.js +2 -3
  38. package/lib/ModuleNotFoundError.js +0 -2
  39. package/lib/ModuleParseError.js +0 -2
  40. package/lib/ModuleRestoreError.js +0 -2
  41. package/lib/ModuleStoreError.js +0 -2
  42. package/lib/ModuleWarning.js +0 -2
  43. package/lib/MultiCompiler.js +31 -27
  44. package/lib/NoModeWarning.js +0 -2
  45. package/lib/NormalModule.js +26 -8
  46. package/lib/NormalModuleFactory.js +2 -0
  47. package/lib/RecordIdsPlugin.js +5 -4
  48. package/lib/ResolverFactory.js +10 -7
  49. package/lib/SourceMapDevToolPlugin.js +13 -14
  50. package/lib/Template.js +4 -2
  51. package/lib/UnsupportedFeatureWarning.js +0 -2
  52. package/lib/WarnDeprecatedOptionPlugin.js +0 -2
  53. package/lib/Watching.js +91 -47
  54. package/lib/WebpackError.js +0 -2
  55. package/lib/asset/AssetGenerator.js +46 -29
  56. package/lib/asset/AssetModulesPlugin.js +1 -1
  57. package/lib/buildChunkGraph.js +21 -21
  58. package/lib/cache/PackFileCacheStrategy.js +12 -9
  59. package/lib/config/defaults.js +21 -10
  60. package/lib/config/normalization.js +8 -7
  61. package/lib/config/target.js +7 -2
  62. package/lib/debug/ProfilingPlugin.js +4 -3
  63. package/lib/dependencies/AMDRequireDependency.js +3 -3
  64. package/lib/dependencies/CommonJsExportRequireDependency.js +2 -3
  65. package/lib/dependencies/CommonJsExportsParserPlugin.js +3 -1
  66. package/lib/dependencies/CommonJsImportsParserPlugin.js +2 -4
  67. package/lib/dependencies/CommonJsPlugin.js +8 -7
  68. package/lib/dependencies/CommonJsRequireContextDependency.js +2 -1
  69. package/lib/dependencies/ContextDependencyHelpers.js +10 -8
  70. package/lib/dependencies/ContextElementDependency.js +6 -1
  71. package/lib/dependencies/CriticalDependencyWarning.js +0 -2
  72. package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +11 -13
  73. package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +2 -4
  74. package/lib/dependencies/HarmonyImportSpecifierDependency.js +4 -11
  75. package/lib/dependencies/ImportDependency.js +3 -3
  76. package/lib/dependencies/ImportParserPlugin.js +3 -4
  77. package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +2 -3
  78. package/lib/dependencies/RequireEnsureDependency.js +3 -3
  79. package/lib/dependencies/RequireIncludeDependencyParserPlugin.js +0 -2
  80. package/lib/dependencies/SystemPlugin.js +0 -2
  81. package/lib/dependencies/WorkerDependency.js +6 -6
  82. package/lib/dependencies/WorkerPlugin.js +18 -19
  83. package/lib/errors/BuildCycleError.js +0 -1
  84. package/lib/hmr/LazyCompilationPlugin.js +9 -5
  85. package/lib/ids/HashedModuleIdsPlugin.js +3 -3
  86. package/lib/ids/OccurrenceModuleIdsPlugin.js +2 -3
  87. package/lib/index.js +5 -3
  88. package/lib/javascript/ArrayPushCallbackChunkFormatPlugin.js +4 -6
  89. package/lib/javascript/CommonJsChunkFormatPlugin.js +2 -3
  90. package/lib/javascript/JavascriptGenerator.js +3 -1
  91. package/lib/javascript/JavascriptModulesPlugin.js +15 -23
  92. package/lib/javascript/JavascriptParser.js +10 -8
  93. package/lib/library/AssignLibraryPlugin.js +4 -2
  94. package/lib/node/NodeEnvironmentPlugin.js +1 -0
  95. package/lib/node/NodeWatchFileSystem.js +19 -4
  96. package/lib/optimize/AggressiveSplittingPlugin.js +5 -4
  97. package/lib/optimize/ConcatenatedModule.js +31 -27
  98. package/lib/optimize/FlagIncludedChunksPlugin.js +4 -6
  99. package/lib/optimize/InnerGraph.js +9 -11
  100. package/lib/optimize/InnerGraphPlugin.js +3 -1
  101. package/lib/optimize/ModuleConcatenationPlugin.js +7 -10
  102. package/lib/optimize/RealContentHashPlugin.js +14 -16
  103. package/lib/optimize/SideEffectsFlagPlugin.js +6 -5
  104. package/lib/optimize/SplitChunksPlugin.js +13 -15
  105. package/lib/performance/AssetsOverSizeLimitWarning.js +0 -2
  106. package/lib/performance/EntrypointsOverSizeLimitWarning.js +0 -2
  107. package/lib/performance/NoAsyncChunksWarning.js +0 -2
  108. package/lib/runtime/EnsureChunkRuntimeModule.js +9 -8
  109. package/lib/runtime/LoadScriptRuntimeModule.js +2 -3
  110. package/lib/runtime/OnChunksLoadedRuntimeModule.js +38 -37
  111. package/lib/schemes/DataUriPlugin.js +21 -2
  112. package/lib/serialization/BinaryMiddleware.js +5 -3
  113. package/lib/serialization/FileMiddleware.js +3 -1
  114. package/lib/serialization/ObjectMiddleware.js +11 -7
  115. package/lib/stats/DefaultStatsFactoryPlugin.js +7 -7
  116. package/lib/stats/DefaultStatsPrinterPlugin.js +11 -9
  117. package/lib/stats/StatsFactory.js +2 -1
  118. package/lib/stats/StatsPrinter.js +3 -3
  119. package/lib/util/LazyBucketSortedSet.js +3 -3
  120. package/lib/util/cleverMerge.js +3 -1
  121. package/lib/util/comparators.js +13 -13
  122. package/lib/util/createHash.js +5 -4
  123. package/lib/util/identifier.js +2 -1
  124. package/lib/util/serialization.js +108 -59
  125. package/lib/validateSchema.js +5 -3
  126. package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +4 -4
  127. package/lib/wasm-sync/UnsupportedWebAssemblyFeatureError.js +0 -2
  128. package/lib/wasm-sync/WasmFinalizeExportsPlugin.js +5 -4
  129. package/lib/wasm-sync/WebAssemblyGenerator.js +89 -83
  130. package/lib/wasm-sync/WebAssemblyInInitialChunkError.js +0 -2
  131. package/lib/wasm-sync/WebAssemblyModulesPlugin.js +2 -1
  132. package/lib/wasm-sync/WebAssemblyParser.js +6 -5
  133. package/lib/web/JsonpChunkLoadingRuntimeModule.js +2 -4
  134. package/lib/webpack.js +11 -7
  135. package/package.json +9 -6
  136. package/schemas/WebpackOptions.check.js +1 -1
  137. package/schemas/WebpackOptions.json +76 -60
  138. package/types.d.ts +112 -262
  139. package/lib/util/DataURI.js +0 -32
@@ -186,21 +186,18 @@ class WorkerPlugin {
186
186
  spread: hasSpreadInOptions,
187
187
  insertType,
188
188
  insertLocation
189
- } =
190
- arg2 && arg2.type === "ObjectExpression"
191
- ? parseObjectExpression(parser, arg2)
192
- : {
193
- expressions: {},
194
- otherElements: [],
195
- values: {},
196
- spread: false,
197
- insertType: arg2 ? "spread" : "argument",
198
- insertLocation: arg2 ? arg2.range : arg1.range[1]
199
- };
200
- const {
201
- options: importOptions,
202
- errors: commentErrors
203
- } = parser.parseCommentOptions(expr.range);
189
+ } = arg2 && arg2.type === "ObjectExpression"
190
+ ? parseObjectExpression(parser, arg2)
191
+ : {
192
+ expressions: {},
193
+ otherElements: [],
194
+ values: {},
195
+ spread: false,
196
+ insertType: arg2 ? "spread" : "argument",
197
+ insertLocation: arg2 ? arg2.range : arg1.range[1]
198
+ };
199
+ const { options: importOptions, errors: commentErrors } =
200
+ parser.parseCommentOptions(expr.range);
204
201
 
205
202
  if (commentErrors) {
206
203
  for (const e of commentErrors) {
@@ -280,9 +277,9 @@ class WorkerPlugin {
280
277
  )}|${i}`;
281
278
  const hash = createHash(compilation.outputOptions.hashFunction);
282
279
  hash.update(name);
283
- const digest = /** @type {string} */ (hash.digest(
284
- compilation.outputOptions.hashDigest
285
- ));
280
+ const digest = /** @type {string} */ (
281
+ hash.digest(compilation.outputOptions.hashDigest)
282
+ );
286
283
  entryOptions.runtime = digest.slice(
287
284
  0,
288
285
  compilation.outputOptions.hashDigestLength
@@ -368,7 +365,9 @@ class WorkerPlugin {
368
365
  (call ? parser.hooks.call : parser.hooks.new)
369
366
  .for(harmonySpecifierTag)
370
367
  .tap("WorkerPlugin", expr => {
371
- const settings = /** @type {HarmonySettings} */ (parser.currentTagData);
368
+ const settings = /** @type {HarmonySettings} */ (
369
+ parser.currentTagData
370
+ );
372
371
  if (
373
372
  !settings ||
374
373
  settings.source !== source ||
@@ -21,7 +21,6 @@ class BuildCycleError extends WebpackError {
21
21
 
22
22
  this.name = "BuildCycleError";
23
23
  this.module = module;
24
- Error.captureStackTrace(this, this.constructor);
25
24
  }
26
25
  }
27
26
 
@@ -196,8 +196,9 @@ class LazyCompilationProxyModule extends Module {
196
196
  const sources = new Map();
197
197
  const runtimeRequirements = new Set();
198
198
  runtimeRequirements.add(RuntimeGlobals.module);
199
- const clientDep = /** @type {CommonJsRequireDependency} */ (this
200
- .dependencies[0]);
199
+ const clientDep = /** @type {CommonJsRequireDependency} */ (
200
+ this.dependencies[0]
201
+ );
201
202
  const clientModule = moduleGraph.getModule(clientDep);
202
203
  const block = this.blocks[0];
203
204
  const client = Template.asString([
@@ -290,8 +291,9 @@ class LazyCompilationDependencyFactory extends ModuleFactory {
290
291
  * @returns {void}
291
292
  */
292
293
  create(data, callback) {
293
- const dependency = /** @type {LazyCompilationDependency} */ (data
294
- .dependencies[0]);
294
+ const dependency = /** @type {LazyCompilationDependency} */ (
295
+ data.dependencies[0]
296
+ );
295
297
  callback(null, {
296
298
  module: dependency.proxyModule.originalModule
297
299
  });
@@ -348,7 +350,9 @@ class LazyCompilationPlugin {
348
350
  resolveData.dependencies.every(
349
351
  dep =>
350
352
  IGNORED_DEPENDENCY_TYPES.has(dep.type) ||
351
- (this.imports && dep.type === "import()") ||
353
+ (this.imports &&
354
+ (dep.type === "import()" ||
355
+ dep.type === "import() context element")) ||
352
356
  (this.entries && dep.type === "entry")
353
357
  ) &&
354
358
  !/webpack[/\\]hot[/\\]|webpack-dev-server[/\\]client/.test(
@@ -63,9 +63,9 @@ class HashedModuleIdsPlugin {
63
63
  const ident = getFullModuleName(module, context, compiler.root);
64
64
  const hash = createHash(options.hashFunction);
65
65
  hash.update(ident || "");
66
- const hashId = /** @type {string} */ (hash.digest(
67
- options.hashDigest
68
- ));
66
+ const hashId = /** @type {string} */ (
67
+ hash.digest(options.hashDigest)
68
+ );
69
69
  let len = options.hashDigestLength;
70
70
  while (usedIds.has(hashId.substr(0, len))) len++;
71
71
  const moduleId = hashId.substr(0, len);
@@ -98,9 +98,8 @@ class OccurrenceModuleIdsPlugin {
98
98
  connections
99
99
  ] of moduleGraph.getIncomingConnectionsByOriginModule(module)) {
100
100
  if (!originModule) continue;
101
- const chunkModules = chunkGraph.getNumberOfModuleChunks(
102
- originModule
103
- );
101
+ const chunkModules =
102
+ chunkGraph.getNumberOfModuleChunks(originModule);
104
103
  for (const c of connections) {
105
104
  if (!c.isTargetActive(undefined)) continue;
106
105
  if (!c.dependency) continue;
package/lib/index.js CHANGED
@@ -50,9 +50,11 @@ const memoize = require("./util/memoize");
50
50
  */
51
51
  const lazyFunction = factory => {
52
52
  const fac = memoize(factory);
53
- const f = /** @type {any} */ ((...args) => {
54
- return fac()(...args);
55
- });
53
+ const f = /** @type {any} */ (
54
+ (...args) => {
55
+ return fac()(...args);
56
+ }
57
+ );
56
58
  return /** @type {T} */ (f);
57
59
  };
58
60
 
@@ -47,9 +47,8 @@ class ArrayPushCallbackChunkFormatPlugin {
47
47
  chunk instanceof HotUpdateChunk ? chunk : null;
48
48
  const globalObject = runtimeTemplate.outputOptions.globalObject;
49
49
  const source = new ConcatSource();
50
- const runtimeModules = chunkGraph.getChunkRuntimeModulesInOrder(
51
- chunk
52
- );
50
+ const runtimeModules =
51
+ chunkGraph.getChunkRuntimeModulesInOrder(chunk);
53
52
  if (hotUpdateChunk) {
54
53
  const hotUpdateGlobal =
55
54
  runtimeTemplate.outputOptions.hotUpdateGlobal;
@@ -83,9 +82,8 @@ class ArrayPushCallbackChunkFormatPlugin {
83
82
  chunkGraph.getChunkEntryModulesWithChunkGroupIterable(chunk)
84
83
  );
85
84
  if (runtimeModules.length > 0 || entries.length > 0) {
86
- const strictBailout = hooks.strictRuntimeBailout.call(
87
- renderContext
88
- );
85
+ const strictBailout =
86
+ hooks.strictRuntimeBailout.call(renderContext);
89
87
  const runtime = new ConcatSource(
90
88
  (runtimeTemplate.supportsArrowFunction()
91
89
  ? "__webpack_require__ =>"
@@ -51,9 +51,8 @@ class CommonJsChunkFormatPlugin {
51
51
  source.add(`exports.modules = `);
52
52
  source.add(modules);
53
53
  source.add(";\n");
54
- const runtimeModules = chunkGraph.getChunkRuntimeModulesInOrder(
55
- chunk
56
- );
54
+ const runtimeModules =
55
+ chunkGraph.getChunkRuntimeModulesInOrder(chunk);
57
56
  if (runtimeModules.length > 0) {
58
57
  source.add("exports.runtime =\n");
59
58
  source.add(
@@ -180,7 +180,9 @@ class JavascriptGenerator extends Generator {
180
180
  * @returns {void}
181
181
  */
182
182
  sourceDependency(module, dependency, initFragments, source, generateContext) {
183
- const constructor = /** @type {new (...args: any[]) => Dependency} */ (dependency.constructor);
183
+ const constructor = /** @type {new (...args: any[]) => Dependency} */ (
184
+ dependency.constructor
185
+ );
184
186
  const template = generateContext.dependencyTemplates.get(constructor);
185
187
  if (!template) {
186
188
  throw new Error(
@@ -228,10 +228,11 @@ class JavascriptModulesPlugin {
228
228
  chunk instanceof HotUpdateChunk ? chunk : null;
229
229
 
230
230
  let render;
231
- const filenameTemplate = JavascriptModulesPlugin.getChunkFilenameTemplate(
232
- chunk,
233
- outputOptions
234
- );
231
+ const filenameTemplate =
232
+ JavascriptModulesPlugin.getChunkFilenameTemplate(
233
+ chunk,
234
+ outputOptions
235
+ );
235
236
  if (hotUpdateChunk) {
236
237
  render = () =>
237
238
  this.renderChunk(
@@ -394,9 +395,8 @@ class JavascriptModulesPlugin {
394
395
  compilation.hooks.executeModule.tap(
395
396
  "JavascriptModulesPlugin",
396
397
  (options, context) => {
397
- const source = options.codeGenerationResult.sources.get(
398
- "javascript"
399
- );
398
+ const source =
399
+ options.codeGenerationResult.sources.get("javascript");
400
400
  if (source === undefined) return;
401
401
  const { module, moduleObject } = options;
402
402
  const code = source.source();
@@ -468,12 +468,8 @@ class JavascriptModulesPlugin {
468
468
  * @returns {Source} the newly generated source from rendering
469
469
  */
470
470
  renderModule(module, renderContext, hooks, factory) {
471
- const {
472
- chunk,
473
- chunkGraph,
474
- runtimeTemplate,
475
- codeGenerationResults
476
- } = renderContext;
471
+ const { chunk, chunkGraph, runtimeTemplate, codeGenerationResults } =
472
+ renderContext;
477
473
  try {
478
474
  const moduleSource = codeGenerationResults.getSource(
479
475
  module,
@@ -699,9 +695,8 @@ class JavascriptModulesPlugin {
699
695
  );
700
696
  }
701
697
 
702
- const runtimeModules = renderContext.chunkGraph.getChunkRuntimeModulesInOrder(
703
- chunk
704
- );
698
+ const runtimeModules =
699
+ renderContext.chunkGraph.getChunkRuntimeModulesInOrder(chunk);
705
700
 
706
701
  if (runtimeModules.length > 0) {
707
702
  source.add(
@@ -985,9 +980,8 @@ class JavascriptModulesPlugin {
985
980
  if (chunkGraph.getNumberOfEntryModules(chunk) > 0) {
986
981
  /** @type {string[]} */
987
982
  const buf2 = [];
988
- const runtimeRequirements = chunkGraph.getTreeRuntimeRequirements(
989
- chunk
990
- );
983
+ const runtimeRequirements =
984
+ chunkGraph.getTreeRuntimeRequirements(chunk);
991
985
  buf2.push("// Load entry module and return exports");
992
986
  let i = chunkGraph.getNumberOfEntryModules(chunk);
993
987
  for (const [
@@ -1044,10 +1038,8 @@ class JavascriptModulesPlugin {
1044
1038
  }
1045
1039
  i--;
1046
1040
  const moduleId = chunkGraph.getModuleId(entryModule);
1047
- const entryRuntimeRequirements = chunkGraph.getModuleRuntimeRequirements(
1048
- entryModule,
1049
- chunk.runtime
1050
- );
1041
+ const entryRuntimeRequirements =
1042
+ chunkGraph.getModuleRuntimeRequirements(entryModule, chunk.runtime);
1051
1043
  let moduleIdExpr = JSON.stringify(moduleId);
1052
1044
  if (runtimeRequirements.has(RuntimeGlobals.entryModuleId)) {
1053
1045
  moduleIdExpr = `${RuntimeGlobals.entryModuleId} = ${moduleIdExpr}`;
@@ -3336,8 +3336,10 @@ class JavascriptParser extends Parser {
3336
3336
  if (expr.superClass && !this.isPure(expr.superClass, expr.range[0])) {
3337
3337
  return false;
3338
3338
  }
3339
- const items = /** @type {(MethodDefinitionNode | PropertyDefinitionNode)[]} */ (expr
3340
- .body.body);
3339
+ const items =
3340
+ /** @type {(MethodDefinitionNode | PropertyDefinitionNode)[]} */ (
3341
+ expr.body.body
3342
+ );
3341
3343
  return items.every(
3342
3344
  item =>
3343
3345
  (!item.computed ||
@@ -3623,10 +3625,8 @@ class JavascriptParser extends Parser {
3623
3625
  let callee = object.callee;
3624
3626
  let rootMembers = EMPTY_ARRAY;
3625
3627
  if (callee.type === "MemberExpression") {
3626
- ({
3627
- object: callee,
3628
- members: rootMembers
3629
- } = this.extractMemberExpressionChain(callee));
3628
+ ({ object: callee, members: rootMembers } =
3629
+ this.extractMemberExpressionChain(callee));
3630
3630
  }
3631
3631
  const rootName = getRootName(callee);
3632
3632
  if (!rootName) return undefined;
@@ -3729,5 +3729,7 @@ class JavascriptParser extends Parser {
3729
3729
 
3730
3730
  module.exports = JavascriptParser;
3731
3731
  module.exports.ALLOWED_MEMBER_TYPES_ALL = ALLOWED_MEMBER_TYPES_ALL;
3732
- module.exports.ALLOWED_MEMBER_TYPES_EXPRESSION = ALLOWED_MEMBER_TYPES_EXPRESSION;
3733
- module.exports.ALLOWED_MEMBER_TYPES_CALL_EXPRESSION = ALLOWED_MEMBER_TYPES_CALL_EXPRESSION;
3732
+ module.exports.ALLOWED_MEMBER_TYPES_EXPRESSION =
3733
+ ALLOWED_MEMBER_TYPES_EXPRESSION;
3734
+ module.exports.ALLOWED_MEMBER_TYPES_CALL_EXPRESSION =
3735
+ ALLOWED_MEMBER_TYPES_CALL_EXPRESSION;
@@ -24,8 +24,10 @@ const AbstractLibraryPlugin = require("./AbstractLibraryPlugin");
24
24
  /** @typedef {import("../util/Hash")} Hash */
25
25
  /** @template T @typedef {import("./AbstractLibraryPlugin").LibraryContext<T>} LibraryContext<T> */
26
26
 
27
- const KEYWORD_REGEX = /^(await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|false|finally|for|function|if|implements|import|in|instanceof|interface|let|new|null|package|private|protected|public|return|super|switch|static|this|throw|try|true|typeof|var|void|while|with|yield)$/;
28
- const IDENTIFIER_REGEX = /^[\p{L}\p{Nl}$_][\p{L}\p{Nl}$\p{Mn}\p{Mc}\p{Nd}\p{Pc}]*$/iu;
27
+ const KEYWORD_REGEX =
28
+ /^(await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|false|finally|for|function|if|implements|import|in|instanceof|interface|let|new|null|package|private|protected|public|return|super|switch|static|this|throw|try|true|typeof|var|void|while|with|yield)$/;
29
+ const IDENTIFIER_REGEX =
30
+ /^[\p{L}\p{Nl}$_][\p{L}\p{Nl}$\p{Mn}\p{Mc}\p{Nd}\p{Pc}]*$/iu;
29
31
 
30
32
  /**
31
33
  * Validates the library name by checking for keywords and valid characters
@@ -50,6 +50,7 @@ class NodeEnvironmentPlugin {
50
50
  );
51
51
  compiler.hooks.beforeRun.tap("NodeEnvironmentPlugin", compiler => {
52
52
  if (compiler.inputFileSystem === inputFileSystem) {
53
+ compiler.fsStartTime = Date.now();
53
54
  inputFileSystem.purge();
54
55
  }
55
56
  });
@@ -70,11 +70,12 @@ class NodeWatchFileSystem {
70
70
  }
71
71
  this.watcher.once("aggregated", (changes, removals) => {
72
72
  if (this.inputFileSystem && this.inputFileSystem.purge) {
73
+ const fs = this.inputFileSystem;
73
74
  for (const item of changes) {
74
- this.inputFileSystem.purge(item);
75
+ fs.purge(item);
75
76
  }
76
77
  for (const item of removals) {
77
- this.inputFileSystem.purge(item);
78
+ fs.purge(item);
78
79
  }
79
80
  }
80
81
  const times = this.watcher.getTimeInfoEntries();
@@ -99,10 +100,24 @@ class NodeWatchFileSystem {
99
100
  }
100
101
  },
101
102
  getAggregatedRemovals: () => {
102
- return this.watcher && this.watcher.aggregatedRemovals;
103
+ const items = this.watcher && this.watcher.aggregatedRemovals;
104
+ if (items && this.inputFileSystem && this.inputFileSystem.purge) {
105
+ const fs = this.inputFileSystem;
106
+ for (const item of items) {
107
+ fs.purge(item);
108
+ }
109
+ }
110
+ return items;
103
111
  },
104
112
  getAggregatedChanges: () => {
105
- return this.watcher && this.watcher.aggregatedChanges;
113
+ const items = this.watcher && this.watcher.aggregatedChanges;
114
+ if (items && this.inputFileSystem && this.inputFileSystem.purge) {
115
+ const fs = this.inputFileSystem;
116
+ for (const item of items) {
117
+ fs.purge(item);
118
+ }
119
+ }
120
+ return items;
106
121
  },
107
122
  getFileTimeInfoEntries: () => {
108
123
  if (this.watcher) {
@@ -109,10 +109,11 @@ class AggressiveSplittingPlugin {
109
109
  // Precompute stuff
110
110
  const nameToModuleMap = new Map();
111
111
  const moduleToNameMap = new Map();
112
- const makePathsRelative = identifierUtils.makePathsRelative.bindContextCache(
113
- compiler.context,
114
- compiler.root
115
- );
112
+ const makePathsRelative =
113
+ identifierUtils.makePathsRelative.bindContextCache(
114
+ compiler.context,
115
+ compiler.root
116
+ );
116
117
  for (const m of compilation.modules) {
117
118
  const name = makePathsRelative(m.identifier());
118
119
  nameToModuleMap.set(name, m);
@@ -6,6 +6,7 @@
6
6
  "use strict";
7
7
 
8
8
  const eslintScope = require("eslint-scope");
9
+ const Referencer = require("eslint-scope/lib/referencer");
9
10
  const {
10
11
  CachedSource,
11
12
  ConcatSource,
@@ -58,6 +59,14 @@ const {
58
59
  /** @typedef {import("../util/fs").InputFileSystem} InputFileSystem */
59
60
  /** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */
60
61
 
62
+ // fix eslint-scope to support class properties correctly
63
+ // cspell:word Referencer
64
+ const ReferencerClass = Referencer;
65
+ if (!ReferencerClass.prototype.PropertyDefinition) {
66
+ ReferencerClass.prototype.PropertyDefinition =
67
+ ReferencerClass.prototype.Property;
68
+ }
69
+
61
70
  /**
62
71
  * @typedef {Object} ReexportInfo
63
72
  * @property {Module} module
@@ -381,10 +390,9 @@ const getFinalBinding = (
381
390
  }
382
391
  const directExport = info.exportMap && info.exportMap.get(exportId);
383
392
  if (directExport) {
384
- const usedName = /** @type {string[]} */ (exportsInfo.getUsedName(
385
- exportName,
386
- runtime
387
- ));
393
+ const usedName = /** @type {string[]} */ (
394
+ exportsInfo.getUsedName(exportName, runtime)
395
+ );
388
396
  if (!usedName) {
389
397
  return {
390
398
  info,
@@ -443,10 +451,9 @@ const getFinalBinding = (
443
451
  );
444
452
  }
445
453
  if (info.namespaceExportSymbol) {
446
- const usedName = /** @type {string[]} */ (exportsInfo.getUsedName(
447
- exportName,
448
- runtime
449
- ));
454
+ const usedName = /** @type {string[]} */ (
455
+ exportsInfo.getUsedName(exportName, runtime)
456
+ );
450
457
  return {
451
458
  info,
452
459
  rawName: info.namespaceObjectName,
@@ -462,10 +469,9 @@ const getFinalBinding = (
462
469
  }
463
470
 
464
471
  case "external": {
465
- const used = /** @type {string[]} */ (exportsInfo.getUsedName(
466
- exportName,
467
- runtime
468
- ));
472
+ const used = /** @type {string[]} */ (
473
+ exportsInfo.getUsedName(exportName, runtime)
474
+ );
469
475
  if (!used) {
470
476
  return {
471
477
  info,
@@ -883,8 +889,9 @@ class ConcatenatedModule extends Module {
883
889
  })
884
890
  .map(connection => ({
885
891
  connection,
886
- sourceOrder: /** @type {HarmonyImportDependency} */ (connection.dependency)
887
- .sourceOrder
892
+ sourceOrder: /** @type {HarmonyImportDependency} */ (
893
+ connection.dependency
894
+ ).sourceOrder
888
895
  }));
889
896
  references.sort(
890
897
  concatComparators(bySourceOrder, keepOriginalOrder(references))
@@ -1162,13 +1169,11 @@ class ConcatenatedModule extends Module {
1162
1169
  true
1163
1170
  );
1164
1171
  if (!binding.ids) continue;
1165
- const {
1166
- usedNames,
1167
- alreadyCheckedScopes
1168
- } = getUsedNamesInScopeInfo(
1169
- binding.info.module.identifier(),
1170
- "name" in binding ? binding.name : ""
1171
- );
1172
+ const { usedNames, alreadyCheckedScopes } =
1173
+ getUsedNamesInScopeInfo(
1174
+ binding.info.module.identifier(),
1175
+ "name" in binding ? binding.name : ""
1176
+ );
1172
1177
  for (const expr of getSuperClassExpressions(reference.from)) {
1173
1178
  if (
1174
1179
  expr.range[0] <= reference.identifier.range[0] &&
@@ -1361,9 +1366,9 @@ class ConcatenatedModule extends Module {
1361
1366
  /** @type {Set<string>} */
1362
1367
  const unusedExports = new Set();
1363
1368
 
1364
- const rootInfo = /** @type {ConcatenatedModuleInfo} */ (moduleToInfoMap.get(
1365
- this.rootModule
1366
- ));
1369
+ const rootInfo = /** @type {ConcatenatedModuleInfo} */ (
1370
+ moduleToInfoMap.get(this.rootModule)
1371
+ );
1367
1372
  const strictHarmonyModule = rootInfo.module.buildMeta.strictHarmonyModule;
1368
1373
  const exportsInfo = moduleGraph.getExportsInfo(rootInfo.module);
1369
1374
  for (const exportInfo of exportsInfo.orderedExports) {
@@ -1531,9 +1536,8 @@ ${defineGetters}`
1531
1536
  )}\n`
1532
1537
  );
1533
1538
  runtimeRequirements.add(RuntimeGlobals.require);
1534
- const {
1535
- runtimeCondition
1536
- } = /** @type {ExternalModuleInfo | ReferenceToModuleInfo} */ (rawInfo);
1539
+ const { runtimeCondition } =
1540
+ /** @type {ExternalModuleInfo | ReferenceToModuleInfo} */ (rawInfo);
1537
1541
  const condition = runtimeTemplate.runtimeConditionExpression({
1538
1542
  chunkGraph,
1539
1543
  runtimeCondition,
@@ -68,9 +68,8 @@ class FlagIncludedChunksPlugin {
68
68
 
69
69
  for (const chunkA of chunks) {
70
70
  const chunkAHash = chunkModulesHash.get(chunkA);
71
- const chunkAModulesCount = chunkGraph.getNumberOfChunkModules(
72
- chunkA
73
- );
71
+ const chunkAModulesCount =
72
+ chunkGraph.getNumberOfChunkModules(chunkA);
74
73
  if (chunkAModulesCount === 0) continue;
75
74
  let bestModule = undefined;
76
75
  for (const module of chunkGraph.getChunkModulesIterable(chunkA)) {
@@ -88,9 +87,8 @@ class FlagIncludedChunksPlugin {
88
87
  // skip if we find ourselves
89
88
  if (chunkA === chunkB) continue;
90
89
 
91
- const chunkBModulesCount = chunkGraph.getNumberOfChunkModules(
92
- chunkB
93
- );
90
+ const chunkBModulesCount =
91
+ chunkGraph.getNumberOfChunkModules(chunkB);
94
92
 
95
93
  // ids for empty chunks are not included
96
94
  if (chunkBModulesCount === 0) continue;
@@ -103,10 +103,9 @@ exports.addUsage = (state, symbol, usage) => {
103
103
  */
104
104
  exports.addVariableUsage = (parser, name, usage) => {
105
105
  const symbol =
106
- /** @type {TopLevelSymbol} */ (parser.getTagData(
107
- name,
108
- topLevelSymbolTag
109
- )) || exports.tagTopLevelSymbol(parser, name);
106
+ /** @type {TopLevelSymbol} */ (
107
+ parser.getTagData(name, topLevelSymbolTag)
108
+ ) || exports.tagTopLevelSymbol(parser, name);
110
109
  if (symbol) {
111
110
  exports.addUsage(parser.state, symbol, usage);
112
111
  }
@@ -179,9 +178,9 @@ exports.inferDependencyUsage = state => {
179
178
 
180
179
  /** @type {Map<Dependency, true | Set<string>>} */
181
180
  for (const [symbol, callbacks] of usageCallbackMap) {
182
- const usage = /** @type {true | Set<string> | undefined} */ (innerGraph.get(
183
- symbol
184
- ));
181
+ const usage = /** @type {true | Set<string> | undefined} */ (
182
+ innerGraph.get(symbol)
183
+ );
185
184
  for (const callback of callbacks) {
186
185
  callback(usage === undefined ? false : usage);
187
186
  }
@@ -249,10 +248,9 @@ exports.tagTopLevelSymbol = (parser, name) => {
249
248
 
250
249
  parser.defineVariable(name);
251
250
 
252
- const existingTag = /** @type {TopLevelSymbol} */ (parser.getTagData(
253
- name,
254
- topLevelSymbolTag
255
- ));
251
+ const existingTag = /** @type {TopLevelSymbol} */ (
252
+ parser.getTagData(name, topLevelSymbolTag)
253
+ );
256
254
  if (existingTag) {
257
255
  return existingTag;
258
256
  }
@@ -300,7 +300,9 @@ class InnerGraphPlugin {
300
300
  parser.hooks.expression
301
301
  .for(topLevelSymbolTag)
302
302
  .tap("InnerGraphPlugin", () => {
303
- const topLevelSymbol = /** @type {TopLevelSymbol} */ (parser.currentTagData);
303
+ const topLevelSymbol = /** @type {TopLevelSymbol} */ (
304
+ parser.currentTagData
305
+ );
304
306
  const currentTopLevelSymbol = InnerGraph.getTopLevelSymbol(
305
307
  parser.state
306
308
  );
@@ -316,9 +316,8 @@ class ModuleConcatenationPlugin {
316
316
  }
317
317
  } else {
318
318
  statsEmptyConfigurations++;
319
- const optimizationBailouts = moduleGraph.getOptimizationBailout(
320
- currentRoot
321
- );
319
+ const optimizationBailouts =
320
+ moduleGraph.getOptimizationBailout(currentRoot);
322
321
  for (const warning of currentConfiguration.getWarningsSorted()) {
323
322
  optimizationBailouts.push(
324
323
  formatBailoutWarning(warning[0], warning[1])
@@ -574,20 +573,18 @@ class ModuleConcatenationPlugin {
574
573
 
575
574
  const moduleGraph = compilation.moduleGraph;
576
575
 
577
- const incomingConnections = moduleGraph.getIncomingConnectionsByOriginModule(
578
- module
579
- );
576
+ const incomingConnections =
577
+ moduleGraph.getIncomingConnectionsByOriginModule(module);
580
578
 
581
579
  const incomingConnectionsFromNonModules =
582
580
  incomingConnections.get(null) || incomingConnections.get(undefined);
583
581
  if (incomingConnectionsFromNonModules) {
584
- const activeNonModulesConnections = incomingConnectionsFromNonModules.filter(
585
- connection => {
582
+ const activeNonModulesConnections =
583
+ incomingConnectionsFromNonModules.filter(connection => {
586
584
  // We are not interested in inactive connections
587
585
  // or connections without dependency
588
586
  return connection.isActive(runtime) || connection.dependency;
589
- }
590
- );
587
+ });
591
588
  if (activeNonModulesConnections.length > 0) {
592
589
  const problem = requestShortener => {
593
590
  const importingExplanations = new Set(