webpack 5.89.0 → 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 (148) 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/CommonJsImportsParserPlugin.js +1 -1
  52. package/lib/dependencies/ContextElementDependency.js +1 -1
  53. package/lib/dependencies/ExternalModuleDependency.js +98 -0
  54. package/lib/dependencies/ExternalModuleInitFragment.js +124 -0
  55. package/lib/dependencies/HarmonyAcceptDependency.js +1 -1
  56. package/lib/dependencies/HarmonyDetectionParserPlugin.js +7 -1
  57. package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +18 -18
  58. package/lib/dependencies/HarmonyExportInitFragment.js +4 -4
  59. package/lib/dependencies/HarmonyImportDependency.js +4 -4
  60. package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +6 -6
  61. package/lib/dependencies/ImportDependency.js +26 -6
  62. package/lib/dependencies/JsonExportsDependency.js +1 -1
  63. package/lib/dependencies/LoaderPlugin.js +2 -1
  64. package/lib/dependencies/PureExpressionDependency.js +12 -4
  65. package/lib/dependencies/RequireIncludeDependency.js +1 -1
  66. package/lib/dependencies/WebpackIsIncludedDependency.js +1 -1
  67. package/lib/dependencies/WorkerPlugin.js +7 -1
  68. package/lib/esm/ModuleChunkLoadingRuntimeModule.js +6 -6
  69. package/lib/hmr/HotModuleReplacement.runtime.js +3 -5
  70. package/lib/hmr/lazyCompilationBackend.js +4 -4
  71. package/lib/ids/DeterministicModuleIdsPlugin.js +1 -1
  72. package/lib/index.js +4 -0
  73. package/lib/javascript/JavascriptGenerator.js +16 -1
  74. package/lib/javascript/JavascriptModulesPlugin.js +33 -33
  75. package/lib/javascript/JavascriptParser.js +8 -0
  76. package/lib/json/JsonGenerator.js +1 -1
  77. package/lib/library/AmdLibraryPlugin.js +5 -1
  78. package/lib/library/AssignLibraryPlugin.js +1 -1
  79. package/lib/library/SystemLibraryPlugin.js +1 -1
  80. package/lib/library/UmdLibraryPlugin.js +39 -39
  81. package/lib/logging/createConsoleLogger.js +1 -19
  82. package/lib/node/ReadFileChunkLoadingRuntimeModule.js +8 -8
  83. package/lib/node/RequireChunkLoadingRuntimeModule.js +8 -8
  84. package/lib/node/nodeConsole.js +1 -5
  85. package/lib/optimize/ConcatenatedModule.js +7 -7
  86. package/lib/optimize/InnerGraphPlugin.js +9 -1
  87. package/lib/optimize/ModuleConcatenationPlugin.js +2 -2
  88. package/lib/optimize/RemoveParentModulesPlugin.js +123 -47
  89. package/lib/optimize/SideEffectsFlagPlugin.js +15 -3
  90. package/lib/optimize/SplitChunksPlugin.js +16 -16
  91. package/lib/prefetch/ChunkPrefetchStartupRuntimeModule.js +2 -2
  92. package/lib/rules/RuleSetCompiler.js +1 -1
  93. package/lib/runtime/AutoPublicPathRuntimeModule.js +2 -2
  94. package/lib/runtime/GetChunkFilenameRuntimeModule.js +4 -4
  95. package/lib/runtime/GetTrustedTypesPolicyRuntimeModule.js +4 -4
  96. package/lib/runtime/LoadScriptRuntimeModule.js +2 -2
  97. package/lib/runtime/StartupChunkDependenciesRuntimeModule.js +23 -22
  98. package/lib/runtime/StartupEntrypointRuntimeModule.js +2 -2
  99. package/lib/schemes/HttpUriPlugin.js +1 -1
  100. package/lib/serialization/FileMiddleware.js +4 -4
  101. package/lib/serialization/ObjectMiddleware.js +4 -4
  102. package/lib/sharing/ConsumeSharedPlugin.js +5 -5
  103. package/lib/sharing/ConsumeSharedRuntimeModule.js +8 -4
  104. package/lib/sharing/ProvideSharedModule.js +2 -2
  105. package/lib/sharing/SharePlugin.js +2 -2
  106. package/lib/sharing/ShareRuntimeModule.js +1 -1
  107. package/lib/sharing/utils.js +24 -28
  108. package/lib/stats/DefaultStatsFactoryPlugin.js +10 -10
  109. package/lib/stats/DefaultStatsPresetPlugin.js +3 -7
  110. package/lib/stats/DefaultStatsPrinterPlugin.js +34 -31
  111. package/lib/util/cleverMerge.js +4 -4
  112. package/lib/util/hash/xxhash64.js +2 -2
  113. package/lib/util/identifier.js +2 -2
  114. package/lib/util/internalSerializables.js +6 -0
  115. package/lib/util/runtime.js +18 -1
  116. package/lib/util/semver.js +19 -24
  117. package/lib/util/smartGrouping.js +1 -1
  118. package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +1 -1
  119. package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +2 -2
  120. package/lib/wasm-async/AsyncWebAssemblyParser.js +6 -0
  121. package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +2 -2
  122. package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +2 -2
  123. package/lib/web/JsonpChunkLoadingRuntimeModule.js +13 -13
  124. package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +6 -6
  125. package/package.json +23 -23
  126. package/schemas/WebpackOptions.check.js +1 -1
  127. package/schemas/WebpackOptions.json +140 -32
  128. package/schemas/plugins/css/CssAutoGeneratorOptions.check.d.ts +7 -0
  129. package/schemas/plugins/css/CssAutoGeneratorOptions.check.js +6 -0
  130. package/schemas/plugins/css/CssAutoGeneratorOptions.json +3 -0
  131. package/schemas/plugins/css/CssAutoParserOptions.check.d.ts +7 -0
  132. package/schemas/plugins/css/CssAutoParserOptions.check.js +6 -0
  133. package/schemas/plugins/css/CssAutoParserOptions.json +3 -0
  134. package/schemas/plugins/css/CssGeneratorOptions.check.js +1 -1
  135. package/schemas/plugins/css/CssGlobalGeneratorOptions.check.d.ts +7 -0
  136. package/schemas/plugins/css/CssGlobalGeneratorOptions.check.js +6 -0
  137. package/schemas/plugins/css/CssGlobalGeneratorOptions.json +3 -0
  138. package/schemas/plugins/css/CssGlobalParserOptions.check.d.ts +7 -0
  139. package/schemas/plugins/css/CssGlobalParserOptions.check.js +6 -0
  140. package/schemas/plugins/css/CssGlobalParserOptions.json +3 -0
  141. package/schemas/plugins/css/CssModuleGeneratorOptions.check.d.ts +7 -0
  142. package/schemas/plugins/css/CssModuleGeneratorOptions.check.js +6 -0
  143. package/schemas/plugins/css/CssModuleGeneratorOptions.json +3 -0
  144. package/schemas/plugins/css/CssModuleParserOptions.check.d.ts +7 -0
  145. package/schemas/plugins/css/CssModuleParserOptions.check.js +6 -0
  146. package/schemas/plugins/css/CssModuleParserOptions.json +3 -0
  147. package/schemas/plugins/css/CssParserOptions.check.js +1 -1
  148. package/types.d.ts +172 -20
