webpack 5.106.2 → 5.107.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 (220) hide show
  1. package/README.md +2 -2
  2. package/lib/APIPlugin.js +1 -1
  3. package/lib/Cache.js +3 -6
  4. package/lib/CompatibilityPlugin.js +8 -7
  5. package/lib/Compilation.js +34 -26
  6. package/lib/Compiler.js +4 -13
  7. package/lib/ContextModule.js +2 -2
  8. package/lib/DefinePlugin.js +2 -2
  9. package/lib/Dependency.js +22 -1
  10. package/lib/DependencyTemplate.js +2 -1
  11. package/lib/EnvironmentPlugin.js +1 -1
  12. package/lib/EvalSourceMapDevToolPlugin.js +8 -9
  13. package/lib/ExternalModule.js +76 -15
  14. package/lib/ExternalModuleFactoryPlugin.js +5 -0
  15. package/lib/FileSystemInfo.js +187 -72
  16. package/lib/Generator.js +3 -3
  17. package/lib/HotModuleReplacementPlugin.js +26 -8
  18. package/lib/IgnorePlugin.js +2 -1
  19. package/lib/Module.js +19 -18
  20. package/lib/ModuleFactory.js +1 -1
  21. package/lib/ModuleSourceTypeConstants.js +31 -1
  22. package/lib/ModuleTypeConstants.js +12 -3
  23. package/lib/MultiCompiler.js +2 -2
  24. package/lib/NodeStuffPlugin.js +1 -1
  25. package/lib/NormalModule.js +13 -31
  26. package/lib/NormalModuleFactory.js +10 -2
  27. package/lib/Parser.js +1 -1
  28. package/lib/ProgressPlugin.js +129 -56
  29. package/lib/RuntimeGlobals.js +5 -5
  30. package/lib/RuntimeModule.js +9 -7
  31. package/lib/RuntimePlugin.js +11 -0
  32. package/lib/WarnCaseSensitiveModulesPlugin.js +70 -2
  33. package/lib/WarnDeprecatedOptionPlugin.js +1 -1
  34. package/lib/WarnNoModeSetPlugin.js +16 -1
  35. package/lib/Watching.js +2 -3
  36. package/lib/WebpackError.js +3 -77
  37. package/lib/WebpackIsIncludedPlugin.js +1 -1
  38. package/lib/WebpackOptionsApply.js +13 -1
  39. package/lib/asset/AssetBytesGenerator.js +6 -2
  40. package/lib/asset/AssetGenerator.js +22 -8
  41. package/lib/asset/AssetModulesPlugin.js +3 -1
  42. package/lib/asset/AssetSourceGenerator.js +6 -2
  43. package/lib/buildChunkGraph.js +4 -6
  44. package/lib/cache/PackFileCacheStrategy.js +4 -4
  45. package/lib/cli.js +3 -1
  46. package/lib/config/defaults.js +197 -10
  47. package/lib/config/normalization.js +3 -1
  48. package/lib/css/CssGenerator.js +320 -105
  49. package/lib/css/CssInjectStyleRuntimeModule.js +44 -42
  50. package/lib/css/CssLoadingRuntimeModule.js +22 -4
  51. package/lib/{CssModule.js → css/CssModule.js} +15 -15
  52. package/lib/css/CssModulesPlugin.js +166 -86
  53. package/lib/css/CssParser.js +566 -269
  54. package/lib/css/walkCssTokens.js +148 -2
  55. package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +1 -1
  56. package/lib/dependencies/CommonJsDependencyHelpers.js +63 -0
  57. package/lib/dependencies/CommonJsExportRequireDependency.js +54 -10
  58. package/lib/dependencies/CommonJsExportsParserPlugin.js +1 -1
  59. package/lib/dependencies/CommonJsFullRequireDependency.js +32 -9
  60. package/lib/dependencies/CommonJsImportsParserPlugin.js +4 -3
  61. package/lib/dependencies/CommonJsRequireDependency.js +67 -4
  62. package/lib/dependencies/ContextDependency.js +1 -1
  63. package/lib/dependencies/ContextDependencyHelpers.js +1 -1
  64. package/lib/dependencies/CreateRequireParserPlugin.js +1 -1
  65. package/lib/dependencies/CriticalDependencyWarning.js +1 -1
  66. package/lib/dependencies/CssIcssExportDependency.js +332 -67
  67. package/lib/dependencies/CssIcssImportDependency.js +49 -7
  68. package/lib/dependencies/CssIcssSymbolDependency.js +11 -3
  69. package/lib/dependencies/CssImportDependency.js +8 -0
  70. package/lib/dependencies/CssUrlDependency.js +25 -0
  71. package/lib/dependencies/HarmonyDetectionParserPlugin.js +1 -1
  72. package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +8 -7
  73. package/lib/dependencies/HarmonyExportExpressionDependency.js +22 -14
  74. package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +110 -3
  75. package/lib/dependencies/HarmonyImportDependency.js +10 -2
  76. package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +22 -1
  77. package/lib/dependencies/HarmonyImportSpecifierDependency.js +1 -1
  78. package/lib/{HarmonyLinkingError.js → dependencies/HarmonyLinkingError.js} +5 -3
  79. package/lib/dependencies/HtmlInlineScriptDependency.js +133 -0
  80. package/lib/dependencies/HtmlInlineStyleDependency.js +101 -0
  81. package/lib/dependencies/HtmlScriptSrcDependency.js +318 -0
  82. package/lib/dependencies/HtmlSourceDependency.js +127 -0
  83. package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +1 -1
  84. package/lib/dependencies/ImportParserPlugin.js +2 -2
  85. package/lib/dependencies/ImportPhase.js +1 -1
  86. package/lib/dependencies/RequireIncludeDependencyParserPlugin.js +1 -1
  87. package/lib/{RequireJsStuffPlugin.js → dependencies/RequireJsStuffPlugin.js} +7 -7
  88. package/lib/dependencies/SystemPlugin.js +1 -1
  89. package/lib/dependencies/WebAssemblyImportDependency.js +1 -1
  90. package/lib/dependencies/WorkerPlugin.js +2 -2
  91. package/lib/{DelegatedModule.js → dll/DelegatedModule.js} +31 -31
  92. package/lib/{DelegatedModuleFactoryPlugin.js → dll/DelegatedModuleFactoryPlugin.js} +4 -4
  93. package/lib/{DelegatedPlugin.js → dll/DelegatedPlugin.js} +2 -2
  94. package/lib/{DllEntryPlugin.js → dll/DllEntryPlugin.js} +4 -4
  95. package/lib/{DllModule.js → dll/DllModule.js} +24 -24
  96. package/lib/{DllModuleFactory.js → dll/DllModuleFactory.js} +4 -4
  97. package/lib/{DllPlugin.js → dll/DllPlugin.js} +6 -5
  98. package/lib/{DllReferencePlugin.js → dll/DllReferencePlugin.js} +14 -14
  99. package/lib/{LibManifestPlugin.js → dll/LibManifestPlugin.js} +9 -9
  100. package/lib/{AsyncDependencyToInitialChunkError.js → errors/AsyncDependencyToInitialChunkError.js} +2 -2
  101. package/lib/errors/BuildCycleError.js +1 -1
  102. package/lib/{ChunkRenderError.js → errors/ChunkRenderError.js} +1 -1
  103. package/lib/{CodeGenerationError.js → errors/CodeGenerationError.js} +1 -1
  104. package/lib/{CommentCompilationWarning.js → errors/CommentCompilationWarning.js} +3 -3
  105. package/lib/{ConcurrentCompilationError.js → errors/ConcurrentCompilationError.js} +4 -2
  106. package/lib/{EnvironmentNotSupportAsyncWarning.js → errors/EnvironmentNotSupportAsyncWarning.js} +4 -4
  107. package/lib/{HookWebpackError.js → errors/HookWebpackError.js} +5 -5
  108. package/lib/{IgnoreErrorModuleFactory.js → errors/IgnoreErrorModuleFactory.js} +4 -4
  109. package/lib/{InvalidDependenciesModuleWarning.js → errors/InvalidDependenciesModuleWarning.js} +3 -3
  110. package/lib/errors/JSONParseError.js +114 -0
  111. package/lib/{ModuleBuildError.js → errors/ModuleBuildError.js} +5 -5
  112. package/lib/{ModuleDependencyError.js → errors/ModuleDependencyError.js} +2 -2
  113. package/lib/{ModuleDependencyWarning.js → errors/ModuleDependencyWarning.js} +4 -4
  114. package/lib/{ModuleError.js → errors/ModuleError.js} +5 -5
  115. package/lib/{ModuleHashingError.js → errors/ModuleHashingError.js} +1 -1
  116. package/lib/{ModuleNotFoundError.js → errors/ModuleNotFoundError.js} +2 -2
  117. package/lib/{ModuleParseError.js → errors/ModuleParseError.js} +8 -6
  118. package/lib/{ModuleRestoreError.js → errors/ModuleRestoreError.js} +1 -1
  119. package/lib/{ModuleStoreError.js → errors/ModuleStoreError.js} +1 -1
  120. package/lib/{ModuleWarning.js → errors/ModuleWarning.js} +5 -5
  121. package/lib/{NodeStuffInWebError.js → errors/NodeStuffInWebError.js} +4 -4
  122. package/lib/errors/NonErrorEmittedError.js +28 -0
  123. package/lib/{UnhandledSchemeError.js → errors/UnhandledSchemeError.js} +2 -2
  124. package/lib/{UnsupportedFeatureWarning.js → errors/UnsupportedFeatureWarning.js} +3 -3
  125. package/lib/errors/WebpackError.js +84 -0
  126. package/lib/html/HtmlGenerator.js +379 -0
  127. package/lib/html/HtmlModulesPlugin.js +433 -0
  128. package/lib/html/HtmlParser.js +1489 -0
  129. package/lib/html/walkHtmlTokens.js +2733 -0
  130. package/lib/ids/IdHelpers.js +2 -1
  131. package/lib/index.js +34 -15
  132. package/lib/javascript/JavascriptModulesPlugin.js +89 -8
  133. package/lib/javascript/JavascriptParser.js +197 -16
  134. package/lib/javascript/JavascriptParserHelpers.js +1 -1
  135. package/lib/json/JsonParser.js +7 -16
  136. package/lib/library/AbstractLibraryPlugin.js +1 -1
  137. package/lib/library/EnableLibraryPlugin.js +1 -1
  138. package/lib/{FalseIIFEUmdWarning.js → library/FalseIIFEUmdWarning.js} +1 -1
  139. package/lib/library/ModuleLibraryPlugin.js +74 -0
  140. package/lib/node/NodeEnvironmentPlugin.js +4 -2
  141. package/lib/node/nodeConsole.js +113 -64
  142. package/lib/optimize/ConcatenatedModule.js +51 -6
  143. package/lib/optimize/InnerGraph.js +1 -1
  144. package/lib/optimize/InnerGraphPlugin.js +11 -1
  145. package/lib/optimize/MinMaxSizeWarning.js +4 -4
  146. package/lib/optimize/ModuleConcatenationPlugin.js +15 -7
  147. package/lib/optimize/RealContentHashPlugin.js +89 -26
  148. package/lib/optimize/SideEffectsFlagPlugin.js +111 -3
  149. package/lib/optimize/SplitChunksPlugin.js +1 -1
  150. package/lib/performance/AssetsOverSizeLimitWarning.js +2 -2
  151. package/lib/performance/EntrypointsOverSizeLimitWarning.js +2 -2
  152. package/lib/performance/NoAsyncChunksWarning.js +5 -3
  153. package/lib/performance/SizeLimitsPlugin.js +1 -1
  154. package/lib/prefetch/ChunkPrefetchTriggerRuntimeModule.js +4 -1
  155. package/lib/rules/UseEffectRulePlugin.js +4 -3
  156. package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +119 -13
  157. package/lib/runtime/SetAnonymousDefaultNameRuntimeModule.js +35 -0
  158. package/lib/schemes/DataUriPlugin.js +13 -1
  159. package/lib/schemes/VirtualUrlPlugin.js +1 -1
  160. package/lib/serialization/SerializerMiddleware.js +2 -2
  161. package/lib/sharing/ConsumeSharedPlugin.js +2 -2
  162. package/lib/sharing/ConsumeSharedRuntimeModule.js +8 -4
  163. package/lib/sharing/ProvideSharedModule.js +1 -1
  164. package/lib/sharing/ProvideSharedPlugin.js +1 -1
  165. package/lib/sharing/resolveMatchedConfigs.js +1 -1
  166. package/lib/stats/DefaultStatsFactoryPlugin.js +2 -2
  167. package/lib/stats/DefaultStatsPresetPlugin.js +1 -1
  168. package/lib/stats/DefaultStatsPrinterPlugin.js +1 -1
  169. package/lib/stats/StatsFactory.js +1 -1
  170. package/lib/typescript/TypeScriptPlugin.js +210 -0
  171. package/lib/url/URLParserPlugin.js +2 -2
  172. package/lib/util/AsyncQueue.js +2 -2
  173. package/lib/util/Hash.js +2 -2
  174. package/lib/util/LocConverter.js +53 -0
  175. package/lib/util/SortableSet.js +1 -1
  176. package/lib/util/cleverMerge.js +2 -2
  177. package/lib/util/comparators.js +3 -3
  178. package/lib/util/concatenate.js +3 -3
  179. package/lib/util/conventions.js +42 -1
  180. package/lib/util/createMappings.js +118 -0
  181. package/lib/{formatLocation.js → util/formatLocation.js} +2 -2
  182. package/lib/{SizeFormatHelpers.js → util/formatSize.js} +3 -1
  183. package/lib/util/fs.js +8 -8
  184. package/lib/util/hash/md4.js +1 -1
  185. package/lib/util/hash/xxhash64.js +1 -1
  186. package/lib/util/identifier.js +48 -0
  187. package/lib/util/internalSerializables.js +35 -19
  188. package/lib/util/magicComment.js +10 -7
  189. package/lib/util/parseJson.js +2 -73
  190. package/lib/util/source.js +21 -0
  191. package/lib/util/topologicalSort.js +69 -0
  192. package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +2 -2
  193. package/lib/wasm-async/AsyncWebAssemblyParser.js +1 -1
  194. package/lib/wasm-sync/UnsupportedWebAssemblyFeatureError.js +5 -3
  195. package/lib/wasm-sync/WasmFinalizeExportsPlugin.js +1 -1
  196. package/lib/wasm-sync/WebAssemblyInInitialChunkError.js +5 -3
  197. package/lib/webpack.js +3 -1
  198. package/package.json +22 -20
  199. package/schemas/WebpackOptions.check.js +1 -1
  200. package/schemas/WebpackOptions.json +118 -3
  201. package/schemas/plugins/{DllPlugin.check.d.ts → HtmlGeneratorOptions.check.d.ts} +1 -1
  202. package/schemas/plugins/HtmlGeneratorOptions.check.js +6 -0
  203. package/schemas/plugins/HtmlGeneratorOptions.json +3 -0
  204. package/schemas/plugins/ProgressPlugin.check.js +1 -1
  205. package/schemas/plugins/ProgressPlugin.json +22 -0
  206. package/schemas/plugins/{DllReferencePlugin.check.d.ts → css/CssAutoOrModuleParserOptions.check.d.ts} +1 -1
  207. package/schemas/plugins/css/CssAutoOrModuleParserOptions.check.js +6 -0
  208. package/schemas/plugins/css/CssAutoOrModuleParserOptions.json +3 -0
  209. package/schemas/plugins/dll/DllPlugin.check.d.ts +7 -0
  210. package/schemas/plugins/dll/DllReferencePlugin.check.d.ts +7 -0
  211. package/types.d.ts +810 -101
  212. package/lib/CaseSensitiveModulesWarning.js +0 -80
  213. package/lib/GraphHelpers.js +0 -49
  214. package/lib/NoModeWarning.js +0 -23
  215. package/lib/css/CssMergeStyleSheetsRuntimeModule.js +0 -57
  216. /package/lib/{AbstractMethodError.js → errors/AbstractMethodError.js} +0 -0
  217. /package/schemas/plugins/{DllPlugin.check.js → dll/DllPlugin.check.js} +0 -0
  218. /package/schemas/plugins/{DllPlugin.json → dll/DllPlugin.json} +0 -0
  219. /package/schemas/plugins/{DllReferencePlugin.check.js → dll/DllReferencePlugin.check.js} +0 -0
  220. /package/schemas/plugins/{DllReferencePlugin.json → dll/DllReferencePlugin.json} +0 -0
