webpack 5.102.0 → 5.103.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.
Files changed (146) hide show
  1. package/README.md +121 -134
  2. package/lib/ChunkGraph.js +2 -2
  3. package/lib/CodeGenerationResults.js +1 -1
  4. package/lib/CompatibilityPlugin.js +25 -2
  5. package/lib/Compilation.js +30 -13
  6. package/lib/ConcatenationScope.js +0 -15
  7. package/lib/ContextModule.js +3 -1
  8. package/lib/CssModule.js +6 -1
  9. package/lib/DefinePlugin.js +12 -12
  10. package/lib/Dependency.js +8 -1
  11. package/lib/DependencyTemplate.js +1 -0
  12. package/lib/DependencyTemplates.js +1 -1
  13. package/lib/DotenvPlugin.js +457 -0
  14. package/lib/EnvironmentPlugin.js +19 -16
  15. package/lib/EvalSourceMapDevToolPlugin.js +16 -0
  16. package/lib/ExportsInfo.js +6 -2
  17. package/lib/ExternalModule.js +20 -28
  18. package/lib/ExternalModuleFactoryPlugin.js +10 -8
  19. package/lib/ExternalsPlugin.js +2 -1
  20. package/lib/FileSystemInfo.js +9 -12
  21. package/lib/ManifestPlugin.js +235 -0
  22. package/lib/Module.js +3 -0
  23. package/lib/ModuleFilenameHelpers.js +1 -1
  24. package/lib/ModuleGraph.js +2 -1
  25. package/lib/ModuleSourceTypesConstants.js +0 -6
  26. package/lib/MultiCompiler.js +1 -1
  27. package/lib/NodeStuffPlugin.js +419 -121
  28. package/lib/NormalModule.js +18 -17
  29. package/lib/NormalModuleFactory.js +75 -4
  30. package/lib/RuntimeGlobals.js +22 -4
  31. package/lib/RuntimePlugin.js +27 -6
  32. package/lib/RuntimeTemplate.js +125 -57
  33. package/lib/SourceMapDevToolPlugin.js +26 -8
  34. package/lib/WebpackOptionsApply.js +33 -9
  35. package/lib/asset/AssetBytesGenerator.js +2 -1
  36. package/lib/asset/AssetGenerator.js +3 -5
  37. package/lib/asset/AssetSourceGenerator.js +1 -1
  38. package/lib/cache/getLazyHashedEtag.js +1 -1
  39. package/lib/config/browserslistTargetHandler.js +82 -76
  40. package/lib/config/defaults.js +105 -20
  41. package/lib/config/normalization.js +2 -1
  42. package/lib/config/target.js +7 -1
  43. package/lib/css/CssGenerator.js +283 -57
  44. package/lib/css/CssLoadingRuntimeModule.js +2 -0
  45. package/lib/css/CssMergeStyleSheetsRuntimeModule.js +56 -0
  46. package/lib/css/CssModulesPlugin.js +86 -40
  47. package/lib/css/CssParser.js +1174 -667
  48. package/lib/css/walkCssTokens.js +98 -1
  49. package/lib/dependencies/CommonJsImportsParserPlugin.js +0 -9
  50. package/lib/dependencies/CommonJsPlugin.js +12 -0
  51. package/lib/dependencies/ContextElementDependency.js +2 -2
  52. package/lib/dependencies/CssIcssExportDependency.js +247 -8
  53. package/lib/dependencies/CssIcssFromIdentifierDependency.js +124 -0
  54. package/lib/dependencies/CssIcssGlobalIdentifierDependency.js +48 -0
  55. package/lib/dependencies/CssIcssImportDependency.js +60 -54
  56. package/lib/dependencies/CssIcssLocalIdentifierDependency.js +61 -0
  57. package/lib/dependencies/{CssSelfLocalIdentifierDependency.js → CssIcssSelfLocalIdentifierDependency.js} +88 -10
  58. package/lib/dependencies/CssIcssSymbolDependency.js +31 -29
  59. package/lib/dependencies/CssImportDependency.js +15 -5
  60. package/lib/dependencies/ExternalModuleInitFragment.js +1 -1
  61. package/lib/dependencies/ExternalModuleInitFragmentDependency.js +95 -0
  62. package/lib/dependencies/HarmonyAcceptDependency.js +6 -1
  63. package/lib/dependencies/HarmonyAcceptImportDependency.js +2 -1
  64. package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +12 -1
  65. package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +32 -21
  66. package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +12 -8
  67. package/lib/dependencies/HarmonyImportDependency.js +27 -28
  68. package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +28 -69
  69. package/lib/dependencies/HarmonyImportSideEffectDependency.js +4 -3
  70. package/lib/dependencies/HarmonyImportSpecifierDependency.js +10 -8
  71. package/lib/dependencies/ImportContextDependency.js +13 -0
  72. package/lib/dependencies/ImportDependency.js +10 -4
  73. package/lib/dependencies/ImportEagerDependency.js +6 -3
  74. package/lib/dependencies/ImportMetaPlugin.js +98 -10
  75. package/lib/dependencies/ImportParserPlugin.js +19 -21
  76. package/lib/dependencies/ImportPhase.js +121 -0
  77. package/lib/dependencies/ImportWeakDependency.js +6 -3
  78. package/lib/dependencies/ModuleDependency.js +5 -1
  79. package/lib/dependencies/ModuleHotAcceptDependency.js +1 -1
  80. package/lib/dependencies/WorkerPlugin.js +1 -3
  81. package/lib/esm/ExportWebpackRequireRuntimeModule.js +1 -8
  82. package/lib/hmr/LazyCompilationPlugin.js +1 -0
  83. package/lib/ids/HashedModuleIdsPlugin.js +5 -7
  84. package/lib/ids/IdHelpers.js +5 -2
  85. package/lib/index.js +6 -0
  86. package/lib/javascript/ChunkHelpers.js +16 -5
  87. package/lib/javascript/JavascriptGenerator.js +101 -101
  88. package/lib/javascript/JavascriptModulesPlugin.js +25 -16
  89. package/lib/javascript/JavascriptParser.js +143 -39
  90. package/lib/json/JsonParser.js +7 -1
  91. package/lib/library/ModuleLibraryPlugin.js +0 -10
  92. package/lib/library/SystemLibraryPlugin.js +19 -5
  93. package/lib/library/UmdLibraryPlugin.js +1 -1
  94. package/lib/node/NodeTargetPlugin.js +9 -1
  95. package/lib/node/ReadFileCompileWasmPlugin.js +0 -2
  96. package/lib/optimize/ConcatenatedModule.js +161 -135
  97. package/lib/optimize/RealContentHashPlugin.js +5 -3
  98. package/lib/runtime/AsyncModuleRuntimeModule.js +28 -18
  99. package/lib/runtime/AutoPublicPathRuntimeModule.js +8 -3
  100. package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +89 -55
  101. package/lib/serialization/FileMiddleware.js +1 -1
  102. package/lib/serialization/ObjectMiddleware.js +1 -1
  103. package/lib/stats/DefaultStatsFactoryPlugin.js +1 -1
  104. package/lib/util/Hash.js +35 -5
  105. package/lib/util/comparators.js +4 -3
  106. package/lib/util/create-schema-validation.js +1 -1
  107. package/lib/util/createHash.js +85 -15
  108. package/lib/util/hash/BatchedHash.js +47 -8
  109. package/lib/util/hash/wasm-hash.js +53 -13
  110. package/lib/util/internalSerializables.js +4 -4
  111. package/lib/util/jsonParseEvenBetterErrors.js +10 -0
  112. package/lib/wasm/EnableWasmLoadingPlugin.js +10 -4
  113. package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +8 -5
  114. package/lib/wasm-async/AsyncWebAssemblyParser.js +0 -9
  115. package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +8 -4
  116. package/lib/wasm-sync/WebAssemblyParser.js +0 -9
  117. package/lib/web/FetchCompileWasmPlugin.js +0 -2
  118. package/lib/web/JsonpChunkLoadingRuntimeModule.js +1 -1
  119. package/lib/webpack.js +85 -82
  120. package/module.d.ts +5 -0
  121. package/package.json +28 -26
  122. package/schemas/WebpackOptions.check.js +1 -1
  123. package/schemas/WebpackOptions.json +110 -15
  124. package/schemas/plugins/{HashedModuleIdsPlugin.check.d.ts → ManifestPlugin.check.d.ts} +1 -1
  125. package/schemas/plugins/ManifestPlugin.check.js +6 -0
  126. package/schemas/plugins/ManifestPlugin.json +98 -0
  127. package/schemas/plugins/SourceMapDevToolPlugin.check.js +1 -1
  128. package/schemas/plugins/SourceMapDevToolPlugin.json +16 -3
  129. package/schemas/plugins/container/ContainerReferencePlugin.check.js +1 -1
  130. package/schemas/plugins/container/ContainerReferencePlugin.json +4 -1
  131. package/schemas/plugins/container/ExternalsType.check.js +1 -1
  132. package/schemas/plugins/container/ModuleFederationPlugin.check.js +1 -1
  133. package/schemas/plugins/container/ModuleFederationPlugin.json +4 -1
  134. package/schemas/plugins/css/CssAutoParserOptions.check.js +1 -1
  135. package/schemas/plugins/css/CssGlobalGeneratorOptions.check.js +1 -1
  136. package/schemas/plugins/css/CssGlobalParserOptions.check.js +1 -1
  137. package/schemas/plugins/css/CssModuleGeneratorOptions.check.js +1 -1
  138. package/schemas/plugins/css/CssModuleParserOptions.check.js +1 -1
  139. package/schemas/plugins/css/CssParserOptions.check.js +1 -1
  140. package/schemas/plugins/ids/HashedModuleIdsPlugin.check.d.ts +7 -0
  141. package/schemas/plugins/ids/HashedModuleIdsPlugin.check.js +6 -0
  142. package/schemas/plugins/{HashedModuleIdsPlugin.json → ids/HashedModuleIdsPlugin.json} +15 -2
  143. package/schemas/plugins/json/JsonModulesPluginParser.check.js +1 -1
  144. package/types.d.ts +788 -127
  145. package/lib/dependencies/CssLocalIdentifierDependency.js +0 -252
  146. package/schemas/plugins/HashedModuleIdsPlugin.check.js +0 -6
