webpack 5.83.1 → 5.84.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 (137) hide show
  1. package/README.md +2 -2
  2. package/lib/CompatibilityPlugin.js +3 -2
  3. package/lib/Compilation.js +2 -2
  4. package/lib/ContextModule.js +3 -3
  5. package/lib/DefinePlugin.js +11 -2
  6. package/lib/DllEntryPlugin.js +5 -0
  7. package/lib/DllModule.js +1 -1
  8. package/lib/EvalSourceMapDevToolPlugin.js +3 -1
  9. package/lib/MainTemplate.js +2 -2
  10. package/lib/PrefetchPlugin.js +4 -0
  11. package/lib/RuntimeTemplate.js +5 -5
  12. package/lib/SelfModuleFactory.js +12 -0
  13. package/lib/SourceMapDevToolPlugin.js +9 -2
  14. package/lib/Template.js +2 -1
  15. package/lib/config/browserslistTargetHandler.js +3 -3
  16. package/lib/config/defaults.js +209 -70
  17. package/lib/config/normalization.js +103 -71
  18. package/lib/config/target.js +37 -10
  19. package/lib/container/FallbackModule.js +1 -1
  20. package/lib/container/RemoteRuntimeModule.js +1 -1
  21. package/lib/css/CssParser.js +168 -73
  22. package/lib/debug/ProfilingPlugin.js +11 -0
  23. package/lib/dependencies/AMDDefineDependency.js +12 -6
  24. package/lib/dependencies/AMDDefineDependencyParserPlugin.js +8 -2
  25. package/lib/dependencies/AMDPlugin.js +7 -0
  26. package/lib/dependencies/AMDRequireArrayDependency.js +5 -0
  27. package/lib/dependencies/AMDRequireContextDependency.js +6 -0
  28. package/lib/dependencies/AMDRequireDependenciesBlock.js +6 -0
  29. package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +8 -2
  30. package/lib/dependencies/AMDRequireDependency.js +8 -1
  31. package/lib/dependencies/AMDRequireItemDependency.js +6 -0
  32. package/lib/dependencies/CachedConstDependency.js +6 -0
  33. package/lib/dependencies/CommonJsExportRequireDependency.js +11 -0
  34. package/lib/dependencies/CommonJsExportsDependency.js +8 -0
  35. package/lib/dependencies/CommonJsExportsParserPlugin.js +2 -2
  36. package/lib/dependencies/CommonJsFullRequireDependency.js +2 -1
  37. package/lib/dependencies/CommonJsPlugin.js +14 -0
  38. package/lib/dependencies/CommonJsRequireContextDependency.js +8 -0
  39. package/lib/dependencies/CommonJsRequireDependency.js +7 -0
  40. package/lib/dependencies/CommonJsSelfReferenceDependency.js +8 -0
  41. package/lib/dependencies/ConstDependency.js +2 -1
  42. package/lib/dependencies/ContextDependencyHelpers.js +3 -3
  43. package/lib/dependencies/CreateScriptUrlDependency.js +2 -1
  44. package/lib/dependencies/CriticalDependencyWarning.js +3 -0
  45. package/lib/dependencies/CssImportDependency.js +2 -1
  46. package/lib/dependencies/CssLocalIdentifierDependency.js +2 -1
  47. package/lib/dependencies/CssSelfLocalIdentifierDependency.js +2 -1
  48. package/lib/dependencies/CssUrlDependency.js +12 -2
  49. package/lib/dependencies/DelegatedSourceDependency.js +3 -0
  50. package/lib/dependencies/ExportsInfoDependency.js +6 -0
  51. package/lib/dependencies/HarmonyAcceptDependency.js +2 -1
  52. package/lib/dependencies/HarmonyAcceptImportDependency.js +3 -0
  53. package/lib/dependencies/HarmonyDetectionParserPlugin.js +16 -0
  54. package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +11 -0
  55. package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +3 -0
  56. package/lib/dependencies/HarmonyExportExpressionDependency.js +8 -0
  57. package/lib/dependencies/HarmonyExportHeaderDependency.js +5 -0
  58. package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +2 -1
  59. package/lib/dependencies/HarmonyExportSpecifierDependency.js +4 -0
  60. package/lib/dependencies/HarmonyImportDependency.js +2 -1
  61. package/lib/dependencies/HarmonyImportSideEffectDependency.js +6 -0
  62. package/lib/dependencies/HarmonyImportSpecifierDependency.js +11 -0
  63. package/lib/dependencies/HarmonyModulesPlugin.js +12 -0
  64. package/lib/dependencies/ImportContextDependency.js +6 -0
  65. package/lib/dependencies/ImportDependency.js +2 -1
  66. package/lib/dependencies/ImportEagerDependency.js +2 -1
  67. package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +32 -13
  68. package/lib/dependencies/ImportMetaContextPlugin.js +7 -0
  69. package/lib/dependencies/ImportMetaHotAcceptDependency.js +6 -0
  70. package/lib/dependencies/ImportMetaHotDeclineDependency.js +6 -0
  71. package/lib/dependencies/ImportParserPlugin.js +5 -0
  72. package/lib/dependencies/ImportPlugin.js +7 -0
  73. package/lib/dependencies/ImportWeakDependency.js +2 -1
  74. package/lib/dependencies/LocalModule.js +16 -0
  75. package/lib/dependencies/LocalModuleDependency.js +7 -0
  76. package/lib/dependencies/LocalModulesHelpers.js +18 -0
  77. package/lib/dependencies/ModuleHotAcceptDependency.js +6 -0
  78. package/lib/dependencies/ModuleHotDeclineDependency.js +6 -0
  79. package/lib/dependencies/PrefetchDependency.js +3 -0
  80. package/lib/dependencies/ProvidedDependency.js +2 -1
  81. package/lib/dependencies/PureExpressionDependency.js +2 -1
  82. package/lib/dependencies/RequireContextDependency.js +6 -0
  83. package/lib/dependencies/RequireContextPlugin.js +7 -0
  84. package/lib/dependencies/RequireEnsureDependenciesBlock.js +4 -0
  85. package/lib/dependencies/RequireEnsureDependency.js +8 -2
  86. package/lib/dependencies/RequireEnsureItemDependency.js +3 -0
  87. package/lib/dependencies/RequireEnsurePlugin.js +14 -0
  88. package/lib/dependencies/RequireHeaderDependency.js +5 -1
  89. package/lib/dependencies/RequireIncludeDependency.js +5 -0
  90. package/lib/dependencies/RequireIncludeDependencyParserPlugin.js +3 -0
  91. package/lib/dependencies/RequireIncludePlugin.js +14 -0
  92. package/lib/dependencies/RequireResolveContextDependency.js +8 -0
  93. package/lib/dependencies/RequireResolveDependency.js +6 -0
  94. package/lib/dependencies/RequireResolveHeaderDependency.js +4 -0
  95. package/lib/dependencies/SystemPlugin.js +10 -1
  96. package/lib/dependencies/URLDependency.js +3 -2
  97. package/lib/dependencies/URLPlugin.js +7 -5
  98. package/lib/dependencies/UnsupportedDependency.js +5 -0
  99. package/lib/dependencies/WebAssemblyExportImportedDependency.js +6 -0
  100. package/lib/dependencies/WebpackIsIncludedDependency.js +5 -0
  101. package/lib/dependencies/WorkerDependency.js +2 -1
  102. package/lib/dependencies/WorkerPlugin.js +5 -2
  103. package/lib/dependencies/getFunctionExpression.js +7 -0
  104. package/lib/esm/ExportWebpackRequireRuntimeModule.js +2 -1
  105. package/lib/esm/ModuleChunkFormatPlugin.js +2 -2
  106. package/lib/esm/ModuleChunkLoadingRuntimeModule.js +5 -2
  107. package/lib/javascript/ArrayPushCallbackChunkFormatPlugin.js +2 -2
  108. package/lib/javascript/CommonJsChunkFormatPlugin.js +1 -1
  109. package/lib/javascript/JavascriptModulesPlugin.js +13 -13
  110. package/lib/javascript/JavascriptParser.js +540 -180
  111. package/lib/javascript/StartupHelpers.js +1 -1
  112. package/lib/node/ReadFileChunkLoadingRuntimeModule.js +2 -2
  113. package/lib/node/RequireChunkLoadingRuntimeModule.js +2 -2
  114. package/lib/optimize/ConcatenatedModule.js +1 -1
  115. package/lib/optimize/InnerGraphPlugin.js +11 -4
  116. package/lib/runtime/StartupChunkDependenciesRuntimeModule.js +1 -1
  117. package/lib/runtime/StartupEntrypointRuntimeModule.js +5 -5
  118. package/lib/serialization/ArraySerializer.js +22 -6
  119. package/lib/serialization/BinaryMiddleware.js +21 -0
  120. package/lib/serialization/DateObjectSerializer.js +15 -4
  121. package/lib/serialization/ErrorObjectSerializer.js +20 -8
  122. package/lib/serialization/FileMiddleware.js +17 -0
  123. package/lib/serialization/MapObjectSerializer.js +24 -8
  124. package/lib/serialization/NullPrototypeObjectSerializer.js +25 -8
  125. package/lib/serialization/ObjectMiddleware.js +23 -0
  126. package/lib/serialization/PlainObjectSerializer.js +23 -12
  127. package/lib/serialization/RegExpObjectSerializer.js +16 -5
  128. package/lib/serialization/SetObjectSerializer.js +21 -6
  129. package/lib/sharing/ShareRuntimeModule.js +1 -1
  130. package/lib/util/makeSerializable.js +7 -0
  131. package/lib/util/serialization.js +10 -0
  132. package/lib/web/JsonpChunkLoadingRuntimeModule.js +4 -1
  133. package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +5 -1
  134. package/package.json +3 -3
  135. package/schemas/plugins/SourceMapDevToolPlugin.check.js +1 -1
  136. package/schemas/plugins/SourceMapDevToolPlugin.json +4 -0
  137. package/types.d.ts +469 -149
