webpack 5.106.2 → 5.107.1

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 (235) hide show
  1. package/README.md +2 -2
  2. package/lib/APIPlugin.js +1 -1
  3. package/lib/BannerPlugin.js +3 -4
  4. package/lib/Cache.js +3 -6
  5. package/lib/Chunk.js +21 -25
  6. package/lib/ChunkGroup.js +57 -15
  7. package/lib/CompatibilityPlugin.js +8 -7
  8. package/lib/Compilation.js +67 -37
  9. package/lib/Compiler.js +4 -13
  10. package/lib/ContextModule.js +2 -2
  11. package/lib/DefinePlugin.js +2 -2
  12. package/lib/Dependency.js +22 -1
  13. package/lib/DependencyTemplate.js +2 -1
  14. package/lib/EnvironmentPlugin.js +1 -1
  15. package/lib/EvalSourceMapDevToolPlugin.js +8 -10
  16. package/lib/ExportsInfo.js +30 -34
  17. package/lib/ExternalModule.js +91 -26
  18. package/lib/ExternalModuleFactoryPlugin.js +7 -1
  19. package/lib/FileSystemInfo.js +187 -72
  20. package/lib/Generator.js +3 -3
  21. package/lib/HotModuleReplacementPlugin.js +26 -8
  22. package/lib/IgnorePlugin.js +2 -1
  23. package/lib/Module.js +20 -19
  24. package/lib/ModuleFactory.js +1 -1
  25. package/lib/ModuleNotFoundError.js +3 -84
  26. package/lib/ModuleSourceTypeConstants.js +51 -19
  27. package/lib/ModuleTypeConstants.js +12 -3
  28. package/lib/MultiCompiler.js +2 -2
  29. package/lib/NodeStuffPlugin.js +1 -1
  30. package/lib/NormalModule.js +119 -77
  31. package/lib/NormalModuleFactory.js +47 -27
  32. package/lib/Parser.js +1 -1
  33. package/lib/ProgressPlugin.js +129 -56
  34. package/lib/RuntimeGlobals.js +5 -5
  35. package/lib/RuntimeModule.js +9 -7
  36. package/lib/RuntimePlugin.js +12 -1
  37. package/lib/SourceMapDevToolPlugin.js +250 -49
  38. package/lib/Template.js +1 -1
  39. package/lib/TemplatedPathPlugin.js +22 -4
  40. package/lib/WarnCaseSensitiveModulesPlugin.js +70 -2
  41. package/lib/WarnDeprecatedOptionPlugin.js +1 -1
  42. package/lib/WarnNoModeSetPlugin.js +16 -1
  43. package/lib/Watching.js +2 -3
  44. package/lib/WebpackError.js +3 -77
  45. package/lib/WebpackIsIncludedPlugin.js +1 -1
  46. package/lib/WebpackOptionsApply.js +13 -1
  47. package/lib/asset/AssetBytesGenerator.js +12 -8
  48. package/lib/asset/AssetGenerator.js +36 -22
  49. package/lib/asset/AssetModulesPlugin.js +6 -8
  50. package/lib/asset/AssetSourceGenerator.js +12 -8
  51. package/lib/buildChunkGraph.js +4 -6
  52. package/lib/cache/PackFileCacheStrategy.js +4 -4
  53. package/lib/cli.js +3 -1
  54. package/lib/config/defaults.js +197 -10
  55. package/lib/config/normalization.js +3 -1
  56. package/lib/css/CssGenerator.js +320 -105
  57. package/lib/css/CssInjectStyleRuntimeModule.js +44 -42
  58. package/lib/css/CssLoadingRuntimeModule.js +22 -4
  59. package/lib/{CssModule.js → css/CssModule.js} +15 -15
  60. package/lib/css/CssModulesPlugin.js +168 -88
  61. package/lib/css/CssParser.js +566 -269
  62. package/lib/css/walkCssTokens.js +148 -2
  63. package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +1 -1
  64. package/lib/dependencies/CommonJsDependencyHelpers.js +63 -0
  65. package/lib/dependencies/CommonJsExportRequireDependency.js +54 -10
  66. package/lib/dependencies/CommonJsExportsParserPlugin.js +1 -1
  67. package/lib/dependencies/CommonJsFullRequireDependency.js +32 -9
  68. package/lib/dependencies/CommonJsImportsParserPlugin.js +112 -4
  69. package/lib/dependencies/CommonJsRequireDependency.js +67 -4
  70. package/lib/dependencies/ContextDependency.js +1 -1
  71. package/lib/dependencies/ContextDependencyHelpers.js +1 -1
  72. package/lib/dependencies/CreateRequireParserPlugin.js +1 -1
  73. package/lib/dependencies/CriticalDependencyWarning.js +1 -1
  74. package/lib/dependencies/CssIcssExportDependency.js +332 -67
  75. package/lib/dependencies/CssIcssImportDependency.js +49 -7
  76. package/lib/dependencies/CssIcssSymbolDependency.js +11 -3
  77. package/lib/dependencies/CssImportDependency.js +8 -0
  78. package/lib/dependencies/CssUrlDependency.js +28 -2
  79. package/lib/dependencies/HarmonyDetectionParserPlugin.js +22 -2
  80. package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +8 -7
  81. package/lib/dependencies/HarmonyExportExpressionDependency.js +22 -14
  82. package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +110 -3
  83. package/lib/dependencies/HarmonyImportDependency.js +10 -2
  84. package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +22 -1
  85. package/lib/dependencies/HarmonyImportSpecifierDependency.js +1 -1
  86. package/lib/{HarmonyLinkingError.js → dependencies/HarmonyLinkingError.js} +5 -3
  87. package/lib/dependencies/HtmlInlineScriptDependency.js +133 -0
  88. package/lib/dependencies/HtmlInlineStyleDependency.js +101 -0
  89. package/lib/dependencies/HtmlScriptSrcDependency.js +557 -0
  90. package/lib/dependencies/HtmlSourceDependency.js +128 -0
  91. package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +1 -1
  92. package/lib/dependencies/ImportParserPlugin.js +2 -2
  93. package/lib/dependencies/ImportPhase.js +1 -1
  94. package/lib/dependencies/RequireIncludeDependencyParserPlugin.js +1 -1
  95. package/lib/{RequireJsStuffPlugin.js → dependencies/RequireJsStuffPlugin.js} +7 -7
  96. package/lib/dependencies/SystemPlugin.js +1 -1
  97. package/lib/dependencies/WebAssemblyImportDependency.js +1 -1
  98. package/lib/dependencies/WorkerPlugin.js +2 -2
  99. package/lib/{DelegatedModule.js → dll/DelegatedModule.js} +31 -31
  100. package/lib/{DelegatedModuleFactoryPlugin.js → dll/DelegatedModuleFactoryPlugin.js} +4 -4
  101. package/lib/{DelegatedPlugin.js → dll/DelegatedPlugin.js} +2 -2
  102. package/lib/{DllEntryPlugin.js → dll/DllEntryPlugin.js} +4 -4
  103. package/lib/{DllModule.js → dll/DllModule.js} +24 -24
  104. package/lib/{DllModuleFactory.js → dll/DllModuleFactory.js} +4 -4
  105. package/lib/{DllPlugin.js → dll/DllPlugin.js} +6 -5
  106. package/lib/{DllReferencePlugin.js → dll/DllReferencePlugin.js} +14 -14
  107. package/lib/{LibManifestPlugin.js → dll/LibManifestPlugin.js} +9 -9
  108. package/lib/{AsyncDependencyToInitialChunkError.js → errors/AsyncDependencyToInitialChunkError.js} +2 -2
  109. package/lib/errors/BuildCycleError.js +1 -1
  110. package/lib/{ChunkRenderError.js → errors/ChunkRenderError.js} +1 -1
  111. package/lib/{CodeGenerationError.js → errors/CodeGenerationError.js} +1 -1
  112. package/lib/{CommentCompilationWarning.js → errors/CommentCompilationWarning.js} +3 -3
  113. package/lib/{ConcurrentCompilationError.js → errors/ConcurrentCompilationError.js} +4 -2
  114. package/lib/{EnvironmentNotSupportAsyncWarning.js → errors/EnvironmentNotSupportAsyncWarning.js} +4 -4
  115. package/lib/{HookWebpackError.js → errors/HookWebpackError.js} +5 -5
  116. package/lib/{IgnoreErrorModuleFactory.js → errors/IgnoreErrorModuleFactory.js} +4 -4
  117. package/lib/{InvalidDependenciesModuleWarning.js → errors/InvalidDependenciesModuleWarning.js} +3 -3
  118. package/lib/errors/JSONParseError.js +114 -0
  119. package/lib/{ModuleBuildError.js → errors/ModuleBuildError.js} +5 -5
  120. package/lib/{ModuleDependencyError.js → errors/ModuleDependencyError.js} +2 -2
  121. package/lib/{ModuleDependencyWarning.js → errors/ModuleDependencyWarning.js} +4 -4
  122. package/lib/{ModuleError.js → errors/ModuleError.js} +5 -5
  123. package/lib/{ModuleHashingError.js → errors/ModuleHashingError.js} +1 -1
  124. package/lib/errors/ModuleNotFoundError.js +91 -0
  125. package/lib/{ModuleParseError.js → errors/ModuleParseError.js} +8 -6
  126. package/lib/{ModuleRestoreError.js → errors/ModuleRestoreError.js} +1 -1
  127. package/lib/{ModuleStoreError.js → errors/ModuleStoreError.js} +1 -1
  128. package/lib/{ModuleWarning.js → errors/ModuleWarning.js} +5 -5
  129. package/lib/{NodeStuffInWebError.js → errors/NodeStuffInWebError.js} +4 -4
  130. package/lib/errors/NonErrorEmittedError.js +28 -0
  131. package/lib/{UnhandledSchemeError.js → errors/UnhandledSchemeError.js} +2 -2
  132. package/lib/{UnsupportedFeatureWarning.js → errors/UnsupportedFeatureWarning.js} +3 -3
  133. package/lib/errors/WebpackError.js +84 -0
  134. package/lib/html/HtmlGenerator.js +379 -0
  135. package/lib/html/HtmlModulesPlugin.js +429 -0
  136. package/lib/html/HtmlParser.js +1489 -0
  137. package/lib/html/walkHtmlTokens.js +3249 -0
  138. package/lib/ids/IdHelpers.js +2 -1
  139. package/lib/index.js +36 -15
  140. package/lib/javascript/JavascriptModulesPlugin.js +91 -10
  141. package/lib/javascript/JavascriptParser.js +197 -16
  142. package/lib/javascript/JavascriptParserHelpers.js +1 -1
  143. package/lib/json/JsonParser.js +7 -16
  144. package/lib/library/AbstractLibraryPlugin.js +1 -1
  145. package/lib/library/EnableLibraryPlugin.js +1 -1
  146. package/lib/{FalseIIFEUmdWarning.js → library/FalseIIFEUmdWarning.js} +1 -1
  147. package/lib/library/ModuleLibraryPlugin.js +74 -0
  148. package/lib/node/NodeEnvironmentPlugin.js +4 -2
  149. package/lib/node/nodeConsole.js +113 -64
  150. package/lib/optimize/ConcatenatedModule.js +51 -6
  151. package/lib/optimize/InnerGraph.js +1 -1
  152. package/lib/optimize/InnerGraphPlugin.js +11 -1
  153. package/lib/optimize/MinMaxSizeWarning.js +4 -4
  154. package/lib/optimize/ModuleConcatenationPlugin.js +15 -7
  155. package/lib/optimize/RealContentHashPlugin.js +89 -26
  156. package/lib/optimize/SideEffectsFlagPlugin.js +112 -5
  157. package/lib/optimize/SplitChunksPlugin.js +5 -5
  158. package/lib/performance/AssetsOverSizeLimitWarning.js +2 -2
  159. package/lib/performance/EntrypointsOverSizeLimitWarning.js +2 -2
  160. package/lib/performance/NoAsyncChunksWarning.js +5 -3
  161. package/lib/performance/SizeLimitsPlugin.js +1 -1
  162. package/lib/prefetch/ChunkPrefetchTriggerRuntimeModule.js +4 -1
  163. package/lib/rules/UseEffectRulePlugin.js +4 -3
  164. package/lib/runtime/AutoPublicPathRuntimeModule.js +3 -3
  165. package/lib/runtime/GetChunkFilenameRuntimeModule.js +5 -5
  166. package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +119 -13
  167. package/lib/runtime/SetAnonymousDefaultNameRuntimeModule.js +35 -0
  168. package/lib/schemes/DataUriPlugin.js +13 -1
  169. package/lib/schemes/VirtualUrlPlugin.js +1 -1
  170. package/lib/serialization/SerializerMiddleware.js +2 -2
  171. package/lib/sharing/ConsumeSharedPlugin.js +4 -10
  172. package/lib/sharing/ConsumeSharedRuntimeModule.js +8 -4
  173. package/lib/sharing/ProvideSharedModule.js +1 -1
  174. package/lib/sharing/ProvideSharedPlugin.js +5 -5
  175. package/lib/sharing/resolveMatchedConfigs.js +1 -1
  176. package/lib/stats/DefaultStatsFactoryPlugin.js +2 -2
  177. package/lib/stats/DefaultStatsPresetPlugin.js +1 -1
  178. package/lib/stats/DefaultStatsPrinterPlugin.js +1 -1
  179. package/lib/stats/StatsFactory.js +1 -1
  180. package/lib/typescript/TypeScriptPlugin.js +210 -0
  181. package/lib/url/URLParserPlugin.js +2 -2
  182. package/lib/util/AsyncQueue.js +2 -2
  183. package/lib/util/Hash.js +2 -2
  184. package/lib/util/LocConverter.js +53 -0
  185. package/lib/util/SortableSet.js +1 -1
  186. package/lib/util/cleverMerge.js +2 -2
  187. package/lib/util/comparators.js +3 -3
  188. package/lib/util/concatenate.js +3 -3
  189. package/lib/util/conventions.js +42 -1
  190. package/lib/util/createMappings.js +118 -0
  191. package/lib/{formatLocation.js → util/formatLocation.js} +2 -2
  192. package/lib/{SizeFormatHelpers.js → util/formatSize.js} +3 -1
  193. package/lib/util/fs.js +8 -8
  194. package/lib/util/hash/md4.js +1 -1
  195. package/lib/util/hash/xxhash64.js +1 -1
  196. package/lib/util/identifier.js +48 -0
  197. package/lib/util/internalSerializables.js +35 -19
  198. package/lib/util/magicComment.js +10 -7
  199. package/lib/util/parseJson.js +2 -73
  200. package/lib/util/source.js +21 -0
  201. package/lib/util/topologicalSort.js +69 -0
  202. package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +3 -4
  203. package/lib/wasm-async/AsyncWebAssemblyParser.js +1 -1
  204. package/lib/wasm-sync/UnsupportedWebAssemblyFeatureError.js +5 -3
  205. package/lib/wasm-sync/WasmFinalizeExportsPlugin.js +1 -1
  206. package/lib/wasm-sync/WebAssemblyInInitialChunkError.js +5 -3
  207. package/lib/webpack.js +3 -1
  208. package/package.json +24 -22
  209. package/schemas/WebpackOptions.check.js +1 -1
  210. package/schemas/WebpackOptions.json +129 -12
  211. package/schemas/plugins/{DllPlugin.check.d.ts → HtmlGeneratorOptions.check.d.ts} +1 -1
  212. package/schemas/plugins/HtmlGeneratorOptions.check.js +6 -0
  213. package/schemas/plugins/HtmlGeneratorOptions.json +3 -0
  214. package/schemas/plugins/ProgressPlugin.check.js +1 -1
  215. package/schemas/plugins/ProgressPlugin.json +22 -0
  216. package/schemas/plugins/container/ContainerReferencePlugin.check.js +1 -1
  217. package/schemas/plugins/container/ContainerReferencePlugin.json +1 -0
  218. package/schemas/plugins/container/ExternalsType.check.js +1 -1
  219. package/schemas/plugins/container/ModuleFederationPlugin.check.js +1 -1
  220. package/schemas/plugins/container/ModuleFederationPlugin.json +1 -0
  221. package/schemas/plugins/{DllReferencePlugin.check.d.ts → css/CssAutoOrModuleParserOptions.check.d.ts} +1 -1
  222. package/schemas/plugins/css/CssAutoOrModuleParserOptions.check.js +6 -0
  223. package/schemas/plugins/css/CssAutoOrModuleParserOptions.json +3 -0
  224. package/schemas/plugins/dll/DllPlugin.check.d.ts +7 -0
  225. package/schemas/plugins/dll/DllReferencePlugin.check.d.ts +7 -0
  226. package/types.d.ts +1153 -233
  227. package/lib/CaseSensitiveModulesWarning.js +0 -80
  228. package/lib/GraphHelpers.js +0 -49
  229. package/lib/NoModeWarning.js +0 -23
  230. package/lib/css/CssMergeStyleSheetsRuntimeModule.js +0 -57
  231. /package/lib/{AbstractMethodError.js → errors/AbstractMethodError.js} +0 -0
  232. /package/schemas/plugins/{DllPlugin.check.js → dll/DllPlugin.check.js} +0 -0
  233. /package/schemas/plugins/{DllPlugin.json → dll/DllPlugin.json} +0 -0
  234. /package/schemas/plugins/{DllReferencePlugin.check.js → dll/DllReferencePlugin.check.js} +0 -0
  235. /package/schemas/plugins/{DllReferencePlugin.json → dll/DllReferencePlugin.json} +0 -0