@@ -202,6 +202,7 @@ const {
202
202
  * & { performance: NonNullable<WebpackOptionsNormalized["performance"]> }
203
203
  * & { recordsInputPath: NonNullable<WebpackOptionsNormalized["recordsInputPath"]> }
204
204
  * & { recordsOutputPath: NonNullable<WebpackOptionsNormalized["recordsOutputPath"]>
205
+ * & { dotenv: NonNullable<WebpackOptionsNormalized["dotenv"]> }
205
206
  * }} WebpackOptionsNormalizedWithDefaults
206
207
  */
207
208
 
@@ -410,7 +411,10 @@ const applyWebpackOptionsDefaults = (options, compilerIndex) => {
410
411
 
411
412
  applyExternalsPresetsDefaults(options.externalsPresets, {
412
413
  targetProperties,
413
- buildHttp: Boolean(options.experiments.buildHttp)
414
+ buildHttp: Boolean(options.experiments.buildHttp),
415
+ outputModule:
416
+ /** @type {NonNullable<WebpackOptionsNormalized["output"]["module"]>} */
417
+ (options.output.module)
414
418
  });
415
419
 
416
420
  applyLoaderDefaults(
@@ -513,6 +517,7 @@ const applyExperimentsDefaults = (
513
517
  ) => {
514
518
  D(experiments, "futureDefaults", false);
515
519
  D(experiments, "backCompat", !experiments.futureDefaults);
520
+ // TODO do we need sync web assembly in webpack@6?
516
521
  D(experiments, "syncWebAssembly", false);
517
522
  D(experiments, "asyncWebAssembly", experiments.futureDefaults);
518
523
  D(experiments, "outputModule", false);
@@ -1042,6 +1047,35 @@ const applyModuleDefaults = (
1042
1047
  type: CSS_MODULE_TYPE,
1043
1048
  resolve
1044
1049
  });
1050
+ // For CSS modules, i.e. `.class { composes: className from "./style.css" }`
1051
+ // We inherit for such constructions
1052
+ rules.push({
1053
+ dependency: /css-import-local-module/,
1054
+ type: CSS_MODULE_TYPE_MODULE,
1055
+ resolve
1056
+ });
1057
+ rules.push({
1058
+ dependency: /css-import-global-module/,
1059
+ type: CSS_MODULE_TYPE_GLOBAL,
1060
+ resolve
1061
+ });
1062
+
1063
+ rules.push(
1064
+ {
1065
+ with: { type: "css" },
1066
+ parser: {
1067
+ exportType: "css-style-sheet"
1068
+ },
1069
+ resolve
1070
+ },
1071
+ {
1072
+ assert: { type: "css" },
1073
+ parser: {
1074
+ exportType: "css-style-sheet"
1075
+ },
1076
+ resolve
1077
+ }
1078
+ );
1045
1079
  }
1046
1080
  rules.push(
1047
1081
  {
@@ -1058,11 +1092,13 @@ const applyModuleDefaults = (
1058
1092
  },
1059
1093
  {
1060
1094
  with: { type: JSON_MODULE_TYPE },
1061
- type: JSON_MODULE_TYPE
1095
+ type: JSON_MODULE_TYPE,
1096
+ parser: { namedExports: false }
1062
1097
  },
1063
1098
  {
1064
1099
  assert: { type: JSON_MODULE_TYPE },
1065
- type: JSON_MODULE_TYPE
1100
+ type: JSON_MODULE_TYPE,
1101
+ parser: { namedExports: false }
1066
1102
  },
1067
1103
  {
1068
1104
  with: { type: "text" },
@@ -1220,6 +1256,13 @@ const applyOutputDefaults = (
1220
1256
  /** @type {boolean | undefined} */ (tp.nodePrefixForCoreModules)
1221
1257
  )
1222
1258
  );
1259
+ F(
1260
+ environment,
1261
+ "importMetaDirnameAndFilename",
1262
+ () =>
1263
+ // No optimistic, because it is new
1264
+ tp && /** @type {boolean | undefined} */ (tp.importMetaDirnameAndFilename)
1265
+ );
1223
1266
  F(
1224
1267
  environment,
1225
1268
  "templateLiteral",
@@ -1301,6 +1344,8 @@ const applyOutputDefaults = (
1301
1344
  if (tp) {
1302
1345
  if (tp.global) return "global";
1303
1346
  if (tp.globalThis) return "globalThis";
1347
+ // For universal target (i.e. code can be run in browser/node/worker etc.)
1348
+ if (tp.web === null && tp.node === null && tp.module) return "globalThis";
1304
1349
  }
1305
1350
  return "self";
1306
1351
  });
@@ -1326,8 +1371,13 @@ const applyOutputDefaults = (
1326
1371
  if (tp.importScripts) return "array-push";
1327
1372
  throw new Error(
1328
1373
  "For the selected environment is no default script chunk format available:\n" +
1329
- "JSONP Array push can be chosen when 'document' or 'importScripts' is available.\n" +
1330
- `CommonJs exports can be chosen when 'require' or node builtins are available.\n${
1374
+ `${
1375
+ tp.module
1376
+ ? "Module ('module') can be chosen when ES modules are available (please set 'experiments.outputModule' and 'output.module' to `true`)"
1377
+ : ""
1378
+ }\n` +
1379
+ "JSONP Array push ('array-push') can be chosen when 'document' or 'importScripts' is available.\n" +
1380
+ `CommonJs exports ('commonjs') can be chosen when 'require' or node builtins are available.\n${
1331
1381
  helpMessage
1332
1382
  }`
1333
1383
  );
@@ -1398,7 +1448,6 @@ const applyOutputDefaults = (
1398
1448
  if (tp.nodeBuiltins) return "async-node";
1399
1449
  if (
1400
1450
  (tp.nodeBuiltins === null || tp.fetchWasm === null) &&
1401
- asyncWebAssembly &&
1402
1451
  output.module &&
1403
1452
  environment.dynamicImport
1404
1453
  ) {
@@ -1522,35 +1571,47 @@ const applyOutputDefaults = (
1522
1571
  * @param {object} options options
1523
1572
  * @param {TargetProperties | false} options.targetProperties target properties
1524
1573
  * @param {boolean} options.buildHttp buildHttp experiment enabled
1574
+ * @param {boolean} options.outputModule is output type is module
1525
1575
  * @returns {void}
1526
1576
  */
1527
1577
  const applyExternalsPresetsDefaults = (
1528
1578
  externalsPresets,
1529
- { targetProperties, buildHttp }
1579
+ { targetProperties, buildHttp, outputModule }
1530
1580
  ) => {
1581
+ /**
1582
+ * @param {keyof TargetProperties} key a key
1583
+ * @returns {boolean} true when target is universal, otherwise false
1584
+ */
1585
+ const isUniversal = (key) =>
1586
+ Boolean(outputModule && targetProperties && targetProperties[key] === null);
1587
+
1531
1588
  D(
1532
1589
  externalsPresets,
1533
1590
  "web",
1534
1591
  /** @type {boolean | undefined} */
1535
- (!buildHttp && targetProperties && targetProperties.web)
1592
+ (
1593
+ !buildHttp &&
1594
+ targetProperties &&
1595
+ (targetProperties.web || isUniversal("node"))
1596
+ )
1536
1597
  );
1537
1598
  D(
1538
1599
  externalsPresets,
1539
1600
  "node",
1540
1601
  /** @type {boolean | undefined} */
1541
- (targetProperties && targetProperties.node)
1602
+ (targetProperties && (targetProperties.node || isUniversal("node")))
1542
1603
  );
1543
1604
  D(
1544
1605
  externalsPresets,
1545
1606
  "nwjs",
1546
1607
  /** @type {boolean | undefined} */
1547
- (targetProperties && targetProperties.nwjs)
1608
+ (targetProperties && (targetProperties.nwjs || isUniversal("nwjs")))
1548
1609
  );
1549
1610
  D(
1550
1611
  externalsPresets,
1551
1612
  "electron",
1552
1613
  /** @type {boolean | undefined} */
1553
- (targetProperties && targetProperties.electron)
1614
+ ((targetProperties && targetProperties.electron) || isUniversal("electron"))
1554
1615
  );
1555
1616
  D(
1556
1617
  externalsPresets,
@@ -1559,7 +1620,7 @@ const applyExternalsPresetsDefaults = (
1559
1620
  (
1560
1621
  targetProperties &&
1561
1622
  targetProperties.electron &&
1562
- targetProperties.electronMain
1623
+ (targetProperties.electronMain || isUniversal("electronMain"))
1563
1624
  )
1564
1625
  );
1565
1626
  D(
@@ -1569,7 +1630,7 @@ const applyExternalsPresetsDefaults = (
1569
1630
  (
1570
1631
  targetProperties &&
1571
1632
  targetProperties.electron &&
1572
- targetProperties.electronPreload
1633
+ (targetProperties.electronPreload || isUniversal("electronPreload"))
1573
1634
  )
1574
1635
  );
1575
1636
  D(
@@ -1579,7 +1640,7 @@ const applyExternalsPresetsDefaults = (
1579
1640
  (
1580
1641
  targetProperties &&
1581
1642
  targetProperties.electron &&
1582
- targetProperties.electronRenderer
1643
+ (targetProperties.electronRenderer || isUniversal("electronRenderer"))
1583
1644
  )
1584
1645
  );
1585
1646
  };
@@ -1624,15 +1685,28 @@ const applyNodeDefaults = (
1624
1685
 
1625
1686
  F(node, "global", () => {
1626
1687
  if (targetProperties && targetProperties.global) return false;
1627
- // TODO webpack 6 should always default to false
1688
+ // We use `warm` because overriding `global` with `globalThis` (or a polyfill) is sometimes safe (global.URL), sometimes unsafe (global.process), but we need to warn about it
1628
1689
  return futureDefaults ? "warn" : true;
1629
1690
  });
1630
1691
 
1631
1692
  const handlerForNames = () => {
1632
- if (targetProperties && targetProperties.node) {
1633
- return outputModule ? "node-module" : "eval-only";
1693
+ // TODO webpack@6 remove `node-module` in favor of `eval-only`
1694
+ if (targetProperties) {
1695
+ if (targetProperties.node) {
1696
+ return "eval-only";
1697
+ }
1698
+
1699
+ // For the "universal" target we only evaluate these values
1700
+ if (
1701
+ outputModule &&
1702
+ targetProperties.node === null &&
1703
+ targetProperties.web === null
1704
+ ) {
1705
+ return "eval-only";
1706
+ }
1634
1707
  }
1635
- // TODO webpack 6 should always default to false
1708
+
1709
+ // TODO webpack@6 should we use `warn-even-only`?
1636
1710
  return futureDefaults ? "warn-mock" : "mock";
1637
1711
  };
1638
1712
 
@@ -1839,8 +1913,8 @@ const getResolveDefaults = ({
1839
1913
  styleConditions.push(mode === "development" ? "development" : "production");
1840
1914
  styleConditions.push("style");
1841
1915
 
1842
- /** @type {NonNullable<ResolveOptions["byDependency"]>} */
1843
- (resolveOptions.byDependency)["css-import"] = {
1916
+ /** @type {ResolveOptions} */
1917
+ const cssResolveOptions = {
1844
1918
  // We avoid using any main files because we have to be consistent with CSS `@import`
1845
1919
  // and CSS `@import` does not handle `main` files in directories,
1846
1920
  // you should always specify the full URL for styles
@@ -1850,6 +1924,17 @@ const getResolveDefaults = ({
1850
1924
  extensions: [".css"],
1851
1925
  preferRelative: true
1852
1926
  };
1927
+
1928
+ /** @type {NonNullable<ResolveOptions["byDependency"]>} */
1929
+ (resolveOptions.byDependency)["css-import"] = cssResolveOptions;
1930
+ // For CSS modules, i.e. `.class { composes: className from "./style.css" }`
1931
+ // We inherit for such constructions
1932
+ /** @type {NonNullable<ResolveOptions["byDependency"]>} */
1933
+ (resolveOptions.byDependency)["css-import-local-module"] =
1934
+ cssResolveOptions;
1935
+ /** @type {NonNullable<ResolveOptions["byDependency"]>} */
1936
+ (resolveOptions.byDependency)["css-import-global-module"] =
1937
+ cssResolveOptions;
1853
1938
  }
1854
1939
 
1855
1940
  return resolveOptions;
@@ -178,6 +178,7 @@ const getNormalizedWebpackOptions = (config) => ({
178
178
  return { ...devServer };
179
179
  }),
180
180
  devtool: config.devtool,
181
+ dotenv: config.dotenv,
181
182
  entry:
182
183
  config.entry === undefined
183
184
  ? { main: {} }
@@ -241,6 +242,7 @@ const getNormalizedWebpackOptions = (config) => ({
241
242
  unsafeCache: module.unsafeCache,
242
243
  parser: keyedNestedConfig(module.parser, cloneObject, {
243
244
  javascript: (parserOptions) => ({
245
+ // TODO webpack 6 remove from `ModuleOptions`, keep only `*ByModuleType`
244
246
  unknownContextRequest: module.unknownContextRequest,
245
247
  unknownContextRegExp: module.unknownContextRegExp,
246
248
  unknownContextRecursive: module.unknownContextRecursive,
@@ -252,7 +254,6 @@ const getNormalizedWebpackOptions = (config) => ({
252
254
  wrappedContextRegExp: module.wrappedContextRegExp,
253
255
  wrappedContextRecursive: module.wrappedContextRecursive,
254
256
  wrappedContextCritical: module.wrappedContextCritical,
255
- // TODO webpack 6 remove
256
257
  strictExportPresence: module.strictExportPresence,
257
258
  strictThisContextOnImports: module.strictThisContextOnImports,
258
259
  ...parserOptions
@@ -16,7 +16,7 @@ const getBrowserslistTargetHandler = memoize(() =>
16
16
  * @returns {string} default target
17
17
  */
18
18
  const getDefaultTarget = (context) => {
19
- const browsers = getBrowserslistTargetHandler().load(null, context);
19
+ const browsers = getBrowserslistTargetHandler().load(undefined, context);
20
20
  return browsers ? "browserslist" : "web";
21
21
  };
22
22
 
@@ -42,6 +42,7 @@ const getDefaultTarget = (context) => {
42
42
  * @property {boolean | null} require has require function available
43
43
  * @property {boolean | null} nodeBuiltins has node.js built-in modules available
44
44
  * @property {boolean | null} nodePrefixForCoreModules node.js allows to use `node:` prefix for core modules
45
+ * @property {boolean | null} importMetaDirnameAndFilename node.js allows to use `import.meta.dirname` and `import.meta.filename`
45
46
  * @property {boolean | null} document has document available (allows script tags)
46
47
  * @property {boolean | null} importScripts has importScripts available
47
48
  * @property {boolean | null} importScriptsInWorker has importScripts available when creating a worker
@@ -178,6 +179,9 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
178
179
  nodeBuiltins: true,
179
180
  // v16.0.0, v14.18.0
180
181
  nodePrefixForCoreModules: Number(major) < 15 ? v(14, 18) : v(16),
182
+ // Added in: v21.2.0, v20.11.0, but Node.js will output experimental warning, we don't want it
183
+ // v24.0.0, v22.16.0 - This property is no longer experimental.
184
+ importMetaDirnameAndFilename: v(22, 16),
181
185
  global: true,
182
186
  document: false,
183
187
  fetchWasm: false,
@@ -223,6 +227,8 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
223
227
  // 15.0.0 - Node.js v16.5
224
228
  // 14.0.0 - Mode.js v14.17, but prefixes only since v14.18
225
229
  nodePrefixForCoreModules: v(15),
230
+ // 37.0.0 - Node.js v22.16
231
+ importMetaDirnameAndFilename: v(37),
226
232
 
227
233
  require: true,
228
234
  document: context === "renderer",