@@ -28,7 +28,7 @@ const getExportsFromData = data => {
28
28
  canMangle: true,
29
29
  exports: getExportsFromData(item)
30
30
  };
31
- })
31
+ })
32
32
  : undefined;
33
33
  } else {
34
34
  const exports = [];
@@ -185,7 +185,8 @@ class LoaderPlugin {
185
185
  issuerLayer: options.layer
186
186
  },
187
187
  context: loaderContext.context,
188
- connectOrigin: false
188
+ connectOrigin: false,
189
+ checkCycle: true
189
190
  },
190
191
  err => {
191
192
  compilation.buildQueue.decreaseParallelism();
@@ -7,7 +7,7 @@
7
7
 
8
8
  const { UsageState } = require("../ExportsInfo");
9
9
  const makeSerializable = require("../util/makeSerializable");
10
- const { filterRuntime } = require("../util/runtime");
10
+ const { filterRuntime, deepMergeRuntime } = require("../util/runtime");
11
11
  const NullDependency = require("./NullDependency");
12
12
 
13
13
  /** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */
@@ -93,7 +93,14 @@ PureExpressionDependency.Template = class PureExpressionDependencyTemplate exten
93
93
  apply(
94
94
  dependency,
95
95
  source,
96
- { chunkGraph, moduleGraph, runtime, runtimeTemplate, runtimeRequirements }
96
+ {
97
+ chunkGraph,
98
+ moduleGraph,
99
+ runtime,
100
+ runtimes,
101
+ runtimeTemplate,
102
+ runtimeRequirements
103
+ }
97
104
  ) {
98
105
  const dep = /** @type {PureExpressionDependency} */ (dependency);
99
106
 
@@ -101,7 +108,8 @@ PureExpressionDependency.Template = class PureExpressionDependencyTemplate exten
101
108
  if (usedByExports !== false) {
102
109
  const selfModule = moduleGraph.getParentModule(dep);
103
110
  const exportsInfo = moduleGraph.getExportsInfo(selfModule);
104
- const runtimeCondition = filterRuntime(runtime, runtime => {
111
+ const merged = deepMergeRuntime(runtimes, runtime);
112
+ const runtimeCondition = filterRuntime(merged, runtime => {
105
113
  for (const exportName of usedByExports) {
106
114
  if (exportsInfo.getUsed(exportName, runtime) !== UsageState.Unused) {
107
115
  return true;
@@ -113,7 +121,7 @@ PureExpressionDependency.Template = class PureExpressionDependencyTemplate exten
113
121
  if (runtimeCondition !== false) {
114
122
  const condition = runtimeTemplate.runtimeConditionExpression({
115
123
  chunkGraph,
116
- runtime,
124
+ runtime: merged,
117
125
  runtimeCondition,
118
126
  runtimeRequirements
119
127
  });
@@ -69,7 +69,7 @@ RequireIncludeDependency.Template = class RequireIncludeDependencyTemplate exten
69
69
  `require.include ${runtimeTemplate.requestShortener.shorten(
70
70
  dep.request
71
71
  )}`
72
- )
72
+ )
73
73
  : "";
74
74
 
75
75
  source.replace(dep.range[0], dep.range[1] - 1, `undefined${comment}`);
@@ -71,7 +71,7 @@ WebpackIsIncludedDependency.Template = class WebpackIsIncludedDependencyTemplate
71
71
  `__webpack_is_included__ ${runtimeTemplate.requestShortener.shorten(
72
72
  dep.request
73
73
  )}`
74
- )
74
+ )
75
75
  : "";
76
76
 
77
77
  source.replace(
@@ -240,7 +240,7 @@ class WorkerPlugin {
240
240
  insertLocation: arg2
241
241
  ? /** @type {Range} */ (arg2.range)
242
242
  : /** @type {Range} */ (arg1.range)[1]
243
- };
243
+ };
244
244
  const { options: importOptions, errors: commentErrors } =
245
245
  parser.parseCommentOptions(/** @type {Range} */ (expr.range));
246
246
 
@@ -429,6 +429,12 @@ class WorkerPlugin {
429
429
  const pattern = item.slice(1, firstDot);
430
430
  const itemMembers = item.slice(firstDot + 1, -2);
431
431
 
432
+ parser.hooks.preDeclarator.tap(PLUGIN_NAME, (decl, statement) => {
433
+ if (decl.id.type === "Identifier" && decl.id.name === pattern) {
434
+ parser.tagVariable(decl.id.name, WorkerSpecifierTag);
435
+ return true;
436
+ }
437
+ });
432
438
  parser.hooks.pattern.for(pattern).tap(PLUGIN_NAME, pattern => {
433
439
  parser.tagVariable(pattern.name, WorkerSpecifierTag);
434
440
  return true;
@@ -172,7 +172,7 @@ class ModuleChunkLoadingRuntimeModule extends RuntimeModule {
172
172
  ]),
173
173
  "}",
174
174
  withOnChunkLoad ? `${RuntimeGlobals.onChunksLoaded}();` : ""
175
- ])}`
175
+ ])}`
176
176
  : "// no install chunk",
177
177
  "",
178
178
  withLoading
@@ -222,25 +222,25 @@ class ModuleChunkLoadingRuntimeModule extends RuntimeModule {
222
222
  "}"
223
223
  ]),
224
224
  "}"
225
- ])
225
+ ])
226
226
  : Template.indent(["installedChunks[chunkId] = 0;"])