@@ -0,0 +1,118 @@
1
+ /*
2
+ MIT License http://www.opensource.org/licenses/mit-license.php
3
+ */
4
+
5
+ "use strict";
6
+
7
+ /**
8
+ * Utilities for building V3 source-map `mappings` strings without pulling in a
9
+ * full source-map library. The shape of the input is intentionally minimal —
10
+ * one slot per generated line, each holding zero, one, or many segments — so
11
+ * call sites that have a "one mapping per line" structure (like the CSS-module
12
+ * exports emit in `lib/css/CssGenerator.js`) can build mappings directly,
13
+ * while richer call sites can pass arrays of segments.
14
+ *
15
+ * TODO move this encoder into `webpack-sources` and replace the body of this
16
+ * file with re-exports. The public shape (`encodeVLQ`, `encodeMappings(lines)`,
17
+ * `MappingSegment`, `LineMappings`) is intended to match what would land
18
+ * upstream so call sites don't have to change.
19
+ */
20
+
21
+ const VLQ_BASE64 =
22
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
23
+
24
+ /**
25
+ * Encode a signed integer as a base64 VLQ string per the source-map V3 spec.
26
+ * @param {number} value signed integer to encode
27
+ * @returns {string} base64 VLQ encoded value
28
+ */
29
+ const encodeVLQ = (value) => {
30
+ let vlq = value < 0 ? (-value << 1) | 1 : value << 1;
31
+ let result = "";
32
+ do {
33
+ let digit = vlq & 0x1f;
34
+ vlq >>>= 5;
35
+ if (vlq > 0) digit |= 0x20;
36
+ result += VLQ_BASE64[digit];
37
+ } while (vlq > 0);
38
+ return result;
39
+ };
40
+
41
+ /**
42
+ * @typedef {object} MappingSegment
43
+ * @property {number=} generatedColumn 0-based generated column (defaults to 0)
44
+ * @property {number=} sourceIndex index into the surrounding source map's `sources` array; omit for a generated-only segment
45
+ * @property {number=} originalLine 0-based line in the original source (required when `sourceIndex` is set)
46
+ * @property {number=} originalColumn 0-based column in the original source (required when `sourceIndex` is set)
47
+ * @property {number=} nameIndex index into the surrounding source map's `names` array
48
+ */
49
+
50
+ /** @typedef {null | MappingSegment | MappingSegment[]} LineMappings */
51
+
52
+ /**
53
+ * Encode a V3 source-map `mappings` string from a per-generated-line
54
+ * description of segments.
55
+ *
56
+ * Each entry of `lines` describes the mappings for one generated line:
57
+ *
58
+ * - `null` (or `undefined`) — the line has no mappings.
59
+ * - a single `MappingSegment` — convenience for the common "one mapping at
60
+ * column 0" case.
61
+ * - `MappingSegment[]` — multiple segments on the same line.
62
+ *
63
+ * Lines are joined with `;`, segments within a line with `,`. All numeric
64
+ * fields are encoded as deltas relative to the previous emitted segment, per
65
+ * the V3 spec.
66
+ * @param {LineMappings[]} lines per-generated-line mapping segments
67
+ * @returns {string} VLQ-encoded V3 mappings string
68
+ */
69
+ const encodeMappings = (lines) => {
70
+ let prevSourceIndex = 0;
71
+ let prevOriginalLine = 0;
72
+ let prevOriginalColumn = 0;
73
+ let prevNameIndex = 0;
74
+
75
+ const encodedLines = [];
76
+
77
+ for (const line of lines) {
78
+ if (line === null || line === undefined) {
79
+ encodedLines.push("");
80
+ continue;
81
+ }
82
+
83
+ const segments = Array.isArray(line) ? line : [line];
84
+ let prevGeneratedColumn = 0;
85
+ const encodedSegments = [];
86
+
87
+ for (const segment of segments) {
88
+ const generatedColumn = segment.generatedColumn || 0;
89
+ let encoded = encodeVLQ(generatedColumn - prevGeneratedColumn);
90
+ prevGeneratedColumn = generatedColumn;
91
+
92
+ if (segment.sourceIndex !== undefined) {
93
+ const originalLine = /** @type {number} */ (segment.originalLine);
94
+ const originalColumn = /** @type {number} */ (segment.originalColumn);
95
+ encoded += encodeVLQ(segment.sourceIndex - prevSourceIndex);
96
+ encoded += encodeVLQ(originalLine - prevOriginalLine);
97
+ encoded += encodeVLQ(originalColumn - prevOriginalColumn);
98
+ prevSourceIndex = segment.sourceIndex;
99
+ prevOriginalLine = originalLine;
100
+ prevOriginalColumn = originalColumn;
101
+
102
+ if (segment.nameIndex !== undefined) {
103
+ encoded += encodeVLQ(segment.nameIndex - prevNameIndex);
104
+ prevNameIndex = segment.nameIndex;
105
+ }
106
+ }
107
+
108
+ encodedSegments.push(encoded);
109
+ }
110
+
111
+ encodedLines.push(encodedSegments.join(","));
112
+ }
113
+
114
+ return encodedLines.join(";");
115
+ };
116
+
117
+ module.exports.encodeMappings = encodeMappings;
118
+ module.exports.encodeVLQ = encodeVLQ;
@@ -5,8 +5,8 @@
5
5
 