package/README.md CHANGED
@@ -32,8 +32,8 @@
32
32
  <a href="https://github.com/webpack/webpack/graphs/contributors">
33
33
  <img src="https://img.shields.io/github/contributors/webpack/webpack.svg">
34
34
  </a>
35
- <a href="https://gitter.im/webpack/webpack">
36
- <img src="https://badges.gitter.im/webpack/webpack.svg">
35
+ <a href="https://github.com/webpack/webpack/discussions">
36
+ <img src="https://img.shields.io/github/discussions/webpack/webpack">
37
37
  </a>
38
38
  <a href="https://twitter.com/Webpack">
39
39
  <img src="https://img.shields.io/twitter/follow/Webpack?style=social">
@@ -10,6 +10,7 @@ const {
10
10
  JAVASCRIPT_MODULE_TYPE_DYNAMIC,
11
11
  JAVASCRIPT_MODULE_TYPE_ESM
12
12
  } = require("./ModuleTypeConstants");
13
+ const RuntimeGlobals = require("./RuntimeGlobals");
13
14
  const ConstDependency = require("./dependencies/ConstDependency");
14
15
 
15
16
  /** @typedef {import("./Compiler")} Compiler */
@@ -79,7 +80,7 @@ class CompatibilityPlugin {
79
80
  if (
80
81
  statement.type === "FunctionDeclaration" &&
81
82
  statement.id &&
82
- statement.id.name === "__webpack_require__"
83
+ statement.id.name === RuntimeGlobals.require
83
84
  ) {
84
85
  const newName = `__nested_webpack_require_${statement.range[0]}__`;
85
86
  parser.tagVariable(
@@ -98,7 +99,7 @@ class CompatibilityPlugin {
98
99
  }
99
100
  });
100
101
  parser.hooks.pattern
101
- .for("__webpack_require__")
102
+ .for(RuntimeGlobals.require)
102
103
  .tap(PLUGIN_NAME, pattern => {
103
104
  const newName = `__nested_webpack_require_${pattern.range[0]}__`;
104
105
  parser.tagVariable(pattern.name, nestedWebpackIdentifierTag, {
@@ -5024,13 +5024,13 @@ This prevents using hashes of each other and should be avoided.`);
5024
5024
  };
5025
5025
  const interceptModuleExecution = (__webpack_require__[
5026
5026
  RuntimeGlobals.interceptModuleExecution.replace(
5027
- "__webpack_require__.",
5027
+ `${RuntimeGlobals.require}.`,
5028
5028
  ""
5029
5029
  )
5030
5030
  ] = []);
5031
5031
  const moduleCache = (__webpack_require__[
5032
5032
  RuntimeGlobals.moduleCache.replace(
5033
- "__webpack_require__.",
5033
+ `${RuntimeGlobals.require}.`,
5034
5034
  ""
5035
5035
  )
5036
5036
  ] = {});
@@ -640,7 +640,7 @@ class ContextModule extends Module {
640
640
 
641
641
  getReturn(type, asyncModule) {
642
642
  if (type === 9) {
643
- return "__webpack_require__(id)";
643
+ return `${RuntimeGlobals.require}(id)`;
644
644
  }
645
645
  return `${RuntimeGlobals.createFakeNamespaceObject}(id, ${type}${
646
646
  asyncModule ? " | 16" : ""
@@ -799,7 +799,7 @@ module.exports = webpackAsyncContext;`;
799
799
  ? `${arrow ? "id =>" : "function(id)"} {
800
800
  ${this.getReturnModuleObjectSource(fakeMap)}
801
801
  }`
802
- : "__webpack_require__";
802
+ : RuntimeGlobals.require;
803
803
  return `var map = ${JSON.stringify(map, null, "\t")};
804
804
  ${this.getFakeMapInitStatement(fakeMap)}
805
805
 
@@ -850,7 +850,7 @@ module.exports = webpackAsyncContext;`;
850
850
  ? `${arrow ? "id =>" : "function(id)"} {
851
851
  ${this.getReturnModuleObjectSource(fakeMap, true)};
852
852
  }`
853
- : "__webpack_require__";
853
+ : RuntimeGlobals.require;
854
854
 
855
855
  return `var map = ${JSON.stringify(map, null, "\t")};
856
856
  ${this.getFakeMapInitStatement(fakeMap)}
@@ -463,7 +463,7 @@ class DefinePlugin {
463
463
  });
464
464
  parser.hooks.expression.for(key).tap(PLUGIN_NAME, expr => {
465
465
  addValueDependency(originalKey);
466
- const strCode = toCode(
466
+ let strCode = toCode(
467
467
  code,
468
468
  parser,
469
469
  compilation.valueCacheVersions,
@@ -473,6 +473,11 @@ class DefinePlugin {
473
473
  !parser.isAsiPosition(expr.range[0]),
474
474
  parser.destructuringAssignmentPropertiesFor(expr)
475
475
  );
476
+
477
+ if (parser.scope.inShorthand) {
478
+ strCode = parser.scope.inShorthand + ":" + strCode;
479
+ }
480
+
476
481
  if (WEBPACK_REQUIRE_FUNCTION_REGEXP.test(strCode)) {
477
482
  return toConstantDependency(parser, strCode, [
478
483
  RuntimeGlobals.require
@@ -564,7 +569,7 @@ class DefinePlugin {
564
569
  );
565
570
  parser.hooks.expression.for(key).tap(PLUGIN_NAME, expr => {
566
571
  addValueDependency(key);
567
- const strCode = stringifyObj(
572
+ let strCode = stringifyObj(
568
573
  obj,
569
574
  parser,
570
575
  compilation.valueCacheVersions,
@@ -575,6 +580,10 @@ class DefinePlugin {
575
580
  parser.destructuringAssignmentPropertiesFor(expr)
576
581
  );
577
582
 
583
+ if (parser.scope.inShorthand) {
584
+ strCode = parser.scope.inShorthand + ":" + strCode;
585
+ }
586
+
578
587
  if (WEBPACK_REQUIRE_FUNCTION_REGEXP.test(strCode)) {
579
588
  return toConstantDependency(parser, strCode, [
580
589
  RuntimeGlobals.require
@@ -10,6 +10,11 @@ const DllEntryDependency = require("./dependencies/DllEntryDependency");
10
10
  const EntryDependency = require("./dependencies/EntryDependency");
11
11
 
12
12
  class DllEntryPlugin {
13
+ /**
14
+ * @param {string} context context
15
+ * @param {string[]} entries entry names
16
+ * @param {TODO} options options
17
+ */
13
18
  constructor(context, entries, options) {
14
19
  this.context = context;
15
20
  this.entries = entries;
package/lib/DllModule.js CHANGED
@@ -89,7 +89,7 @@ class DllModule extends Module {
89
89
  const sources = new Map();
90
90
  sources.set(
91
91
  "javascript",
92
- new RawSource("module.exports = __webpack_require__;")
92
+ new RawSource(`module.exports = ${RuntimeGlobals.require};`)
93
93
  );
94
94
  return {
95
95
  sources,
@@ -48,7 +48,9 @@ class EvalSourceMapDevToolPlugin {
48
48
  options = inputOptions;
49
49
  }
50
50
  this.sourceMapComment =
51
- options.append || "//# sourceURL=[module]\n//# sourceMappingURL=[url]";
51
+ options.append && typeof options.append !== "function"
52
+ ? options.append
53
+ : "//# sourceURL=[module]\n//# sourceMappingURL=[url]";
52
54
  this.moduleFilenameTemplate =
53
55
  options.moduleFilenameTemplate ||
54
56
  "webpack://[namespace]/[resource-path]?[hash]";
@@ -306,8 +306,8 @@ class MainTemplate {
306
306
 
307
307
  Object.defineProperty(MainTemplate.prototype, "requireFn", {
308
308
  get: util.deprecate(
309
- () => "__webpack_require__",
310
- 'MainTemplate.requireFn is deprecated (use "__webpack_require__")',
309
+ () => RuntimeGlobals.require,
310
+ `MainTemplate.requireFn is deprecated (use "${RuntimeGlobals.require}")`,
311
311
  "DEP_WEBPACK_MAIN_TEMPLATE_REQUIRE_FN"
312
312
  )
313
313
  });
@@ -10,6 +10,10 @@ const PrefetchDependency = require("./dependencies/PrefetchDependency");
10
10
  /** @typedef {import("./Compiler")} Compiler */
11
11
 
12
12
  class PrefetchPlugin {
13
+ /**
14
+ * @param {string} context context or request if context is not set
15
+ * @param {string} [request] request
16
+ */
13
17
  constructor(context, request) {
14
18
  if (request) {
15
19
  this.context = context;
@@ -429,7 +429,7 @@ class RuntimeTemplate {
429
429
  );
430
430
  }
431
431
  runtimeRequirements.add(RuntimeGlobals.require);
432
- return `__webpack_require__(${this.moduleId({
432
+ return `${RuntimeGlobals.require}(${this.moduleId({
433
433
  module,
434
434
  chunkGraph,
435
435
  request,
@@ -625,7 +625,7 @@ class RuntimeTemplate {
625
625
  )})`;
626
626
  } else {
627
627
  runtimeRequirements.add(RuntimeGlobals.require);
628
- appending = `.then(__webpack_require__.bind(__webpack_require__, ${comment}${idExpr}))`;
628
+ appending = `.then(${RuntimeGlobals.require}.bind(${RuntimeGlobals.require}, ${comment}${idExpr}))`;
629
629
  }
630
630
  break;
631
631
  case "dynamic":
@@ -651,7 +651,7 @@ class RuntimeTemplate {
651
651
  )})`;
652
652
  } else {
653
653
  runtimeRequirements.add(RuntimeGlobals.require);
654
- appending = `.then(__webpack_require__.bind(__webpack_require__, ${comment}${idExpr}))`;
654
+ appending = `.then(${RuntimeGlobals.require}.bind(${RuntimeGlobals.require}, ${comment}${idExpr}))`;
655
655
  }
656
656
  appending += `.then(${this.returningFunction(
657
657
  `${RuntimeGlobals.createFakeNamespaceObject}(m, ${fakeType})`,
@@ -666,7 +666,7 @@ class RuntimeTemplate {
666
666
  `${header}return ${returnExpression};`
667
667
  )})`;
668
668
  } else {
669
- appending = `.then(${RuntimeGlobals.createFakeNamespaceObject}.bind(__webpack_require__, ${comment}${idExpr}, ${fakeType}))`;
669
+ appending = `.then(${RuntimeGlobals.createFakeNamespaceObject}.bind(${RuntimeGlobals.require}, ${comment}${idExpr}, ${fakeType}))`;
670
670
  }
671
671
  }
672
672
  break;
@@ -773,7 +773,7 @@ class RuntimeTemplate {
773
773
  originModule.buildMeta.strictHarmonyModule
774
774
  );
775
775
  runtimeRequirements.add(RuntimeGlobals.require);
776
- const importContent = `/* harmony import */ ${optDeclaration}${importVar} = __webpack_require__(${moduleId});\n`;
776
+ const importContent = `/* harmony import */ ${optDeclaration}${importVar} = ${RuntimeGlobals.require}(${moduleId});\n`;
777
777
 
778
778
  if (exportsType === "dynamic") {
779
779
  runtimeRequirements.add(RuntimeGlobals.compatGetDefaultExport);
@@ -5,11 +5,23 @@
5
5
 
6
6
  "use strict";
7
7
 
8
+ /** @typedef {import("./ModuleFactory").ModuleFactoryCreateData} ModuleFactoryCreateData */
9
+ /** @typedef {import("./ModuleFactory").ModuleFactoryResult} ModuleFactoryResult */
10
+ /** @typedef {import("./ModuleGraph")} ModuleGraph */
11
+
8
12
  class SelfModuleFactory {
13
+ /**
14
+ * @param {ModuleGraph} moduleGraph module graph
15
+ */
9
16
  constructor(moduleGraph) {
10
17
  this.moduleGraph = moduleGraph;
11
18
  }
12
19
 
20
+ /**
21
+ * @param {ModuleFactoryCreateData} data data object
22
+ * @param {function(Error=, ModuleFactoryResult=): void} callback callback
23
+ * @returns {void}
24
+ */
13
25
  create(data, callback) {
14
26
  const module = this.moduleGraph.getParentModule(data.dependencies[0]);
15
27
  callback(null, {
@@ -23,6 +23,7 @@ const { makePathsAbsolute } = require("./util/identifier");
23
23
  /** @typedef {import("./CacheFacade").ItemCacheFacade} ItemCacheFacade */
24
24
  /** @typedef {import("./Chunk")} Chunk */
25
25
  /** @typedef {import("./Compilation").AssetInfo} AssetInfo */
26
+ /** @typedef {import("./Compilation").PathData} PathData */
26
27
  /** @typedef {import("./Compiler")} Compiler */
27
28
  /** @typedef {import("./Module")} Module */
28
29
  /** @typedef {import("./NormalModule").SourceMap} SourceMap */
@@ -139,7 +140,7 @@ class SourceMapDevToolPlugin {
139
140
 
140
141
  /** @type {string | false} */
141
142
  this.sourceMapFilename = options.filename;
142
- /** @type {string | false} */
143
+ /** @type {string | false | (function(PathData, AssetInfo=): string)}} */
143
144
  this.sourceMappingURLComment =
144
145
  options.append === false
145
146
  ? false
@@ -447,13 +448,14 @@ class SourceMapDevToolPlugin {
447
448
  );
448
449
  }
449
450
 
450
- /** @type {string | false} */
451
+ /** @type {string | false | (function(PathData, AssetInfo=): string)} */
451
452
  let currentSourceMappingURLComment = sourceMappingURLComment;
452
453
  let cssExtensionDetected =
453
454
  CSS_EXTENSION_DETECT_REGEXP.test(file);
454
455
  resetRegexpState(CSS_EXTENSION_DETECT_REGEXP);
455
456
  if (
456
457
  currentSourceMappingURLComment !== false &&
458
+ typeof currentSourceMappingURLComment !== "function" &&
457
459
  cssExtensionDetected
458
460
  ) {
459
461
  currentSourceMappingURLComment =
@@ -534,6 +536,11 @@ class SourceMapDevToolPlugin {
534
536
  "SourceMapDevToolPlugin: append can't be false when no filename is provided"
535
537
  );
536
538
  }
539
+ if (typeof currentSourceMappingURLComment === "function") {
540
+ throw new Error(
541
+ "SourceMapDevToolPlugin: append can't be a function when no filename is provided"
542
+ );
543
+ }
537
544
  /**
538
545
  * Add source map as data url to asset
539
546
  */
package/lib/Template.js CHANGED
@@ -7,6 +7,7 @@
7
7
 
8
8
  const { ConcatSource, PrefixSource } = require("webpack-sources");
9
9
  const { WEBPACK_MODULE_TYPE_RUNTIME } = require("./ModuleTypeConstants");
10
+ const RuntimeGlobals = require("./RuntimeGlobals");
10
11
 
11
12
  /** @typedef {import("webpack-sources").Source} Source */
12
13
  /** @typedef {import("../declarations/WebpackOptions").Output} OutputOptions */
@@ -405,7 +406,7 @@ class Template {
405
406
  return new PrefixSource(
406
407
  "/******/ ",
407
408
  new ConcatSource(
408
- "function(__webpack_require__) { // webpackRuntimeModules\n",
409
+ `function(${RuntimeGlobals.require}) { // webpackRuntimeModules\n`,
409
410
  this.renderRuntimeModules(runtimeModules, renderContext),
410
411
  "}\n"
411
412
  )
@@ -23,7 +23,7 @@ const inputRx = /^(?:((?:[A-Z]:)?[/\\].*?))?(?::(.+?))?$/i;
23
23
  */
24
24
 
25
25
  /**
26
- * @param {string} input input string
26
+ * @param {string | null | undefined} input input string
27
27
  * @param {string} context the context directory
28
28
  * @returns {BrowserslistHandlerConfig} config
29
29
  */
@@ -47,7 +47,7 @@ const parse = (input, context) => {
47
47
  };
48
48
 
49
49
  /**
50
- * @param {string} input input string
50
+ * @param {string | null | undefined} input input string
51
51
  * @param {string} context the context directory
52
52
  * @returns {string[] | undefined} selected browsers
53
53
  */
@@ -66,7 +66,7 @@ const load = (input, context) => {
66
66
  })
67
67
  : browserslist.loadConfig({ path: context, env });
68
68
 
69
- if (!config) return null;
69
+ if (!config) return;
70
70
  return browserslist(config);
71
71
  };
72
72