227
227
  )};`
228
- ])
228
+ ])
229
229
  : "// no chunk on demand loading",
230
230
  "",
231
231
  withExternalInstallChunk
232
232
  ? Template.asString([
233
233
  `${RuntimeGlobals.externalInstallChunk} = installChunk;`
234
- ])
234
+ ])
235
235
  : "// no external install chunk",
236
236
  "",
237
237
  withOnChunkLoad
238
238
  ? `${
239
239
  RuntimeGlobals.onChunksLoaded
240
- }.j = ${runtimeTemplate.returningFunction(
240
+ }.j = ${runtimeTemplate.returningFunction(
241
241
  "installedChunks[chunkId] === 0",
242
242
  "chunkId"
243
- )};`
243
+ )};`
244
244
  : "// no on chunks loaded"
245
245
  ]);
246
246
  }
@@ -35,7 +35,6 @@ module.exports = function () {
35
35
  var currentUpdateApplyHandlers;
36
36
  var queuedInvalidatedModules;
37
37
 
38
- // eslint-disable-next-line no-unused-vars
39
38
  $hmrModuleData$ = currentModuleData;
40
39
 
41
40
  $interceptModuleExecution$.push(function (options) {
@@ -96,8 +95,8 @@ module.exports = function () {
96
95
  Object.defineProperty(fn, name, createPropertyDescriptor(name));
97
96
  }
98
97
  }
99
- fn.e = function (chunkId) {
100
- return trackBlockingPromise(require.e(chunkId));
98
+ fn.e = function (chunkId, fetchPriority) {
99
+ return trackBlockingPromise(require.e(chunkId, fetchPriority));
101
100
  };
102
101
  return fn;
103
102
  }
@@ -289,8 +288,7 @@ module.exports = function () {
289
288
  updatedModules
290
289
  );
291
290
  return promises;
292
- },
293
- [])
291
+ }, [])
294
292
  ).then(function () {
295
293
  return waitForBlockingPromises(function () {
296
294
  if (applyOnUpdate) {
@@ -37,7 +37,7 @@ module.exports = options => (compiler, callback) => {
37
37
  : (() => {
38
38
  const http = isHttps ? require("https") : require("http");
39
39
  return http.createServer.bind(http, options.server);
40
- })();
40
+ })();
41
41
  const listen =
42
42
  typeof options.listen === "function"
43
43
  ? options.listen
@@ -46,7 +46,7 @@ module.exports = options => (compiler, callback) => {
46
46
  if (typeof listen === "object" && !("port" in listen))
47
47
  listen = { ...listen, port: undefined };
48
48
  server.listen(listen);
49
- };
49
+ };
50
50
 
51
51
  const protocol = options.protocol || (isHttps ? "https" : "http");
52
52
 
@@ -109,8 +109,8 @@ module.exports = options => (compiler, callback) => {
109
109
  addr.address === "::" || addr.address === "0.0.0.0"
110
110
  ? `${protocol}://localhost:${addr.port}`
111
111
  : addr.family === "IPv6"
112
- ? `${protocol}://[${addr.address}]:${addr.port}`
113
- : `${protocol}://${addr.address}:${addr.port}`;
112
+ ? `${protocol}://[${addr.address}]:${addr.port}`
113
+ : `${protocol}://${addr.address}:${addr.port}`;
114
114
  logger.log(
115
115
  `Server-Sent-Events server for lazy compilation open at ${urlBase}.`
116
116
  );
@@ -66,7 +66,7 @@ class DeterministicModuleIdsPlugin {
66
66
  ? () => 0
67
67
  : compareModulesByPreOrderIndexOrIdentifier(
68
68
  compilation.moduleGraph
69
- ),
69
+ ),
70
70
  (module, id) => {
71
71
  const size = usedIds.size;
72
72
  usedIds.add(`${id}`);
package/lib/index.js CHANGED
@@ -37,6 +37,7 @@ const memoize = require("./util/memoize");
37
37
  /** @typedef {import("./Compilation").EntryOptions} EntryOptions */
38
38
  /** @typedef {import("./Compilation").PathData} PathData */
39
39
  /** @typedef {import("./Compiler").AssetEmittedInfo} AssetEmittedInfo */
40
+ /** @typedef {import("./MultiCompiler").MultiCompilerOptions} MultiCompilerOptions */
40
41
  /** @typedef {import("./MultiStats")} MultiStats */
41
42
  /** @typedef {import("./NormalModuleFactory").ResolveData} ResolveData */
42
43
  /** @typedef {import("./Parser").ParserState} ParserState */
@@ -270,6 +271,9 @@ module.exports = mergeExports(fn, {
270
271
  get MultiCompiler() {
271
272
  return require("./MultiCompiler");
272
273
  },
274
+ get OptimizationStages() {
275
+ return require("./OptimizationStages");
276
+ },
273
277
  get Parser() {
274
278
  return require("./Parser");
275
279
  },
@@ -190,6 +190,8 @@ class JavascriptGenerator extends Generator {
190
190
  );
191
191
  }
192
192
 
193
+ let chunkInitFragments;
194
+
193
195
  const templateContext = {
194
196
  runtimeTemplate: generateContext.runtimeTemplate,
195
197
  dependencyTemplates: generateContext.dependencyTemplates,
@@ -197,10 +199,23 @@ class JavascriptGenerator extends Generator {
197
199
  chunkGraph: generateContext.chunkGraph,
198
200
  module,
199
201
  runtime: generateContext.runtime,
202
+ runtimes: generateContext.runtimes,
200
203
  runtimeRequirements: generateContext.runtimeRequirements,
201
204
  concatenationScope: generateContext.concatenationScope,
202
205
  codeGenerationResults: generateContext.codeGenerationResults,
203
- initFragments
206
+ initFragments,
207
+ get chunkInitFragments() {
208
+ if (!chunkInitFragments) {
209
+ const data = generateContext.getData();
210
+ chunkInitFragments = data.get("chunkInitFragments");
211
+ if (!chunkInitFragments) {
212
+ chunkInitFragments = [];
213
+ data.set("chunkInitFragments", chunkInitFragments);
214
+ }
215
+ }
216
+
217
+ return chunkInitFragments;
218
+ }
204
219
  };
205
220
 
206
221
  template.apply(dependency, source, templateContext);
@@ -679,8 +679,8 @@ class JavascriptModulesPlugin {
679
679
  return strictHeader
680
680
  ? new ConcatSource(strictHeader, source, ";")
681
681
  : renderContext.runtimeTemplate.isModule()
682
- ? source
683
- : new ConcatSource(source, ";");
682
+ ? source
683
+ : new ConcatSource(source, ";");
684
684
  }
685
685
 
686
686
  /**
@@ -751,7 +751,7 @@ class JavascriptModulesPlugin {
751
751
  inlinedModules
752
752
  ? allModules.filter(
753
753
  m => !(/** @type {Set<Module>} */ (inlinedModules).has(m))
754
- )
754
+ )
755
755
  : allModules,
756
756
  module => this.renderModule(module, chunkRenderContext, hooks, true),
757
757
  prefix
@@ -837,14 +837,14 @@ class JavascriptModulesPlugin {
837
837
  let iife = innerStrict
838
838
  ? "it need to be in strict mode."
839
839
  : inlinedModules.size > 1
840
- ? // TODO check globals and top-level declarations of other entries and chunk modules
841
- // to make a better decision
842
- "it need to be isolated against other entry modules."
843
- : chunkModules
844
- ? "it need to be isolated against other modules in the chunk."
845
- : exports && !webpackExports
846
- ? `it uses a non-standard name for the exports (${m.exportsArgument}).`
847
- : hooks.embedInRuntimeBailout.call(m, renderContext);
840
+ ? // TODO check globals and top-level declarations of other entries and chunk modules
841
+ // to make a better decision
842
+ "it need to be isolated against other entry modules."
843
+ : chunkModules
844
+ ? "it need to be isolated against other modules in the chunk."
845
+ : exports && !webpackExports
846
+ ? `it uses a non-standard name for the exports (${m.exportsArgument}).`
847
+ : hooks.embedInRuntimeBailout.call(m, renderContext);
848
848
  let footer;
849
849
  if (iife !== undefined) {
850
850
  startupSource.add(
@@ -1310,14 +1310,14 @@ class JavascriptModulesPlugin {
1310
1310
  `${RuntimeGlobals.interceptModuleExecution}.forEach(function(handler) { handler(execOptions); });`,
1311
1311
  "module = execOptions.module;",
1312
1312
  "execOptions.factory.call(module.exports, module, module.exports, execOptions.require);"
1313
- ])
1313
+ ])
1314
1314
  : runtimeRequirements.has(RuntimeGlobals.thisAsExports)
1315
- ? Template.asString([
1316
- `__webpack_modules__[moduleId].call(module.exports, module, module.exports, ${RuntimeGlobals.require});`
1317
- ])
1318
- : Template.asString([
1319
- `__webpack_modules__[moduleId](module, module.exports, ${RuntimeGlobals.require});`
1320
- ]);
1315
+ ? Template.asString([
1316
+ `__webpack_modules__[moduleId].call(module.exports, module, module.exports, ${RuntimeGlobals.require});`
1317
+ ])
1318
+ : Template.asString([
1319
+ `__webpack_modules__[moduleId](module, module.exports, ${RuntimeGlobals.require});`
1320
+ ]);
1321
1321
  const needModuleId = runtimeRequirements.has(RuntimeGlobals.moduleId);
1322
1322
  const needModuleLoaded = runtimeRequirements.has(
1323
1323
  RuntimeGlobals.moduleLoaded
@@ -1330,7 +1330,7 @@ class JavascriptModulesPlugin {
1330
1330
  ? Template.indent([
1331
1331
  "if (cachedModule.error !== undefined) throw cachedModule.error;",
1332
1332
  "return cachedModule.exports;"
1333
- ])
1333
+ ])
1334
1334
  : Template.indent("return cachedModule.exports;"),
1335
1335
  "}",
1336
1336
  "// Create a new module (and put it into the cache)",
@@ -1353,27 +1353,27 @@ class JavascriptModulesPlugin {
1353
1353
  "if(threw) delete __webpack_module_cache__[moduleId];"
1354
1354
  ]),
1355
1355
  "}"
1356
- ])
1356
+ ])
1357
1357
  : outputOptions.strictModuleErrorHandling