6
6
  "use strict";
7
7
 
8
- /** @typedef {import("./Dependency").DependencyLocation} DependencyLocation */
9
- /** @typedef {import("./Dependency").SourcePosition} SourcePosition */
8
+ /** @typedef {import("../Dependency").DependencyLocation} DependencyLocation */
9
+ /** @typedef {import("../Dependency").SourcePosition} SourcePosition */
10
10
 
11
11
  /**
12
12
  * Returns formatted position.
@@ -10,7 +10,7 @@
10
10
  * @param {number=} size the size in bytes
11
11
  * @returns {string} the formatted size
12
12
  */
13
- module.exports.formatSize = (size) => {
13
+ const formatSize = (size) => {
14
14
  if (typeof size !== "number" || Number.isNaN(size) === true) {
15
15
  return "unknown size";
16
16
  }
@@ -24,3 +24,5 @@ module.exports.formatSize = (size) => {
24
24
 
25
25
  return `${Number((size / 1024 ** index).toPrecision(3))} ${abbreviations[index]}`;
26
26
  };
27
+
28
+ module.exports = formatSize;
package/lib/util/fs.js CHANGED
@@ -244,12 +244,12 @@ const path = require("path");
244
244
  /**
245
245
  * Describes the stat sync shape.
246
246
  * @typedef {{
247
- * (path: PathLike, options?: undefined): IStats,
247
+ * (path: PathLike): IStats,
248
+ * (path: PathLike, options?: StatSyncOptions & { bigint?: false | undefined, throwIfNoEntry?: true | undefined }): IStats,
249
+ * (path: PathLike, options: StatSyncOptions & { bigint: true, throwIfNoEntry?: true | undefined }): IBigIntStats,
248
250
  * (path: PathLike, options?: StatSyncOptions & { bigint?: false | undefined, throwIfNoEntry: false }): IStats | undefined,
249
251
  * (path: PathLike, options: StatSyncOptions & { bigint: true, throwIfNoEntry: false }): IBigIntStats | undefined,
250
- * (path: PathLike, options?: StatSyncOptions & { bigint?: false | undefined }): IStats,
251
- * (path: PathLike, options: StatSyncOptions & { bigint: true }): IBigIntStats,
252
- * (path: PathLike, options: StatSyncOptions & { bigint: boolean, throwIfNoEntry?: false | undefined }): IStats | IBigIntStats,
252
+ * (path: PathLike, options: StatSyncOptions & { bigint: boolean, throwIfNoEntry?: true | undefined }): IStats | IBigIntStats,
253
253
  * (path: PathLike, options?: StatSyncOptions): IStats | IBigIntStats | undefined,
254
254
  * }} StatSync
255
255
  */
@@ -267,12 +267,12 @@ const path = require("path");
267
267
  /**
268
268
  * Describes the l stat sync shape.
269
269
  * @typedef {{
270
- * (path: PathLike, options?: undefined): IStats,
270
+ * (path: PathLike): IStats,
271
+ * (path: PathLike, options?: StatSyncOptions & { bigint?: false | undefined, throwIfNoEntry?: true | undefined }): IStats,
272
+ * (path: PathLike, options: StatSyncOptions & { bigint: true, throwIfNoEntry?: true | undefined }): IBigIntStats,
271
273
  * (path: PathLike, options?: StatSyncOptions & { bigint?: false | undefined, throwIfNoEntry: false }): IStats | undefined,
272
274
  * (path: PathLike, options: StatSyncOptions & { bigint: true, throwIfNoEntry: false }): IBigIntStats | undefined,
273
- * (path: PathLike, options?: StatSyncOptions & { bigint?: false | undefined }): IStats,
274
- * (path: PathLike, options: StatSyncOptions & { bigint: true }): IBigIntStats,
275
- * (path: PathLike, options: StatSyncOptions & { bigint: boolean, throwIfNoEntry?: false | undefined }): IStats | IBigIntStats,
275
+ * (path: PathLike, options: StatSyncOptions & { bigint: boolean, throwIfNoEntry?: true | undefined }): IStats | IBigIntStats,
276
276
  * (path: PathLike, options?: StatSyncOptions): IStats | IBigIntStats | undefined,
277
277
  * }} LStatSync
278
278
  */
@@ -11,7 +11,7 @@ const create = require("./wasm-hash");
11
11
  const md4 = new WebAssembly.Module(
12
12
  Buffer.from(
13
13
  // 2150 bytes
14
- "AGFzbQEAAAABCAJgAX8AYAAAAwUEAQAAAAUDAQABBhoFfwFBAAt/AUEAC38BQQALfwFBAAt/AUEACwciBARpbml0AAAGdXBkYXRlAAIFZmluYWwAAwZtZW1vcnkCAAqFEAQmAEGBxpS6BiQBQYnXtv5+JAJB/rnrxXkkA0H2qMmBASQEQQAkAAvQCgEZfyMBIQUjAiECIwMhAyMEIQQDQCAAIAFLBEAgASgCBCIOIAQgAyABKAIAIg8gBSAEIAIgAyAEc3FzampBA3ciCCACIANzcXNqakEHdyEJIAEoAgwiBiACIAggASgCCCIQIAMgAiA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cDAAs=",
15
15
  "base64"
16
16
  )
17
17
  );
@@ -11,7 +11,7 @@ const create = require("./wasm-hash");
11
11
  const xxhash64 = new WebAssembly.Module(
12
12
  Buffer.from(
13
13
  // 1160 bytes
14
- "AGFzbQEAAAABCAJgAX8AYAAAAwQDAQAABQMBAAEGGgV+AUIAC34BQgALfgFCAAt+AUIAC34BQgALByIEBGluaXQAAAZ1cGRhdGUAAQVmaW5hbAACBm1lbW9yeQIACqgIAzAAQtbrgu7q/Yn14AAkAELP1tO+0ser2UIkAUIAJAJC+erQ0OfJoeThACQDQgAkBAvUAQIBfwR+IABFBEAPCyMEIACtfCQEIwAhAiMBIQMjAiEEIwMhBQNAIAIgASkDAELP1tO+0ser2UJ+fEIfiUKHla+vmLbem55/fiECIAMgASkDCELP1tO+0ser2UJ+fEIfiUKHla+vmLbem55/fiEDIAQgASkDEELP1tO+0ser2UJ+fEIfiUKHla+vmLbem55/fiEEIAUgASkDGELP1tO+0ser2UJ+fEIfiUKHla+vmLbem55/fiEFIAFBIGoiASAASQ0ACyACJAAgAyQBIAQkAiAFJAMLngYCAn8CfiMEQgBSBH4jAEIBiSMBQgeJfCMCQgyJfCMDQhKJfCMAQs/W077Sx6vZQn5CH4lCh5Wvr5i23puef36FQoeVr6+Ytt6bnn9+Qp2jteqDsY2K+gB9IwFCz9bTvtLHq9lCfkIfiUKHla+vmLbem55/foVCh5Wvr5i23puef35CnaO16oOxjYr6AH0jAkLP1tO+0ser2UJ+Qh+JQoeVr6+Ytt6bnn9+hUKHla+vmLbem55/fkKdo7Xqg7GNivoAfSMDQs/W077Sx6vZQn5CH4lCh5Wvr5i23puef36FQoeVr6+Ytt6bnn9+Qp2jteqDsY2K+gB9BULFz9my8eW66icLIwQgAK18fCEDA0AgAUEIaiICIABNBEAgAyABKQMAQs/W077Sx6vZQn5CH4lCh5Wvr5i23puef36FQhuJQoeVr6+Ytt6bnn9+Qp2jteqDsY2K+gB9IQMgAiEBDAELCyABQQRqIgIgAE0EQCADIA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
16
16
  )
17
17
  );
@@ -479,9 +479,57 @@ const getUndoPath = (filename, outputPath, enforceRelative) => {
479
479
  : append;
480
480
  };
481
481
 
482
+ const HASH_REGEXP = /(?<!\0)#/g;
483
+
484
+ /**
485
+ * Escape `#` characters that appear inside a path request's directory portion
486
+ * with the `\0#` escape recognized by enhanced-resolve, so a project located at
487
+ * a path like `/home/user/proj#1/` (or `./proj#1/`) resolves correctly. Applies
488
+ * to absolute paths (Unix or Windows) and relative paths (starting with `./` or
489
+ * `../`). Only triggers when a query string is present, because that is the case
490
+ * where the resolver's parseIdentifier fails (without a `?`, the resolver
491
+ * handles directory `#` via its own fallback). A `#` after the last path
492
+ * separator is left alone so that explicit fragment requests like
493
+ * `/abs/path/file.js#fragment` still behave the same. Bare module specifiers
494
+ * are not touched. Already-escaped `\0#` sequences are preserved so the
495
+ * explicit opt-out remains stable.
496
+ * @param {string} request request to potentially escape
497
+ * @returns {string} request with directory `#` characters escaped
498
+ */
499
+ const escapeHashInPathRequest = (request) => {
500
+ if (request.length === 0) return request;
501
+ const queryStart = request.indexOf("?");
502
+ if (queryStart < 0) return request;
503
+ const hashStart = request.indexOf("#");
504
+ if (hashStart < 0 || hashStart >= queryStart) return request;
505
+ const c0 = request.charCodeAt(0);
506
+ const isAbsolute =
507
+ c0 === 47 /* "/" */ || WINDOWS_ABS_PATH_REGEXP.test(request);
508
+ let isRelative = false;
509
+ if (!isAbsolute && c0 === 46 /* "." */) {
510
+ const c1 = request.charCodeAt(1);
511
+ if (c1 === 47 || c1 === 92 /* "/" or "\" */) {
512
+ isRelative = true;
513
+ } else if (c1 === 46 /* "." */) {
514
+ const c2 = request.charCodeAt(2);
515
+ if (c2 === 47 || c2 === 92) isRelative = true;
516
+ }
517
+ }
518
+ if (!isAbsolute && !isRelative) return request;
519
+ const lastSep = Math.max(
520
+ request.lastIndexOf("/", queryStart - 1),
521
+ request.lastIndexOf("\\", queryStart - 1)
522
+ );
523
+ if (hashStart >= lastSep) return request;
524
+ const pathPart = request.slice(0, lastSep);
525
+ return pathPart.replace(HASH_REGEXP, "\0#") + request.slice(lastSep);
526
+ };
527
+
482
528
  module.exports.absolutify = absolutify;
483
529
  module.exports.contextify = contextify;
530
+ module.exports.escapeHashInPathRequest = escapeHashInPathRequest;
484
531
  module.exports.getUndoPath = getUndoPath;
532
+ module.exports.makeCacheable = makeCacheable;
485
533
  module.exports.makePathsAbsolute = makeCacheableWithContext(_makePathsAbsolute);
486
534
  module.exports.makePathsRelative = makeCacheableWithContext(_makePathsRelative);
487
535
  module.exports.parseResource = makeCacheable(_parseResource);
@@ -12,7 +12,6 @@
12
12
  // to process this
13
13
  module.exports = {
14
14
  AsyncDependenciesBlock: () => require("../AsyncDependenciesBlock"),
15
- CommentCompilationWarning: () => require("../CommentCompilationWarning"),
16
15
  ContextModule: () => require("../ContextModule"),
17
16
  "cache/PackFileCacheStrategy": () =>
18
17
  require("../cache/PackFileCacheStrategy"),
@@ -109,6 +108,14 @@ module.exports = {
109
108
  require("../dependencies/HarmonyImportSpecifierDependency"),
110
109
  "dependencies/HarmonyEvaluatedImportSpecifierDependency": () =>
111
110
  require("../dependencies/HarmonyEvaluatedImportSpecifierDependency"),
111
+ "dependencies/HtmlInlineScriptDependency": () =>
112
+ require("../dependencies/HtmlInlineScriptDependency"),
113
+ "dependencies/HtmlInlineStyleDependency": () =>
114
+ require("../dependencies/HtmlInlineStyleDependency"),
115
+ "dependencies/HtmlScriptSrcDependency": () =>
116
+ require("../dependencies/HtmlScriptSrcDependency"),
117
+ "dependencies/HtmlSourceDependency": () =>
118
+ require("../dependencies/HtmlSourceDependency"),
112
119
  "dependencies/ImportContextDependency": () =>
113
120
  require("../dependencies/ImportContextDependency"),
114
121
  "dependencies/ImportDependency": () =>
@@ -179,23 +186,14 @@ module.exports = {
179
186
  "json/JsonData": () => require("../json/JsonData"),
180
187
  "optimize/ConcatenatedModule": () =>
181
188
  require("../optimize/ConcatenatedModule"),
182
- DelegatedModule: () => require("../DelegatedModule"),
189
+
183
190
  DependenciesBlock: () => require("../DependenciesBlock"),
184
- DllModule: () => require("../DllModule"),
185
191
  ExternalModule: () => require("../ExternalModule"),
186
192
  FileSystemInfo: () => require("../FileSystemInfo"),
187
193
  InitFragment: () => require("../InitFragment"),
188
- InvalidDependenciesModuleWarning: () =>
189
- require("../InvalidDependenciesModuleWarning"),
190
- Module: () => require("../Module"),
191
- ModuleBuildError: () => require("../ModuleBuildError"),
192
- ModuleDependencyWarning: () => require("../ModuleDependencyWarning"),
193
- ModuleError: () => require("../ModuleError"),
194
194
  ModuleGraph: () => require("../ModuleGraph"),
195
- ModuleParseError: () => require("../ModuleParseError"),
196
- ModuleWarning: () => require("../ModuleWarning"),
197
195
  NormalModule: () => require("../NormalModule"),
198
- CssModule: () => require("../CssModule"),
196
+ CssModule: () => require("../css/CssModule"),
199
197
  RawDataUrlModule: () => require("../asset/RawDataUrlModule"),
200
198
  RawModule: () => require("../RawModule"),
201
199
  "sharing/ConsumeSharedModule": () =>
@@ -208,14 +206,32 @@ module.exports = {
208
206
  require("../sharing/ProvideSharedDependency"),
209
207
  "sharing/ProvideForSharedDependency": () =>
210
208
  require("../sharing/ProvideForSharedDependency"),
211
- UnsupportedFeatureWarning: () => require("../UnsupportedFeatureWarning"),
212
- "util/LazySet": () => require("../util/LazySet"),
213
- UnhandledSchemeError: () => require("../UnhandledSchemeError"),
214
- NodeStuffInWebError: () => require("../NodeStuffInWebError"),
215
- EnvironmentNotSupportAsyncWarning: () =>
216
- require("../EnvironmentNotSupportAsyncWarning"),
217
- WebpackError: () => require("../WebpackError"),
218
209
 
210
+ "errors/WebpackError": () => require("../errors/WebpackError"),
211
+ "errors/InvalidDependenciesModuleWarning": () =>
212
+ require("../errors/InvalidDependenciesModuleWarning"),
213
+ "errors/Module": () => require("../Module"),
214
+ "errors/ModuleParseError": () => require("../errors/ModuleParseError"),
215
+ "errors/ModuleWarning": () => require("../errors/ModuleWarning"),
216
+ "errors/ModuleBuildError": () => require("../errors/ModuleBuildError"),
217
+ "errors/ModuleDependencyWarning": () =>
218
+ require("../errors/ModuleDependencyWarning"),
219
+ "errors/ModuleError": () => require("../errors/ModuleError"),
220
+ "errors/UnhandledSchemeError": () =>
221
+ require("../errors/UnhandledSchemeError"),
222
+ "errors/UnsupportedFeatureWarning": () =>
223
+ require("../errors/UnsupportedFeatureWarning"),
224
+ "errors/EnvironmentNotSupportAsyncWarning": () =>
225
+ require("../errors/EnvironmentNotSupportAsyncWarning"),
226
+ "errors/CommentCompilationWarning": () =>
227
+ require("../errors/CommentCompilationWarning"),
228
+ "errors/NodeStuffInWebError": () => require("../errors/NodeStuffInWebError"),
229
+ "errors/JSONParseError": () => require("../errors/JSONParseError"),
230
+
231
+ "dll/DelegatedModule": () => require("../dll/DelegatedModule"),
232
+ "dll/DllModule": () => require("../dll/DllModule"),
233
+
234
+ "util/LazySet": () => require("../util/LazySet"),
219
235
  "util/registerExternalSerializer": () => {
220
236
  // already registered
221
237
  }
@@ -9,18 +9,21 @@ const memoize = require("./memoize");
9
9
 
10
10
  const getVm = memoize(() => require("vm"));
11
11
 
12
- // regexp to match at least one "magic comment"
12
+ module.exports.CompilerHintNotationRegExp = Object.freeze({
13
+ Pure: /^\s*(?:#|@)__PURE__\s*$/,
14
+ NoSideEffects: /^\s*[#@]__NO_SIDE_EFFECTS__\s*$/
15
+ });
16
+
17
+ /**
18
+ * regexp to match at least one "magic comment"
19
+ * @returns {import("vm").Context} magic comment context
20
+ */
13
21
  module.exports.createMagicCommentContext = () =>
14
22
  getVm().createContext(undefined, {
15
23
  name: "Webpack Magic Comment Parser",
16
24
  codeGeneration: { strings: false, wasm: false }
17
25
  });
26
+
18
27
  module.exports.webpackCommentRegExp = new RegExp(
19
28
  /(^|\W)webpack[A-Z][A-Za-z]+:/
20
29
  );
21
-
22
- // regexp to match at least one "magic comment"
23
- /**
24
- * Returns magic comment context.
25
- * @returns {import("vm").Context} magic comment context
26
- */
@@ -4,6 +4,8 @@
4
4
 
5
5
  "use strict";
6
6
 
7
+ const JSONParseError = require("../errors/JSONParseError");
8
+
7
9
  /** @typedef {import("../util/fs").JsonValue} JsonValue */
8
10
 
9
11
  // Inspired by https://github.com/npm/json-parse-even-better-errors
@@ -17,79 +19,6 @@
17
19
  */
18
20
  const stripBOM = (txt) => String(txt).replace(/^\uFEFF/, "");
19
21
 
20
- class JSONParseError extends SyntaxError {
21
- /**
22
- * @param {Error} err err
23
- * @param {EXPECTED_ANY} raw raw
24
- * @param {string} txt text
25
- * @param {number=} context context
26
- * @param {EXPECTED_FUNCTION=} caller caller
27
- */
28
- constructor(err, raw, txt, context = 20, caller = parseJson) {
29
- let originalMessage = err.message;
30
- /** @type {string} */
31
- let message;
32
- /** @type {number} */
33
- let position;
34
-
35
- if (typeof raw !== "string") {
36
- message = `Cannot parse ${Array.isArray(raw) && raw.length === 0 ? "an empty array" : String(raw)}`;
37
- position = 0;
38
- } else if (!txt) {
39
- message = `${originalMessage} while parsing empty string`;
40
- position = 0;
41
- } else {
42
- // Node 20 puts single quotes around the token and a comma after it
43
- const UNEXPECTED_TOKEN = /^Unexpected token '?(.)'?(,)? /i;
44
- const badTokenMatch = originalMessage.match(UNEXPECTED_TOKEN);
45
- const badIndexMatch = originalMessage.match(/ position\s+(\d+)/i);
46
-
47
- if (badTokenMatch) {
48
- const h = badTokenMatch[1].charCodeAt(0).toString(16).toUpperCase();
49
- const hex = `0x${h.length % 2 ? "0" : ""}${h}`;
50
-
51
- originalMessage = originalMessage.replace(
52
- UNEXPECTED_TOKEN,
53
- `Unexpected token ${JSON.stringify(badTokenMatch[1])} (${hex})$2 `
54
- );
55
- }
56
-
57
- /** @type {number | undefined} */
58
- let errIdx;
59
-
60
- if (badIndexMatch) {
61
- errIdx = Number(badIndexMatch[1]);
62
- } else if (
63
- // doesn't happen in Node 22+
64
- /^Unexpected end of JSON.*/i.test(originalMessage)
65
- ) {
66
- errIdx = txt.length - 1;
67
- }
68
-
69
- if (errIdx === undefined) {
70
- message = `${originalMessage} while parsing '${txt.slice(0, context * 2)}'`;
71
- position = 0;
72
- } else {
73
- const start = errIdx <= context ? 0 : errIdx - context;
74
- const end =
75
- errIdx + context >= txt.length ? txt.length : errIdx + context;
76
- const slice = `${start ? "..." : ""}${txt.slice(start, end)}${end === txt.length ? "" : "..."}`;
77
-
78
- message = `${originalMessage} while parsing ${txt === slice ? "" : "near "}${JSON.stringify(slice)}`;
79
- position = errIdx;
80
- }
81
- }
82
-
83
- super(message);
84
-
85
- this.name = "JSONParseError";
86
- this.systemError = err;
87
- this.position = position;
88
-
89
- Error.captureStackTrace(this, caller || this.constructor);
90
- }
91
- }
92
-
93
22
  /**
94
23
  * @template [R=JsonValue]
95
24
  * @callback ParseJsonFn
@@ -6,6 +6,7 @@
6
6
  "use strict";
7
7
 
8
8
  /** @typedef {import("webpack-sources").Source} Source */
9
+ /** @typedef {import("./Hash")} Hash */
9
10
 
10
11
  /** @type {WeakMap<Source, WeakMap<Source, boolean>>} */
11
12
  const equalityCache = new WeakMap();
@@ -61,4 +62,24 @@ const isSourceEqual = (a, b) => {
61
62
  return result;
62
63
  };
63
64
 
65
+ // TODO remove in webpack 6, this is protection against authors who directly use `webpack-sources` outdated version
66
+ /**
67
+ * Feeds the Source's content into a Hash without forcing a single
68
+ * concatenated Buffer. Uses webpack-sources >= 3.4.0 `buffers()` when
69
+ * available so `ConcatSource` can stream its children directly.
70
+ * @param {Hash} hash hash to update
71
+ * @param {Source} source source whose bytes are appended
72
+ * @returns {void}
73
+ */
74
+ const updateHashFromSource = (hash, source) => {
75
+ // TODO webpack 6: drop the `buffers` check, require webpack-sources >= 3.4
76
+ // and call `source.buffers()` unconditionally.
77
+ if (typeof source.buffers === "function") {
78
+ for (const buf of source.buffers()) hash.update(buf);
79
+ } else {
80
+ hash.update(source.buffer());
81
+ }
82
+ };
83
+
64
84
  module.exports.isSourceEqual = isSourceEqual;
85
+ module.exports.updateHashFromSource = updateHashFromSource;
@@ -0,0 +1,69 @@
1
+ /*
2
+ MIT License http://www.opensource.org/licenses/mit-license.php
3
+ */
4
+
5
+ "use strict";
6
+
7
+ /**
8
+ * Topologically sort `nodes` using Kahn's algorithm with source-order
9
+ * tie-breaking. Nodes that participate in a cycle remain unvisited —
10
+ * `visit` is never called for them — so the caller can naturally keep
11
+ * them in their original position by treating "no visit" as "keep
12
+ * source order".
13
+ *
14
+ * Precondition: every node appearing in `graph` (as a key OR inside any
15
+ * successor set) must also appear in `nodes`. The caller owns this
16
+ * invariant; the function does not validate it.
17
+ *
18
+ * Complexity: O(V·(V + E)). Each outer iteration scans the ready set
19
+ * linearly to find the smallest source-index node. CSS composes graphs
20
+ * are small (a handful of files per module) so this is fine; if a much
21
+ * larger graph ever needs sorting here, swap in a min-heap.
22
+ * @template T
23
+ * @param {Map<T, Set<T>>} graph adjacency list (`a -> b` means `a` must come before `b`)
24
+ * @param {T[]} nodes nodes in source first-appearance order
25
+ * @param {(node: T, index: number) => void} visit called once per non-cyclic node in topological order
26
+ * @returns {void}
27
+ */
28
+ module.exports = (graph, nodes, visit) => {
29
+ /** @type {Map<T, number>} */
30
+ const inDegree = new Map();
31
+ /** @type {Map<T, number>} */
32
+ const sourceIndex = new Map();
33
+ for (let i = 0; i < nodes.length; i++) {
34
+ inDegree.set(nodes[i], 0);
35
+ sourceIndex.set(nodes[i], i);
36
+ }
37
+ for (const successors of graph.values()) {
38
+ for (const to of successors) {
39
+ inDegree.set(to, /** @type {number} */ (inDegree.get(to)) + 1);
40
+ }
41
+ }
42
+
43
+ const ready = nodes.filter((n) => inDegree.get(n) === 0);
44
+ let index = 0;
45
+ while (ready.length > 0) {
46
+ // Smallest-source-index wins ties. Linear scan + swap-with-last
47
+ // + pop avoids re-sorting the ready set on every iteration.
48
+ let minIdx = 0;
49
+ for (let i = 1; i < ready.length; i++) {
50
+ if (
51
+ /** @type {number} */ (sourceIndex.get(ready[i])) <
52
+ /** @type {number} */ (sourceIndex.get(ready[minIdx]))
53
+ ) {
54
+ minIdx = i;
55
+ }
56
+ }
57
+ const node = ready[minIdx];
58
+ ready[minIdx] = ready[ready.length - 1];
59
+ ready.pop();
60
+ visit(node, index++);
61
+ const successors = graph.get(node);
62
+ if (!successors) continue;
63
+ for (const to of successors) {
64
+ const newDeg = /** @type {number} */ (inDegree.get(to)) - 1;
65
+ inDegree.set(to, newDeg);
66
+ if (newDeg === 0) ready.push(to);
67
+ }
68
+ }
69
+ };
@@ -8,10 +8,10 @@
8
8
  const { SyncWaterfallHook } = require("tapable");
9
9
  const Compilation = require("../Compilation");
10
10
  const Generator = require("../Generator");
11
- const { tryRunOrWebpackError } = require("../HookWebpackError");
12
11
  const { WEBASSEMBLY_MODULE_TYPE_ASYNC } = require("../ModuleTypeConstants");
13
12
  const NormalModule = require("../NormalModule");
14
13
  const WebAssemblyImportDependency = require("../dependencies/WebAssemblyImportDependency");
14
+ const { tryRunOrWebpackError } = require("../errors/HookWebpackError");
15
15
  const { compareModulesByFullName } = require("../util/comparators");
16
16
  const makeSerializable = require("../util/makeSerializable");
17
17
  const memoize = require("../util/memoize");
@@ -27,7 +27,7 @@ const memoize = require("../util/memoize");
27
27
  /** @typedef {import("../NormalModule").NormalModuleCreateData} NormalModuleCreateData */
28
28
  /** @typedef {import("../ModuleGraph")} ModuleGraph */
29
29
  /** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */
30
- /** @typedef {import("../WebpackError")} WebpackError */
30
+ /** @typedef {import("../errors/WebpackError")} WebpackError */
31
31
  /** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
32
32
  /** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
33
33
 
@@ -7,10 +7,10 @@
7
7
 
8
8
  const t = require("@webassemblyjs/ast");
9
9
  const { decode } = require("@webassemblyjs/wasm-parser");
10
- const EnvironmentNotSupportAsyncWarning = require("../EnvironmentNotSupportAsyncWarning");
11
10
  const Parser = require("../Parser");
12
11
  const StaticExportsDependency = require("../dependencies/StaticExportsDependency");
13
12
  const WebAssemblyImportDependency = require("../dependencies/WebAssemblyImportDependency");
13
+ const EnvironmentNotSupportAsyncWarning = require("../errors/EnvironmentNotSupportAsyncWarning");
14
14
 
15
15
  /** @typedef {import("./AsyncWebAssemblyModulesPlugin").AsyncWasmModuleClass} AsyncWasmModule */
16
16
  /** @typedef {import("../Module").BuildInfo} BuildInfo */
@@ -4,9 +4,9 @@
4
4
 
5
5
  "use strict";
6
6
 
7
- const WebpackError = require("../WebpackError");
7
+ const WebpackError = require("../errors/WebpackError");
8
8
 
9
- module.exports = class UnsupportedWebAssemblyFeatureError extends WebpackError {
9
+ class UnsupportedWebAssemblyFeatureError extends WebpackError {
10
10
  /**
11
11
  * Creates an instance of UnsupportedWebAssemblyFeatureError.
12
12
  * @param {string} message Error message
@@ -18,4 +18,6 @@ module.exports = class UnsupportedWebAssemblyFeatureError extends WebpackError {
18
18
  this.name = "UnsupportedWebAssemblyFeatureError";
19
19
  this.hideStack = true;
20
20
  }
21
- };
21
+ }
22
+
23
+ module.exports = UnsupportedWebAssemblyFeatureError;
@@ -5,7 +5,7 @@
5
5
 
6
6
  "use strict";
7
7
 
8
- const formatLocation = require("../formatLocation");
8
+ const formatLocation = require("../util/formatLocation");
9
9
  const UnsupportedWebAssemblyFeatureError = require("./UnsupportedWebAssemblyFeatureError");
10
10
 
11
11
  /** @typedef {import("../Compiler")} Compiler */