@@ -0,0 +1,557 @@
1
+ /*
2
+ MIT License http://www.opensource.org/licenses/mit-license.php
3
+ */
4
+
5
+ "use strict";
6
+
7
+ const {
8
+ CSS_IMPORT_TYPE,
9
+ CSS_TYPE,
10
+ JAVASCRIPT_TYPE
11
+ } = require("../ModuleSourceTypeConstants");
12
+ const makeSerializable = require("../util/makeSerializable");
13
+ const CssUrlDependency = require("./CssUrlDependency");
14
+ const ModuleDependency = require("./ModuleDependency");
15
+
16
+ /** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */
17
+ /** @typedef {import("../Chunk")} Chunk */
18
+ /** @typedef {import("../ChunkGraph")} ChunkGraph */
19
+ /** @typedef {import("../Dependency")} Dependency */
20
+ /** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */
21
+ /** @typedef {import("../Entrypoint")} Entrypoint */
22
+ /** @typedef {import("../javascript/JavascriptParser").Range} Range */
23
+ /** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
24
+ /** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
25
+
26
+ /** @typedef {"script-classic" | "script-module" | "modulepreload" | "stylesheet"} HtmlScriptElementKind */
27
+
28
+ class HtmlScriptSrcDependency extends ModuleDependency {
29
+ /**
30
+ * Creates an instance of HtmlScriptSrcDependency.
31
+ * @param {string} request request
32
+ * @param {Range} range range of the attribute value in the source
33
+ * @param {string} entryName name of the entry this script src is bundled into
34
+ * @param {string=} category dependency category used for resolving and grouping
35
+ * @param {HtmlScriptElementKind=} elementKind shape of the originating HTML element; used when expanding sibling tags for split/runtime chunks
36
+ * @param {number=} tagStart position of the opening `<` of the originating tag in the source; sibling tags emitted for additional entry chunks are inserted right before this
37
+ * @param {number=} tagOpenEnd position of the character immediately after the opening tag's `>` in the source; combined with `tagStart` this lets the template clone the original opening tag verbatim (preserving attributes like `nonce`, `crossorigin`, `referrerpolicy`, `defer`, `async`) when generating sibling tags
38
+ */
39
+ constructor(
40
+ request,
41
+ range,
42
+ entryName,
43
+ category,
44
+ elementKind,
45
+ tagStart,
46
+ tagOpenEnd
47
+ ) {
48
+ super(request);
49
+ this.range = range;
50
+ this.entryName = entryName;
51
+ /** @type {string} */
52
+ this._category = category || "commonjs";
53
+ /** @type {HtmlScriptElementKind} */
54
+ this.elementKind = elementKind || "script-classic";
55
+ /** @type {number} */
56
+ this.tagStart = tagStart === undefined ? -1 : tagStart;
57
+ /** @type {number} */
58
+ this.tagOpenEnd = tagOpenEnd === undefined ? -1 : tagOpenEnd;
59
+ }
60
+
61
+ get type() {
62
+ return "html script src";
63
+ }
64
+
65
+ get category() {
66
+ return this._category;
67
+ }
68
+
69
+ /**
70
+ * Serializes this instance into the provided serializer context.
71
+ * @param {ObjectSerializerContext} context context
72
+ */
73
+ serialize(context) {
74
+ const { write } = context;
75
+ write(this.entryName);
76
+ write(this._category);
77
+ write(this.elementKind);
78
+ write(this.tagStart);
79
+ write(this.tagOpenEnd);
80
+ super.serialize(context);
81
+ }
82
+
83
+ /**
84
+ * Restores this instance from the provided deserializer context.
85
+ * @param {ObjectDeserializerContext} context context
86
+ */
87
+ deserialize(context) {
88
+ const { read } = context;
89
+ this.entryName = read();
90
+ this._category = read();
91
+ this.elementKind = read();
92
+ this.tagStart = read();
93
+ this.tagOpenEnd = read();
94
+ super.deserialize(context);
95
+ }
96
+ }
97
+
98
+ /**
99
+ * @param {Chunk} chunk a chunk
100
+ * @param {import("../Compilation")} compilation compilation
101
+ * @param {"javascript" | "css"} contentHashType which content hash to plug into the filename template
102
+ * @returns {string} chunk filename path (no public-path prefix)
103
+ */
104
+ const getChunkFilename = (chunk, compilation, contentHashType) => {
105
+ const outputOptions = compilation.outputOptions;
106
+ let filenameTemplate;
107
+ if (contentHashType === "css") {
108
+ // For a CSS-typed chunk, use the same template the CSS pipeline
109
+ // will use when it actually emits the `.css` file, so the `<link
110
+ // rel="stylesheet" href>` URL we write into the HTML matches the
111
+ // asset on disk.
112
+ filenameTemplate =
113
+ require("../css/CssModulesPlugin").getChunkFilenameTemplate(
114
+ chunk,
115
+ outputOptions
116
+ );
117
+ } else {
118
+ filenameTemplate =
119
+ chunk.filenameTemplate ||
120
+ (chunk.canBeInitial()
121
+ ? outputOptions.filename
122
+ : outputOptions.chunkFilename);
123
+ }
124
+
125
+ return compilation.getPath(filenameTemplate, {
126
+ chunk,
127
+ contentHashType
128
+ });
129
+ };
130
+
131
+ /**
132
+ * @param {Entrypoint} entrypoint entrypoint
133
+ * @returns {Chunk[]} every chunk this entrypoint needs in load order: the
134
+ * runtime chunk first (when `optimization.runtimeChunk` splits it off), then
135
+ * any intermediate chunks (e.g. from `optimization.splitChunks`), and finally
136
+ * the entry chunk itself. The entry chunk is always returned last so callers
137
+ * can identify it as the tag whose `src`/`href` attribute is being rewritten
138
+ * in place. Chunks that are already loaded by an ancestor (`dependOn`) entry's
139
+ * own script tag — i.e. the parent entrypoint's entry chunk *and* its runtime
140
+ * chunk — are skipped, otherwise they would be loaded twice when the same
141
+ * HTML contains tags for both the leader and the dependant entries.
142
+ */
143
+ const getEntrypointChunksInLoadOrder = (entrypoint) => {
144
+ const entryChunk = /** @type {Chunk} */ (entrypoint.getEntrypointChunk());
145
+ const runtimeChunk = entrypoint.getRuntimeChunk();
146
+
147
+ /** @type {Set<Chunk>} */
148
+ const chunksLoadedByAncestorTags = new Set();
149
+ /** @type {Set<import("../ChunkGroup")>} */
150
+ const visitedGroups = new Set();
151
+ const walk = (/** @type {import("../ChunkGroup")} */ group) => {
152
+ if (visitedGroups.has(group)) return;
153
+ visitedGroups.add(group);
154
+ for (const parent of group.parentsIterable) {
155
+ if (
156
+ typeof (/** @type {Entrypoint} */ (parent).getEntrypointChunk) ===
157
+ "function"
158
+ ) {
159
+ const parentEntry =
160
+ /** @type {Entrypoint} */
161
+ (parent).getEntrypointChunk();
162
+ if (parentEntry) chunksLoadedByAncestorTags.add(parentEntry);
163
+ const parentRuntime =
164
+ /** @type {Entrypoint} */
165
+ (parent).getRuntimeChunk();
166
+ if (parentRuntime) chunksLoadedByAncestorTags.add(parentRuntime);
167
+ }
168
+ walk(parent);
169
+ }
170
+ };
171
+ walk(entrypoint);
172
+
173
+ /** @type {Chunk[]} */
174
+ const ordered = [];
175
+ /** @type {Set<Chunk>} */
176
+ const seen = new Set();
177
+ const push = (/** @type {Chunk | null | undefined} */ chunk) => {
178
+ if (!chunk || seen.has(chunk) || chunk === entryChunk) return;
179
+ if (chunksLoadedByAncestorTags.has(chunk)) return;
180
+ seen.add(chunk);
181
+ ordered.push(chunk);
182
+ };
183
+ if (runtimeChunk !== entryChunk) {
184
+ push(runtimeChunk);
185
+ }
186
+ for (const chunk of entrypoint.chunks) {
187
+ push(chunk);
188
+ }
189
+ ordered.push(entryChunk);
190
+ return ordered;
191
+ };
192
+
193
+ /**
194
+ * Whether webpack will emit a `.js` file for this chunk that must be
195
+ * loaded with a `<script>` tag. Covers three independent reasons a
196
+ * chunk needs JS output: it owns one or more JS-source-type modules;
197
+ * it has entry modules whose source types include JavaScript (entry
198
+ * modules don't show up in `getChunkModulesIterableBySourceType` until
199
+ * they're connected as regular modules — this is why
200
+ * `JavascriptModulesPlugin#_chunkHasJs` checks them separately); or it
201
+ * is a runtime chunk — `chunk.hasRuntime()` — which produces a `.js`
202
+ * file holding the webpack runtime, but its `RuntimeModule`s live in
203
+ * a separate `runtimeModules` set and are *not* surfaced via
204
+ * `getChunkModulesIterableBySourceType`. Missing the runtime case
205
+ * would cause a `runtimeChunk`-split chunk to fall out of the
206
+ * `<script>` list and re-emerge after the chunks that depend on it,
207
+ * producing `__webpack_require__ is not defined` at load time.
208
+ * @param {Chunk} chunk chunk
209
+ * @param {ChunkGraph} chunkGraph chunk graph
210
+ * @returns {boolean} true if the chunk emits a `.js` file
211
+ */
212
+ const chunkHasJs = (chunk, chunkGraph) => {
213
+ if (chunk.hasRuntime()) return true;
214
+ if (chunkGraph.getNumberOfEntryModules(chunk) > 0) {
215
+ for (const module of chunkGraph.getChunkEntryModulesIterable(chunk)) {
216
+ if (chunkGraph.getModuleSourceTypes(module).has(JAVASCRIPT_TYPE)) {
217
+ return true;
218
+ }
219
+ }
220
+ }
221
+ return Boolean(
222
+ chunkGraph.getChunkModulesIterableBySourceType(chunk, JAVASCRIPT_TYPE)
223
+ );
224
+ };
225
+
226
+ /**
227
+ * Whether webpack will emit a `.css` file for this chunk that must be
228
+ * loaded with a `<link rel="stylesheet">` tag. Matches
229
+ * `CssModulesPlugin.chunkHasCss` exactly — both regular CSS modules
230
+ * and pure `@import` placeholder modules count, since the latter
231
+ * still contribute a `.css` asset to the chunk.
232
+ * @param {Chunk} chunk chunk
233
+ * @param {ChunkGraph} chunkGraph chunk graph
234
+ * @returns {boolean} true if the chunk emits a `.css` file
235
+ */
236
+ const chunkHasCss = (chunk, chunkGraph) =>
237
+ Boolean(chunkGraph.getChunkModulesIterableBySourceType(chunk, CSS_TYPE)) ||
238
+ Boolean(
239
+ chunkGraph.getChunkModulesIterableBySourceType(chunk, CSS_IMPORT_TYPE)
240
+ );
241
+
242
+ /**
243
+ * Compare two chunks for a deterministic tie-break in CSS link ordering.
244
+ * `chunk.name` and `chunk.id` are both stable strings (when present);
245
+ * one of them is set for every chunk webpack emits. We can't rely on
246
+ * `Array.prototype.sort` being stable — webpack still supports Node
247
+ * 10.13 where V8's sort is not guaranteed stable for arrays larger
248
+ * than ten elements — so any time `firstCssModulePostOrderIndex`
249
+ * returns the same value for two chunks (most commonly when several
250
+ * chunks have no reachable CSS module in the entrypoint's dependency
251
+ * walk and all map to `Infinity`) this comparator picks the canonical
252
+ * order.
253
+ * @param {Chunk} a first chunk
254
+ * @param {Chunk} b second chunk
255
+ * @returns {-1 | 0 | 1} ordering
256
+ */
257
+ const compareChunksForCssTieBreak = (a, b) => {
258
+ const an = `${a.name || ""} ${a.id === null || a.id === undefined ? "" : a.id}`;
259
+ const bn = `${b.name || ""} ${b.id === null || b.id === undefined ? "" : b.id}`;
260
+ if (an < bn) return -1;
261
+ if (an > bn) return 1;
262
+ return 0;
263
+ };
264
+
265
+ /**
266
+ * Smallest post-order index among the CSS modules of a chunk, taken
267
+ * from the entrypoint's view of the dependency graph. Used to sort
268
+ * sibling CSS chunks so they appear in source import order in the
269
+ * extracted HTML — `entrypoint.chunks` itself does not give that
270
+ * ordering for arbitrary splitChunks layouts. Considers both
271
+ * `CSS_TYPE` and `CSS_IMPORT_TYPE` modules so a chunk made up
272
+ * exclusively of `@import` placeholder modules (e.g. when splitChunks
273
+ * separates them from their target CSS) still sorts by its true
274
+ * source position rather than collapsing to `Infinity` and relying on
275
+ * the chunk-name tie-breaker.
276
+ * @param {Chunk} chunk chunk
277
+ * @param {Entrypoint} entrypoint entrypoint the chunk belongs to
278
+ * @param {ChunkGraph} chunkGraph chunk graph
279
+ * @returns {number} the lowest post-order index of any CSS or
280
+ * CSS-import module in the chunk, or `Number.POSITIVE_INFINITY` when
281
+ * no such module has a defined index (e.g. for a module the
282
+ * entrypoint never reached on its own dependency walk — runtime-only
283
+ * modules, modules reached via `dependOn`, etc.) so such chunks sort
284
+ * last among CSS chunks
285
+ */
286
+ const firstCssModulePostOrderIndex = (chunk, entrypoint, chunkGraph) => {
287
+ let min = Number.POSITIVE_INFINITY;
288
+ for (const sourceType of [CSS_TYPE, CSS_IMPORT_TYPE]) {
289
+ const modules = chunkGraph.getChunkModulesIterableBySourceType(
290
+ chunk,
291
+ sourceType
292
+ );
293
+ if (!modules) continue;
294
+ for (const module of modules) {
295
+ const idx = entrypoint.getModulePostOrderIndex(module);
296
+ if (idx !== undefined && idx < min) min = idx;
297
+ }
298
+ }
299
+ return min;
300
+ };
301
+
302
+ const COPYABLE_LINK_ATTRS = ["nonce", "crossorigin", "referrerpolicy"];
303
+
304
+ /**
305
+ * Build a fresh `<link rel="stylesheet" href="…">` for a CSS chunk that
306
+ * was pulled in by a `<script src>` entry — the originating tag was a
307
+ * `<script>`, but the chunk is CSS so cloning the script tag verbatim
308
+ * would produce nonsense (`<script src="…\.css">`). Copy
309
+ * `nonce`/`crossorigin`/`referrerpolicy` from the original element so
310
+ * the same CSP and fetch policy applies; `defer`/`async`/`type` have no
311
+ * meaning on `<link>` and are dropped.
312
+ * @param {string} originalTag the originating `<script>`/`<link>` tag's source text
313
+ * @param {string} href URL for the stylesheet
314
+ * @returns {string} the sibling `<link>` tag's HTML
315
+ */
316
+ const buildStylesheetLink = (originalTag, href) => {
317
+ let extra = "";
318
+ for (const attr of COPYABLE_LINK_ATTRS) {
319
+ // Match ` <attr>`, ` <attr>=value`, ` <attr>="value"`, ` <attr>='value'`.
320
+ const re = new RegExp(
321
+ `\\s${attr}(?:\\s*=\\s*(?:"[^"]*"|'[^']*'|[^\\s>]+))?(?=[\\s/>])`,
322
+ "i"
323
+ );
324
+ const m = originalTag.match(re);
325
+ if (m) extra += m[0];
326
+ }
327
+ const safeHref = href.replace(/"/g, "&quot;");
328
+ return `<link rel="stylesheet" href="${safeHref}"${extra}>`;
329
+ };
330
+
331
+ /**
332
+ * Clone the original `<script>`/`<link>` opening tag with its `src`/`href`
333
+ * value swapped for a different chunk URL. Reusing the source text verbatim
334
+ * preserves attributes such as `nonce`, `crossorigin`, `referrerpolicy`,
335
+ * `defer`, and `async` so the sibling tags load with the same semantics as
336
+ * the entry tag that's already there. `integrity` is dropped because it's
337
+ * content-specific. When the original tag was upgraded to a module script
338
+ * (either by the author or by the `output.module` auto-upgrade in
339
+ * `HtmlParser`), the sibling is forced to `type="module"` regardless of what
340
+ * the source originally said.
341
+ * @param {string} originalTag the opening tag's source text including `>`
342
+ * @param {number} srcStartInTag offset of the src/href value start within `originalTag`
343
+ * @param {number} srcEndInTag offset of the src/href value end within `originalTag`
344
+ * @param {string} newUrl URL to put into the cloned tag's src/href slot
345
+ * @param {HtmlScriptElementKind} elementKind shape of the originating tag
346
+ * @returns {string} the sibling tag's HTML (including a closing `</script>` for script tags)
347
+ */
348
+ const cloneTagWithUrl = (
349
+ originalTag,
350
+ srcStartInTag,
351
+ srcEndInTag,
352
+ newUrl,
353
+ elementKind
354
+ ) => {
355
+ let body =
356
+ originalTag.slice(0, srcStartInTag) +
357
+ newUrl +
358
+ originalTag.slice(srcEndInTag);
359
+
360
+ // Strip dangerous-to-copy attributes from the cloned tag — currently
361
+ // just `integrity`. The match handles all three quoting styles
362
+ // (`"…"`, `'…'`, unquoted) and the bare-attribute form.
363
+ body = body.replace(
364
+ /\s+integrity(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+))?(?=[\s/>])/gi,
365
+ ""
366
+ );
367
+
368
+ if (elementKind === "script-module") {
369
+ if (/\stype\s*=/i.test(body)) {
370
+ body = body.replace(
371
+ /(\stype\s*=\s*)(?:"[^"]*"|'[^']*'|[^\s>]+)/i,
372
+ '$1"module"'
373
+ );
374
+ } else {
375
+ body = body.replace(/^<script\b/i, '<script type="module"');
376
+ }
377
+ }
378
+
379
+ // `<link>` is a void element — no closing tag. `<script>` needs `</script>`.
380
+ return elementKind === "modulepreload" || elementKind === "stylesheet"
381
+ ? body
382
+ : `${body}</script>`;
383
+ };
384
+
385
+ HtmlScriptSrcDependency.Template = class HtmlScriptSrcDependencyTemplate extends (
386
+ ModuleDependency.Template
387
+ ) {
388
+ /**
389
+ * Applies the plugin by registering its hooks on the compiler.
390
+ * @param {Dependency} dependency the dependency for which the template should be applied
391
+ * @param {ReplaceSource} source the current replace source which can be modified
392
+ * @param {DependencyTemplateContext} templateContext the context object
393
+ * @returns {void}
394
+ */
395
+ apply(dependency, source, templateContext) {
396
+ const { runtimeTemplate } = templateContext;
397
+ const dep = /** @type {HtmlScriptSrcDependency} */ (dependency);
398
+ const compilation = runtimeTemplate.compilation;
399
+ const { chunkGraph } = compilation;
400
+ const entrypoint = /** @type {Entrypoint | undefined} */ (
401
+ compilation.entrypoints.get(dep.entryName)
402
+ );
403
+
404
+ if (!entrypoint) {
405
+ source.replace(dep.range[0], dep.range[1] - 1, "data:,");
406
+ return;
407
+ }
408
+
409
+ const orderedChunks = getEntrypointChunksInLoadOrder(entrypoint);
410
+ const entryChunk = orderedChunks[orderedChunks.length - 1];
411
+ const isStylesheet = dep.elementKind === "stylesheet";
412
+
413
+ // Rewrite the originating tag's src/href to the entry chunk's
414
+ // primary asset for that element kind: `.css` for
415
+ // `<link rel="stylesheet">`, `.js` for everything else.
416
+ const entryContentHashType = isStylesheet ? "css" : "javascript";
417
+ const entryUrl = `${CssUrlDependency.PUBLIC_PATH_AUTO}${getChunkFilename(
418
+ entryChunk,
419
+ compilation,
420
+ entryContentHashType
421
+ )}`;
422
+ source.replace(dep.range[0], dep.range[1] - 1, entryUrl);
423
+
424
+ if (dep.tagStart < 0 || dep.tagOpenEnd <= dep.tagStart) {
425
+ return;
426
+ }
427
+
428
+ // The browser must load every chunk the entry needs, not just the
429
+ // entry chunk. For `<script>` entries that's the JS for sibling
430
+ // chunks plus — critically — the CSS for any chunk that holds
431
+ // stylesheets imported transitively from the JS source. Previously
432
+ // every sibling was cloned as a `<script>` pointing at a `.js`
433
+ // filename, so CSS chunks ended up as `<script src="foo.css">`
434
+ // pointing at non-existent `.js` files (the bug in
435
+ // html-webpack-plugin#1838 / webpack/mini-css-extract-plugin#959,
436
+ // magnified here because the entry chunk's own CSS was emitted to
437
+ // disk but never linked from the HTML at all).
438
+ const originalContent = /** @type {string} */ (source.original().source());
439
+ const originalTag = originalContent.slice(dep.tagStart, dep.tagOpenEnd);
440
+ const srcStartInTag = dep.range[0] - dep.tagStart;
441
+ const srcEndInTag = dep.range[1] - dep.tagStart;
442
+
443
+ /**
444
+ * @param {Chunk} chunk chunk to emit a sibling tag for
445
+ * @param {"javascript" | "css"} kind content type slice of the chunk to emit
446
+ * @returns {string} a single sibling tag's HTML
447
+ */
448
+ const buildSibling = (chunk, kind) => {
449
+ const url = `${CssUrlDependency.PUBLIC_PATH_AUTO}${getChunkFilename(
450
+ chunk,
451
+ compilation,
452
+ kind
453
+ )}`;
454
+ if (kind === "css" && !isStylesheet) {
455
+ // Originating tag is `<script>` (or `<link rel=modulepreload>`)
456
+ // but this chunk is CSS — emit a fresh `<link>` rather than
457
+ // cloning the script.
458
+ return buildStylesheetLink(originalTag, url);
459
+ }
460
+ return cloneTagWithUrl(
461
+ originalTag,
462
+ srcStartInTag,
463
+ srcEndInTag,
464
+ url,
465
+ dep.elementKind
466
+ );
467
+ };
468
+
469
+ const siblings = [];
470
+
471
+ if (isStylesheet) {
472
+ // `<link rel="stylesheet">` entries are CSS-only — every sibling
473
+ // chunk in the entrypoint is also CSS. Keep cloning the original
474
+ // `<link>` for them so attributes like `media` carry over.
475
+ for (let i = 0; i < orderedChunks.length - 1; i++) {
476
+ siblings.push(buildSibling(orderedChunks[i], "css"));
477
+ }
478
+ } else {
479
+ // CSS chunks are emitted before JS chunks so the cascade is set
480
+ // up before any script runs. Within CSS the order needs to match
481
+ // the source's import order — `entrypoint.chunks` alone doesn't
482
+ // give us that for arbitrary splitChunks layouts (splitChunks
483
+ // inserts each new chunk before the entry chunk via
484
+ // `insertChunk(_, before)`, so split CSS siblings end up in
485
+ // *reverse* of the order they were processed — exactly the
486
+ // html-webpack-plugin#1838 / mini-css-extract#959 symptom). We
487
+ // re-derive the order from the entrypoint's module post-order
488
+ // index, which mirrors the dependency walk and so reflects the
489
+ // import order.
490
+ /** @type {{ chunk: Chunk, index: number }[]} */
491
+ const cssChunkOrder = [];
492
+ /** @type {Chunk[]} */
493
+ const jsChunks = [];
494
+ for (let i = 0; i < orderedChunks.length - 1; i++) {
495
+ const chunk = orderedChunks[i];
496
+ const hasCss = chunkHasCss(chunk, chunkGraph);
497
+ const hasJs = chunkHasJs(chunk, chunkGraph);
498
+ if (hasCss) {
499
+ cssChunkOrder.push({
500
+ chunk,
501
+ index: firstCssModulePostOrderIndex(chunk, entrypoint, chunkGraph)
502
+ });
503
+ }
504
+ // Anything that isn't CSS-only stays on the JS lane, in the
505
+ // `orderedChunks` order — that preserves the runtime-first /
506
+ // vendor-before-entry invariant of `getEntrypointChunksInLoadOrder`.
507
+ // Chunks that produce no `.js` and no `.css` (e.g. wasm-only
508
+ // or asset-only) still get a `<script>` clone here so we
509
+ // keep prior behavior for users who relied on it.
510
+ if (hasJs || !hasCss) jsChunks.push(chunk);
511
+ }
512
+ // If the entry chunk itself contains CSS (entry JS imports CSS
513
+ // without splitChunks separating it), fold it into the same CSS
514
+ // ordering so the entry-chunk `<link>` lands in the correct
515
+ // cascade position relative to sibling CSS chunks.
516
+ if (chunkHasCss(entryChunk, chunkGraph)) {
517
+ cssChunkOrder.push({
518
+ chunk: entryChunk,
519
+ index: firstCssModulePostOrderIndex(
520
+ entryChunk,
521
+ entrypoint,
522
+ chunkGraph
523
+ )
524
+ });
525
+ }
526
+ cssChunkOrder.sort((a, b) => {
527
+ // Direct subtraction would yield `NaN` when both indices are
528
+ // `Infinity` (the documented fallback for chunks whose CSS
529
+ // modules the entrypoint's walk never reaches), and
530
+ // `Array#sort` doesn't promise stable ordering on the legacy
531
+ // Node 10 targets this repo still supports — so the
532
+ // tie-breaker must always run when the indices match,
533
+ // including the `Infinity === Infinity` case.
534
+ if (a.index < b.index) return -1;
535
+ if (a.index > b.index) return 1;
536
+ return compareChunksForCssTieBreak(a.chunk, b.chunk);
537
+ });
538
+ for (const { chunk } of cssChunkOrder) {
539
+ siblings.push(buildSibling(chunk, "css"));
540
+ }
541
+ for (const chunk of jsChunks) {
542
+ siblings.push(buildSibling(chunk, "javascript"));
543
+ }
544
+ }
545
+
546
+ if (siblings.length > 0) {
547
+ source.insert(dep.tagStart, siblings.join(""));
548
+ }
549
+ }
550
+ };
551
+
552
+ makeSerializable(
553
+ HtmlScriptSrcDependency,
554
+ "webpack/lib/dependencies/HtmlScriptSrcDependency"
555
+ );
556
+
557
+ module.exports = HtmlScriptSrcDependency;
@@ -0,0 +1,128 @@
1
+ /*
2
+ MIT License http://www.opensource.org/licenses/mit-license.php
3
+ Author Alexander Akait @alexander-akait
4
+ */
5
+
6
+ "use strict";
7
+
8
+ const { ASSET_URL_TYPE } = require("../ModuleSourceTypeConstants");
9
+ const RawDataUrlModule = require("../asset/RawDataUrlModule");
10
+ const makeSerializable = require("../util/makeSerializable");
11
+ const memoize = require("../util/memoize");
12
+ const ModuleDependency = require("./ModuleDependency");
13
+
14
+ /** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */
15
+ /** @typedef {import("../CodeGenerationResults")} CodeGenerationResults */
16
+ /** @typedef {import("../Dependency")} Dependency */
17
+ /** @typedef {import("../DependencyTemplate").CssDependencyTemplateContext} DependencyTemplateContext */
18
+ /** @typedef {import("../Module")} Module */
19
+ /** @typedef {import("../Module").CodeGenerationResult} CodeGenerationResult */
20
+ /** @typedef {import("../Module").CodeGenerationResultData} CodeGenerationResultData */
21
+ /** @typedef {import("../javascript/JavascriptParser").Range} Range */
22
+ /** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
23
+ /** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
24
+ /** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */
25
+
26
+ const getIgnoredRawDataUrlModule = memoize(
27
+ () => new RawDataUrlModule("data:,", "ignored-asset", "(ignored asset)")
28
+ );
29
+
30
+ class HtmlSourceDependency extends ModuleDependency {
31
+ /**
32
+ * Creates an instance of HtmlSourceDependency.
33
+ * @param {string} request request
34
+ * @param {Range} range range of the argument
35
+ */
36
+ constructor(request, range) {
37
+ super(request);
38
+ this.range = range;
39
+ }
40
+
41
+ get type() {
42
+ return "html source()";
43
+ }
44
+
45
+ get category() {
46
+ return "url";
47
+ }
48
+
49
+ /**
50
+ * Creates an ignored module.
51
+ * @param {string} context context directory
52
+ * @returns {Module} ignored module
53
+ */
54
+ createIgnoredModule(context) {
55
+ return getIgnoredRawDataUrlModule();
56
+ }
57
+
58
+ /**
59
+ * Serializes this instance into the provided serializer context.
60
+ * @param {ObjectSerializerContext} context context
61
+ */
62
+ serialize(context) {
63
+ super.serialize(context);
64
+ }
65
+
66
+ /**
67
+ * Restores this instance from the provided deserializer context.
68
+ * @param {ObjectDeserializerContext} context context
69
+ */
70
+ deserialize(context) {
71
+ super.deserialize(context);
72
+ }
73
+ }
74
+
75
+ HtmlSourceDependency.Template = class HtmlSourceDependencyTemplate extends (
76
+ ModuleDependency.Template
77
+ ) {
78
+ /**
79
+ * Applies the plugin by registering its hooks on the compiler.
80
+ * @param {Dependency} dependency the dependency for which the template should be applied
81
+ * @param {ReplaceSource} source the current replace source which can be modified
82
+ * @param {DependencyTemplateContext} templateContext the context object
83
+ * @returns {void}
84
+ */
85
+ apply(
86
+ dependency,
87
+ source,
88
+ { moduleGraph, runtimeTemplate, codeGenerationResults }
89
+ ) {
90
+ const dep = /** @type {HtmlSourceDependency} */ (dependency);
91
+ const module = /** @type {Module} */ (moduleGraph.getModule(dep));
92
+
93
+ /** @type {string | undefined} */
94
+ const newValue = this.assetUrl({
95
+ module,
96
+ codeGenerationResults
97
+ });
98
+
99
+ source.replace(dep.range[0], dep.range[1] - 1, newValue);
100
+ }
101
+
102
+ /**
103
+ * Returns the url of the asset.
104
+ * @param {object} options options object
105
+ * @param {Module} options.module the module
106
+ * @param {RuntimeSpec=} options.runtime runtime
107
+ * @param {CodeGenerationResults} options.codeGenerationResults the code generation results
108
+ * @returns {string} the url of the asset
109
+ */
110
+ assetUrl({ runtime, module, codeGenerationResults }) {
111
+ if (!module) {
112
+ return "data:,";
113
+ }
114
+ const codeGen = codeGenerationResults.get(module, runtime);
115
+ const data = codeGen.data;
116
+ if (!data) return "data:,";
117
+ const url = data.get("url");
118
+ if (!url || !url[ASSET_URL_TYPE]) return "data:,";
119
+ return url[ASSET_URL_TYPE];
120
+ }
121
+ };
122
+
123
+ makeSerializable(
124
+ HtmlSourceDependency,
125
+ "webpack/lib/dependencies/HtmlSourceDependency"
126
+ );
127
+
128
+ module.exports = HtmlSourceDependency;
@@ -5,7 +5,7 @@
5
5
 
6
6
  "use strict";
7
7
 
8
- const WebpackError = require("../WebpackError");
8
+ const WebpackError = require("../errors/WebpackError");
9
9
  const {
10
10
  evaluateToIdentifier
11
11
  } = require("../javascript/JavascriptParserHelpers");