1358
- ? Template.asString([
1359
- "// Execute the module function",
1360
- "try {",
1361
- Template.indent(moduleExecution),
1362
- "} catch(e) {",
1363
- Template.indent(["module.error = e;", "throw e;"]),
1364
- "}"
1365
- ])
1366
- : Template.asString([
1367
- "// Execute the module function",
1368
- moduleExecution
1369
- ]),
1358
+ ? Template.asString([
1359
+ "// Execute the module function",
1360
+ "try {",
1361
+ Template.indent(moduleExecution),
1362
+ "} catch(e) {",
1363
+ Template.indent(["module.error = e;", "throw e;"]),
1364
+ "}"
1365
+ ])
1366
+ : Template.asString([
1367
+ "// Execute the module function",
1368
+ moduleExecution
1369
+ ]),
1370
1370
  needModuleLoaded
1371
1371
  ? Template.asString([
1372
1372
  "",
1373
1373
  "// Flag the module as loaded",
1374
1374
  `${RuntimeGlobals.moduleLoaded} = true;`,
1375
1375
  ""
1376
- ])
1376
+ ])
1377
1377
  : "",
1378
1378
  "// Return the exports of the module",
1379
1379
  "return module.exports;"
@@ -4071,6 +4071,14 @@ class JavascriptParser extends Parser {
4071
4071
  return false;
4072
4072
  }
4073
4073
 
4074
+ if (
4075
+ expr.superClass &&
4076
+ item.type === "MethodDefinition" &&
4077
+ item.kind === "constructor"
4078
+ ) {
4079
+ return false;
4080
+ }
4081
+
4074
4082
  return true;
4075
4083
  });
4076
4084
  }
@@ -183,7 +183,7 @@ class JsonGenerator extends Generator {
183
183
  const jsonStr = /** @type {string} */ (stringifySafe(finalJson));
184
184
  const jsonExpr =
185
185
  jsonStr.length > 20 && typeof finalJson === "object"
186
- ? `JSON.parse('${jsonStr.replace(/[\\']/g, "\\$&")}')`
186
+ ? `/*#__PURE__*/JSON.parse('${jsonStr.replace(/[\\']/g, "\\$&")}')`
187
187
  : jsonStr;
188
188
  /** @type {string} */
189
189
  let content;
@@ -87,7 +87,11 @@ class AmdLibraryPlugin extends AbstractLibraryPlugin {
87
87
  const modern = runtimeTemplate.supportsArrowFunction();
88
88
  const modules = chunkGraph
89
89
  .getChunkModules(chunk)
90
- .filter(m => m instanceof ExternalModule);
90
+ .filter(
91
+ m =>
92
+ m instanceof ExternalModule &&
93
+ (m.externalType === "amd" || m.externalType === "amd-require")
94
+ );
91
95
  const externals = /** @type {ExternalModule[]} */ (modules);
92
96
  const externalsDepsArray = JSON.stringify(
93
97
  externals.map(m =>
@@ -295,7 +295,7 @@ class AssignLibraryPlugin extends AbstractLibraryPlugin {
295
295
  const exportAccess = options.export
296
296
  ? propertyAccess(
297
297
  Array.isArray(options.export) ? options.export : [options.export]
298
- )
298
+ )
299
299
  : "";
300
300
  const result = new ConcatSource(source);
301
301
  if (staticExports) {
@@ -187,7 +187,7 @@ class SystemLibraryPlugin extends AbstractLibraryPlugin {
187
187
  .join(",\n")
188
188
  ),
189
189
  "],"
190
- ]);
190
+ ]);
191
191
 
192
192
  return new ConcatSource(
193
193
  Template.asString([
@@ -243,8 +243,8 @@ class UmdLibraryPlugin extends AbstractLibraryPlugin {
243
243
  const factoryArguments =
244
244
  requiredExternals.length > 0
245
245
  ? externalsArguments(requiredExternals) +
246
- ", " +
247
- externalsRootArray(optionalExternals)
246
+ ", " +
247
+ externalsRootArray(optionalExternals)
248
248
  : externalsRootArray(optionalExternals);
249
249
  amdFactory =
250
250
  `function webpackLoadOptionalExternalModuleAmd(${wrapperArguments}) {\n` +
@@ -283,55 +283,55 @@ class UmdLibraryPlugin extends AbstractLibraryPlugin {
283
283
  (requiredExternals.length > 0
284
284
  ? names.amd && namedDefine === true
285
285
  ? " define(" +
286
- libraryName(names.amd) +
287
- ", " +
288
- externalsDepsArray(requiredExternals) +
289
- ", " +
290
- amdFactory +
291
- ");\n"
286
+ libraryName(names.amd) +
287
+ ", " +
288
+ externalsDepsArray(requiredExternals) +
289
+ ", " +
290
+ amdFactory +
291
+ ");\n"
292
292
  : " define(" +
293
- externalsDepsArray(requiredExternals) +
294
- ", " +
295
- amdFactory +
296
- ");\n"
293
+ externalsDepsArray(requiredExternals) +
294
+ ", " +
295
+ amdFactory +
296
+ ");\n"
297
297
  : names.amd && namedDefine === true
298
- ? " define(" +
299
- libraryName(names.amd) +
300
- ", [], " +
301
- amdFactory +
302
- ");\n"
303
- : " define([], " + amdFactory + ");\n") +
298
+ ? " define(" +
299
+ libraryName(names.amd) +
300
+ ", [], " +
301
+ amdFactory +
302
+ ");\n"
303
+ : " define([], " + amdFactory + ");\n") +
304
304
  (names.root || names.commonjs
305
305
  ? getAuxiliaryComment("commonjs") +
306
- " else if(typeof exports === 'object')\n" +
307
- " exports[" +
308
- libraryName(names.commonjs || names.root) +
309
- "] = factory(" +
310
- externalsRequireArray("commonjs") +
311
- ");\n" +
312
- getAuxiliaryComment("root") +
313
- " else\n" +
314
- " " +
315
- replaceKeys(
306
+ " else if(typeof exports === 'object')\n" +
307
+ " exports[" +
308
+ libraryName(names.commonjs || names.root) +
309
+ "] = factory(" +
310
+ externalsRequireArray("commonjs") +
311
+ ");\n" +
312
+ getAuxiliaryComment("root") +
313
+ " else\n" +
314
+ " " +
315
+ replaceKeys(
316
316
  accessorAccess(
317
317
  "root",
318
318
  /** @type {string | string[]} */ (names.root) ||
319
319
  /** @type {string} */ (names.commonjs)
320
320
  )
321
- ) +
322
- " = factory(" +
323
- externalsRootArray(externals) +
324
- ");\n"
321
+ ) +
322
+ " = factory(" +
323
+ externalsRootArray(externals) +
324
+ ");\n"
325
325
  : " else {\n" +
326
- (externals.length > 0
326
+ (externals.length > 0
327
327
  ? " var a = typeof exports === 'object' ? factory(" +
328
- externalsRequireArray("commonjs") +
329
- ") : factory(" +
330
- externalsRootArray(externals) +
331
- ");\n"
328
+ externalsRequireArray("commonjs") +
329
+ ") : factory(" +
330
+ externalsRootArray(externals) +
331
+ ");\n"
332
332
  : " var a = factory();\n") +
333
- " for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];\n" +
334
- " }\n") +
333
+ " for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];\n" +
334
+ " }\n") +
335
335
  `})(${runtimeTemplate.outputOptions.globalObject}, ${
336
336
  runtimeTemplate.supportsArrowFunction()
337
337
  ? `(${externalsArguments(externals)}) =>`
@@ -45,11 +45,7 @@ const { LogType } = require("./Logger");
45
45
  const filterToFunction = item => {
46
46
  if (typeof item === "string") {
47
47
  const regExp = new RegExp(
48
- `[\\\\/]${item.replace(
49
- // eslint-disable-next-line no-useless-escape
50
- /[-[\]{}()*+?.\\^$|]/g,
51
- "\\$&"
52
- )}([\\\\/]|$|!|\\?)`
48
+ `[\\\\/]${item.replace(/[-[\]{}()*+?.\\^$|]/g, "\\$&")}([\\\\/]|$|!|\\?)`
53
49
  );
54
50
  return ident => regExp.test(ident);
55
51
  }
@@ -114,9 +110,7 @@ module.exports = ({ level = "info", debug = false, console }) => {
114
110
  switch (type) {
115
111
  case LogType.debug:
116
112
  if (!debug) return;
117
- // eslint-disable-next-line node/no-unsupported-features/node-builtins
118
113
  if (typeof console.debug === "function") {
119
- // eslint-disable-next-line node/no-unsupported-features/node-builtins
120
114
  console.debug(...labeledArgs());
121
115
  } else {
122
116
  console.log(...labeledArgs());
@@ -145,9 +139,7 @@ module.exports = ({ level = "info", debug = false, console }) => {
145
139
  case LogType.groupCollapsed:
146
140
  if (!debug && loglevel > LogLevel.log) return;
147
141
  if (!debug && loglevel > LogLevel.verbose) {
148
- // eslint-disable-next-line node/no-unsupported-features/node-builtins
149
142
  if (typeof console.groupCollapsed === "function") {
150
- // eslint-disable-next-line node/no-unsupported-features/node-builtins
151
143
  console.groupCollapsed(...labeledArgs());
152
144
  } else {
153
145
  console.log(...labeledArgs());
@@ -157,9 +149,7 @@ module.exports = ({ level = "info", debug = false, console }) => {
157
149
  // falls through
158
150
  case LogType.group:
159
151
  if (!debug && loglevel > LogLevel.log) return;
160
- // eslint-disable-next-line node/no-unsupported-features/node-builtins
161
152
  if (typeof console.group === "function") {
162
- // eslint-disable-next-line node/no-unsupported-features/node-builtins
163
153
  console.group(...labeledArgs());
164
154
  } else {
165
155
  console.log(...labeledArgs());
@@ -167,9 +157,7 @@ module.exports = ({ level = "info", debug = false, console }) => {
167
157
  break;
168
158
  case LogType.groupEnd:
169
159
  if (!debug && loglevel > LogLevel.log) return;
170
- // eslint-disable-next-line node/no-unsupported-features/node-builtins
171
160
  if (typeof console.groupEnd === "function") {
172
- // eslint-disable-next-line node/no-unsupported-features/node-builtins
173
161
  console.groupEnd();
174
162
  }
175
163
  break;
@@ -185,24 +173,18 @@ module.exports = ({ level = "info", debug = false, console }) => {
185
173
  break;
186
174
  }
187
175
  case LogType.profile:
188
- // eslint-disable-next-line node/no-unsupported-features/node-builtins
189
176
  if (typeof console.profile === "function") {
190
- // eslint-disable-next-line node/no-unsupported-features/node-builtins
191
177
  console.profile(...labeledArgs());
192
178
  }
193
179
  break;
194
180
  case LogType.profileEnd:
195
- // eslint-disable-next-line node/no-unsupported-features/node-builtins
196
181
  if (typeof console.profileEnd === "function") {
197
- // eslint-disable-next-line node/no-unsupported-features/node-builtins
198
182
  console.profileEnd(...labeledArgs());
199
183
  }
200
184
  break;
201
185
  case LogType.clear:
202
186
  if (!debug && loglevel > LogLevel.log) return;
203
- // eslint-disable-next-line node/no-unsupported-features/node-builtins
204
187
  if (typeof console.clear === "function") {
205
- // eslint-disable-next-line node/no-unsupported-features/node-builtins
206
188
  console.clear();
207
189
  }
208
190
  break;