@depup/webpack 5.110.3-depup.0 → 5.111.1-depup.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.
- package/README.md +7 -8
- package/changes.json +7 -11
- package/lib/APIPlugin.js +26 -11
- package/lib/AutomaticPrefetchPlugin.js +1 -1
- package/lib/Cache.js +8 -3
- package/lib/CacheFacade.js +1 -1
- package/lib/CircularModulesPlugin.js +157 -55
- package/lib/CleanPlugin.js +2 -2
- package/lib/CompatibilityPlugin.js +3 -4
- package/lib/Compilation.js +336 -337
- package/lib/Compiler.js +213 -51
- package/lib/ConstPlugin.js +16 -132
- package/lib/CopyPlugin.js +1054 -0
- package/lib/DefinePlugin.js +24 -8
- package/lib/DependencyTemplate.js +2 -1
- package/lib/DotenvPlugin.js +24 -28
- package/lib/ErrorHelpers.js +113 -0
- package/lib/ExportsInfo.js +20 -16
- package/lib/ExternalModule.js +47 -22
- package/lib/FileSystemInfo.js +17 -14
- package/lib/FlagDependencyExportsPlugin.js +53 -34
- package/lib/FlagDependencyUsagePlugin.js +9 -13
- package/lib/Generator.js +24 -2
- package/lib/HotModuleReplacementPlugin.js +55 -7
- package/lib/IgnorePlugin.js +1 -1
- package/lib/JavascriptMetaInfoPlugin.js +5 -3
- package/lib/LoaderOptionsPlugin.js +1 -1
- package/lib/MainTemplate.js +5 -1
- package/lib/Module.js +19 -10
- package/lib/ModuleGraph.js +6 -9
- package/lib/MultiCompiler.js +7 -17
- package/lib/MultiWatching.js +1 -1
- package/lib/NormalModule.js +135 -50
- package/lib/NormalModuleFactory.js +1 -1
- package/lib/RuntimeGlobals.js +21 -7
- package/lib/RuntimeModule.js +28 -12
- package/lib/RuntimePlugin.js +30 -3
- package/lib/RuntimeTemplate.js +813 -518
- package/lib/SourceMapDevToolPlugin.js +54 -104
- package/lib/TemplatedPathPlugin.js +16 -59
- package/lib/Watching.js +9 -0
- package/lib/WebpackOptionsApply.js +84 -91
- package/lib/asset/AssetBytesGenerator.js +7 -1
- package/lib/asset/AssetGenerator.js +50 -24
- package/lib/asset/AssetModule.js +3 -0
- package/lib/asset/AssetSourceGenerator.js +7 -1
- package/lib/asset/WebManifestParser.js +7 -5
- package/lib/buildChunkGraph.js +11 -15
- package/lib/cache/AddBuildDependenciesPlugin.js +33 -4
- package/lib/cache/IdleFileCachePlugin.js +2 -2
- package/lib/cache/MemoryCachePlugin.js +4 -4
- package/lib/cache/MemoryWithGcCachePlugin.js +7 -8
- package/lib/cache/PackFileCacheStrategy.js +17 -19
- package/lib/cache/getLazyHashedEtag.js +3 -5
- package/lib/config/browserslistTargetHandler.js +17 -4
- package/lib/config/defaults.js +138 -128
- package/lib/config/getClaimedAssetTypes.js +10 -11
- package/lib/config/normalization.js +82 -12
- package/lib/config/target.js +13 -4
- package/lib/container/ContainerReferencePlugin.js +6 -0
- package/lib/container/RemoteRuntimeModule.js +9 -0
- package/lib/container/declaredRemotes.js +39 -0
- package/lib/{ContextExclusionPlugin.js → context/ContextExclusionPlugin.js} +1 -1
- package/lib/{ContextModule.js → context/ContextModule.js} +54 -115
- package/lib/{ContextModuleFactory.js → context/ContextModuleFactory.js} +19 -21
- package/lib/{ContextReplacementPlugin.js → context/ContextReplacementPlugin.js} +4 -4
- package/lib/css/CssGenerator.js +27 -11
- package/lib/css/CssInjectStyleRuntimeModule.js +9 -0
- package/lib/css/CssLoadingRuntimeModule.js +94 -36
- package/lib/css/CssModule.js +1 -1
- package/lib/css/CssModulesPlugin.js +7 -6
- package/lib/css/CssParser.js +162 -31
- package/lib/css/CssServerStylesRuntimeModule.js +9 -0
- package/lib/css/cssMinify.js +43 -32
- package/lib/css/data.js +3514 -869
- package/lib/css/syntax.js +6370 -1220
- package/lib/debug/ProfilingPlugin.js +7 -4
- package/lib/dependencies/AMDDefineDependencyParserPlugin.js +6 -3
- package/lib/dependencies/AMDRuntimeModules.js +18 -0
- package/lib/dependencies/CommonJsExportRequireDependency.js +13 -12
- package/lib/dependencies/CommonJsExportsParserPlugin.js +12 -13
- package/lib/dependencies/CommonJsImportsParserPlugin.js +5 -5
- package/lib/dependencies/CommonJsPlugin.js +19 -3
- package/lib/dependencies/CommonJsRequireDependency.js +14 -5
- package/lib/dependencies/CommonJsSelfReferenceDependency.js +2 -4
- package/lib/dependencies/ContextDependency.js +1 -1
- package/lib/dependencies/ContextDependencyHelpers.js +3 -9
- package/lib/dependencies/ContextElementDependency.js +1 -1
- package/lib/dependencies/CssIcssExportDependency.js +13 -9
- package/lib/dependencies/CssIcssImportDependency.js +3 -6
- package/lib/dependencies/CssUrlDependency.js +3 -5
- package/lib/dependencies/HarmonyCompatibilityDependency.js +67 -22
- package/lib/dependencies/HarmonyDetectionParserPlugin.js +3 -4
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +10 -7
- package/lib/dependencies/HarmonyExportExpressionDependency.js +47 -33
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +74 -17
- package/lib/dependencies/HarmonyExportInitFragment.js +110 -23
- package/lib/dependencies/HarmonyExportSpecifierDependency.js +25 -58
- package/lib/dependencies/HarmonyImportBareSideEffectDependency.js +59 -0
- package/lib/dependencies/HarmonyImportDependency.js +6 -1
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +111 -17
- package/lib/dependencies/HarmonyImportSideEffectDependency.js +3 -4
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +40 -3
- package/lib/dependencies/HarmonyModulesPlugin.js +20 -0
- package/lib/dependencies/HtmlEntryDependency.js +124 -102
- package/lib/dependencies/HtmlInlineScriptDependency.js +3 -4
- package/lib/dependencies/HtmlInlineStyleDependency.js +3 -4
- package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +1 -1
- package/lib/dependencies/ImportMetaGlobHelpers.js +1 -1
- package/lib/dependencies/ImportMetaMainDependency.js +104 -0
- package/lib/dependencies/ImportMetaPlugin.js +67 -25
- package/lib/dependencies/ImportParserPlugin.js +1 -1
- package/lib/dependencies/LoaderPlugin.js +26 -1
- package/lib/dependencies/RequireContextDependencyParserPlugin.js +1 -1
- package/lib/dependencies/SystemRuntimeModule.js +9 -0
- package/lib/dependencies/URLContextDependency.js +1 -1
- package/lib/dependencies/URLDependency.js +6 -5
- package/lib/dependencies/WorkerAndWorkletPlugin.js +15 -21
- package/lib/dependencies/WorkerDependency.js +7 -7
- package/lib/dependencies/WorkletDependency.js +7 -11
- package/lib/dll/DelegatedModule.js +18 -1
- package/lib/dll/DllReferencePlugin.js +11 -8
- package/lib/dll/LibManifestPlugin.js +1 -1
- package/lib/errors/AnalyzableBailoutsWarning.js +41 -0
- package/lib/errors/DuplicateModulesWarning.js +12 -7
- package/lib/errors/EmptyCopyPatternWarning.js +26 -0
- package/lib/errors/ExternalStarReexportError.js +44 -0
- package/lib/errors/HookWebpackError.js +3 -2
- package/lib/errors/MissingSourceMapsWarning.js +36 -0
- package/lib/errors/ModuleParseError.js +2 -1
- package/lib/errors/UnusedAssetsWarning.js +36 -0
- package/lib/errors/UnusedFederationWarning.js +35 -0
- package/lib/errors/UnusedModulesWarning.js +38 -0
- package/lib/esm/ExportWebpackRequireRuntimeModule.js +9 -0
- package/lib/esm/ModuleChunkFormatPlugin.js +28 -3
- package/lib/esm/ModuleChunkLoadingPlugin.js +30 -11
- package/lib/esm/ModuleChunkLoadingRuntimeModule.js +92 -60
- package/lib/hmr/HotModuleReplacement.runtime.js +8 -2
- package/lib/hmr/HotModuleReplacementRuntimeModule.js +9 -0
- package/lib/hmr/LazyCompilationPlugin.js +3 -5
- package/lib/html/HtmlGenerator.js +72 -87
- package/lib/html/HtmlModulesPlugin.js +418 -200
- package/lib/html/HtmlParser.js +110 -147
- package/lib/html/builtinEmbeddedRenderer.js +107 -0
- package/lib/html/data.js +142 -7
- package/lib/html/htmlMinify.js +92 -122
- package/lib/html/syntax.js +1618 -1391
- package/lib/ids/HashedModuleIdsPlugin.js +2 -1
- package/lib/index.js +49 -3
- package/lib/javascript/ChunkFormatHelpers.js +4 -3
- package/lib/javascript/JavascriptGenerator.js +8 -1
- package/lib/javascript/JavascriptModule.js +1 -0
- package/lib/javascript/JavascriptModulesPlugin.js +73 -72
- package/lib/javascript/JavascriptParser.js +1970 -900
- package/lib/javascript/StartupHelpers.js +27 -3
- package/lib/javascript/data.js +172 -0
- package/lib/javascript/grammar.js +5546 -0
- package/lib/javascript/parser.js +1500 -0
- package/lib/javascript/regexp.js +1762 -0
- package/lib/javascript/regexpData.js +51 -0
- package/lib/javascript/syntax.js +9061 -5262
- package/lib/json/JsonGenerator.js +7 -1
- package/lib/library/ModuleLibraryPlugin.js +171 -132
- package/lib/loaders/LoaderRunner.js +137 -9
- package/lib/node/NodeWatchFileSystem.js +3 -9
- package/lib/node/ReadFileChunkLoadingRuntimeModule.js +22 -0
- package/lib/node/RequireChunkLoadingRuntimeModule.js +22 -0
- package/lib/optimize/AggressiveMergingPlugin.js +3 -5
- package/lib/optimize/ConcatenatedModule.js +178 -120
- package/lib/optimize/ConstExportsPlugin.js +50 -39
- package/lib/optimize/FlagIncludedChunksPlugin.js +3 -11
- package/lib/optimize/InlineExports.js +20 -123
- package/lib/optimize/InnerGraphPlugin.js +7 -13
- package/lib/optimize/LimitChunkCountPlugin.js +5 -8
- package/lib/optimize/MangleExportsPlugin.js +13 -4
- package/lib/optimize/ModuleConcatenationPlugin.js +27 -5
- package/lib/optimize/RealContentHashPlugin.js +68 -9
- package/lib/optimize/SideEffectsFlagPlugin.js +24 -28
- package/lib/optimize/SplitChunksPlugin.js +2 -4
- package/lib/performance/AnalyzableBailoutsPlugin.js +115 -0
- package/lib/performance/BroadContextsPlugin.js +1 -1
- package/lib/performance/CacheEffectivenessPlugin.js +7 -7
- package/lib/performance/DuplicateModulesPlugin.js +57 -13
- package/lib/performance/EvalUsagePlugin.js +5 -2
- package/lib/performance/MissingSourceMapsPlugin.js +115 -0
- package/lib/performance/PureAnnotationsPlugin.js +6 -3
- package/lib/performance/SizeLimitsPlugin.js +2 -4
- package/lib/performance/TopLevelThisPlugin.js +5 -4
- package/lib/performance/UnusedAssetsPlugin.js +109 -0
- package/lib/performance/UnusedFederationPlugin.js +147 -0
- package/lib/performance/UnusedModulesPlugin.js +141 -0
- package/lib/performance/UnusedReexportsPlugin.js +1 -55
- package/lib/performance/isOnlyReexported.js +65 -0
- package/lib/prefetch/ChunkPrefetchFunctionRuntimeModule.js +25 -5
- package/lib/prefetch/ChunkPrefetchPreloadPlugin.js +8 -8
- package/lib/prefetch/ChunkPrefetchStartupRuntimeModule.js +9 -0
- package/lib/prefetch/ChunkPrefetchTriggerRuntimeModule.js +9 -0
- package/lib/prefetch/ChunkPreloadTriggerRuntimeModule.js +9 -0
- package/lib/prefetch/ResourceHintPlugin.js +18 -23
- package/lib/prefetch/ResourceHintRuntimeModule.js +9 -0
- package/lib/prefetch/StartupAssetHintRuntimeModule.js +16 -10
- package/lib/rules/RuleSetCompiler.js +211 -4
- package/lib/runtime/AsyncModuleRuntimeModule.js +98 -66
- package/lib/runtime/AutoPublicPathRuntimeModule.js +9 -0
- package/lib/runtime/BaseUriRuntimeModule.js +9 -0
- package/lib/runtime/ChunkNameRuntimeModule.js +9 -0
- package/lib/runtime/EnsureChunkRuntimeModule.js +35 -16
- package/lib/runtime/GetChunkFilenameRuntimeModule.js +12 -4
- package/lib/runtime/GetFullHashRuntimeModule.js +9 -0
- package/lib/runtime/GetMainFilenameRuntimeModule.js +9 -0
- package/lib/runtime/GetWorkletBootstrapRuntimeModule.js +9 -0
- package/lib/runtime/GlobalRuntimeModule.js +11 -4
- package/lib/runtime/HasOwnPropertyRuntimeModule.js +9 -0
- package/lib/runtime/HelperRuntimeModule.js +10 -0
- package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +305 -224
- package/lib/runtime/NonceRuntimeModule.js +9 -0
- package/lib/runtime/OnChunksLoadedRuntimeModule.js +67 -20
- package/lib/runtime/PublicPathRuntimeModule.js +9 -0
- package/lib/runtime/RuntimeIdRuntimeModule.js +9 -0
- package/lib/runtime/SpecNamespaceObjectRuntimeModule.js +90 -0
- package/lib/runtime/StartupChunkDependenciesRuntimeModule.js +9 -0
- package/lib/runtime/StartupEntrypointRuntimeModule.js +9 -0
- package/lib/runtime/SystemContextRuntimeModule.js +9 -0
- package/lib/runtime/ToBinaryRuntimeModule.js +9 -0
- package/lib/schemes/DataUriPlugin.js +3 -6
- package/lib/schemes/VirtualUrlPlugin.js +1 -1
- package/lib/serialization/BinaryMiddleware.js +9 -9
- package/lib/serialization/FileMiddleware.js +16 -16
- package/lib/serialization/ObjectMiddleware.js +168 -139
- package/lib/sharing/ConsumeSharedPlugin.js +12 -0
- package/lib/sharing/ConsumeSharedRuntimeModule.js +11 -0
- package/lib/sharing/ShareRuntimeModule.js +9 -0
- package/lib/sharing/declaredShared.js +47 -0
- package/lib/stats/DefaultStatsFactoryPlugin.js +6 -5
- package/lib/stats/DefaultStatsPrinterPlugin.js +3 -0
- package/lib/typescript/TypeScriptPlugin.js +2 -3
- package/lib/url/URLParserPlugin.js +6 -8
- package/lib/util/LocConverter.js +4 -7
- package/lib/util/SourceProcessor.js +91 -91
- package/lib/util/async.js +292 -0
- package/lib/util/buildDiagnostics.js +69 -0
- package/lib/util/chainedImports.js +3 -4
- package/lib/util/concatenate.js +4 -4
- package/lib/util/createHooksRegistry.js +1 -2
- package/lib/util/dataURL.js +2 -3
- package/lib/util/deterministicGrouping.js +8 -13
- package/lib/util/findGraphRoots.js +6 -13
- package/lib/util/fs.js +27 -1
- package/lib/util/globUtils.js +1 -1
- package/lib/util/handlerKeys.js +40 -0
- package/lib/util/hash/wasm-hash.js +3 -4
- package/lib/util/identifier.js +20 -0
- package/lib/util/internalSerializables.js +5 -1
- package/lib/util/registerExternalSerializer.js +6 -45
- package/lib/util/semver.js +5 -3
- package/lib/wasm-async/AsyncWasmCompileRuntimeModule.js +9 -0
- package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +9 -0
- package/lib/wasm-async/AsyncWebAssemblyGenerator.js +6 -1
- package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +5 -1
- package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +12 -4
- package/lib/wasm-sync/WebAssemblyGenerator.js +6 -1
- package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +5 -1
- package/lib/wasm-sync/WebAssemblyUtils.js +2 -4
- package/lib/web/JsonpChunkLoadingRuntimeModule.js +36 -0
- package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +19 -0
- package/package.json +55 -46
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +379 -66
- package/schemas/plugins/LoaderOptionsPlugin.check.js +1 -1
- package/schemas/plugins/ManifestPlugin.check.js +1 -1
- package/schemas/plugins/SourceMapDevToolPlugin.check.js +1 -1
- package/schemas/plugins/asset/AssetGeneratorOptions.check.js +1 -1
- package/schemas/plugins/asset/AssetResourceGeneratorOptions.check.js +1 -1
- package/schemas/plugins/container/ContainerPlugin.check.js +1 -1
- package/schemas/plugins/container/ModuleFederationPlugin.check.js +1 -1
- package/schemas/plugins/debug/ProfilingPlugin.check.js +1 -1
- package/schemas/plugins/dll/DllReferencePlugin.check.js +1 -1
- package/schemas/plugins/ids/HashedModuleIdsPlugin.check.js +1 -1
- package/schemas/plugins/schemes/HttpUriPlugin.check.js +1 -1
- package/types.d.ts +1723 -604
- package/lib/dependencies/ExportBindingInitFragment.js +0 -191
- package/lib/errors/EntrypointOverlapWarning.js +0 -45
- package/lib/performance/EntrypointOverlapPlugin.js +0 -122
|
@@ -335,11 +335,9 @@ class LazyCompilationProxyModule extends Module {
|
|
|
335
335
|
block.addDependency(dep);
|
|
336
336
|
this.addBlock(block);
|
|
337
337
|
} else if (hasClosureLibrary(compilation.options.output)) {
|
|
338
|
-
// Reserve statically
|
|
339
|
-
//
|
|
340
|
-
//
|
|
341
|
-
// Once the proxy activates and the lazily-built module references those
|
|
342
|
-
// externals, the identifiers resolve normally instead of throwing.
|
|
338
|
+
// Reserve the statically declared externals on the inactive proxy, so the
|
|
339
|
+
// entry chunk's library wrapper already exposes their closure identifiers
|
|
340
|
+
// and they resolve rather than throw once the proxy activates.
|
|
343
341
|
const requests = collectStaticExternalRequests(
|
|
344
342
|
options.externals,
|
|
345
343
|
this.layer
|
|
@@ -9,6 +9,7 @@ const ConcatenationScope = require("../ConcatenationScope");
|
|
|
9
9
|
const Generator = require("../Generator");
|
|
10
10
|
const {
|
|
11
11
|
HTML_TYPE,
|
|
12
|
+
HTML_TYPES,
|
|
12
13
|
JAVASCRIPT_TYPE,
|
|
13
14
|
JAVASCRIPT_TYPES
|
|
14
15
|
} = require("../ModuleSourceTypeConstants");
|
|
@@ -225,12 +226,9 @@ const CHUNK_URL_SENTINEL_REGEXP =
|
|
|
225
226
|
const HTML_PAGE_URL_SENTINEL_REGEXP =
|
|
226
227
|
/__WEBPACK_HTML_PAGE_URL__([0-9a-f]+)__END__/g;
|
|
227
228
|
|
|
228
|
-
// Sentinel for a URL-referenced asset
|
|
229
|
-
//
|
|
230
|
-
//
|
|
231
|
-
// HtmlEntry deps run *while* the HTML module is being codegen'd — the asset
|
|
232
|
-
// module's own codegen might not have completed yet. Keyed by the asset
|
|
233
|
-
// module's identifier, hex-encoded so any character in it is safe in a URL.
|
|
229
|
+
// Sentinel for a URL-referenced asset in a resource-hint `<link>`, resolved at
|
|
230
|
+
// `HtmlModulesPlugin` render because HtmlEntry deps run while the HTML module
|
|
231
|
+
// is codegen'd, before the asset's own. Keyed by hex-encoded identifier.
|
|
234
232
|
const ASSET_URL_SENTINEL_REGEXP =
|
|
235
233
|
/__WEBPACK_HTML_ASSET_URL__([0-9a-f]+)__END__/g;
|
|
236
234
|
|
|
@@ -239,11 +237,9 @@ const ASSET_URL_SENTINEL_REGEXP =
|
|
|
239
237
|
/** @type {WeakSet<Compilation>} */
|
|
240
238
|
const integritySentinelCompilations = new WeakSet();
|
|
241
239
|
|
|
242
|
-
// Matches the whole ` integrity="<sentinel>"
|
|
243
|
-
//
|
|
244
|
-
//
|
|
245
|
-
// optional and back-referenced to keep the pair matched; the replacement always
|
|
246
|
-
// re-quotes, since an SRI list carries spaces and `=` padding.
|
|
240
|
+
// Matches the whole ` integrity="<sentinel>"`, so the attribute can be dropped
|
|
241
|
+
// when the per-asset `integrity` returns `false`. Minification runs first and
|
|
242
|
+
// may have unquoted it, hence the optional back-referenced quote.
|
|
247
243
|
const INTEGRITY_SENTINEL_REGEXP =
|
|
248
244
|
/ integrity=(["']?)__WEBPACK_HTML_INTEGRITY__([0-9a-f]+)__([a-z]+)__END__\1/g;
|
|
249
245
|
|
|
@@ -252,10 +248,9 @@ const INTEGRITY_SENTINEL_REGEXP =
|
|
|
252
248
|
const INTEGRITY_SENTINEL_STRIP_REGEXP =
|
|
253
249
|
/ integrity=(\\?["']|)__WEBPACK_HTML_INTEGRITY__[0-9a-f]+__[a-z]+__END__\1/g;
|
|
254
250
|
|
|
255
|
-
// The trailing `(?:__<hash>)?` is the inlined chunk's content hash, embedded
|
|
256
|
-
//
|
|
257
|
-
//
|
|
258
|
-
// resolver ignores it.
|
|
251
|
+
// The trailing `(?:__<hash>)?` is the inlined chunk's content hash, embedded so
|
|
252
|
+
// the host page's bytes and `[contenthash]` change with the inlined content.
|
|
253
|
+
// The resolver ignores it.
|
|
259
254
|
const INLINE_SENTINEL_REGEXP =
|
|
260
255
|
/__WEBPACK_HTML_INLINE__([0-9a-f]+)__([a-z]+)(?:__[0-9a-f]+)?__END__/g;
|
|
261
256
|
|
|
@@ -448,12 +443,9 @@ class HtmlGenerator extends Generator {
|
|
|
448
443
|
const url =
|
|
449
444
|
/** @type {Record<string, string | undefined> | undefined} */
|
|
450
445
|
(data.get("url"));
|
|
451
|
-
// Prefer the `asset-url` channel
|
|
452
|
-
//
|
|
453
|
-
//
|
|
454
|
-
// `__webpack_require__.p + "…"`); for those we reconstruct the URL
|
|
455
|
-
// from the emitted `filename` + `PUBLIC_PATH_AUTO` so the same
|
|
456
|
-
// undo-path substitution runs at asset render.
|
|
446
|
+
// Prefer the `asset-url` channel, which is the real URL string. An asset
|
|
447
|
+
// reached only from JS has none — its URL is a JS expression — so rebuild
|
|
448
|
+
// one from `filename` and let the undo-path substitution run.
|
|
457
449
|
if (url && url["asset-url"]) return url["asset-url"];
|
|
458
450
|
const filename = /** @type {string | undefined} */ (data.get("filename"));
|
|
459
451
|
if (filename) return `${PUBLIC_PATH_AUTO}${filename}`;
|
|
@@ -692,10 +684,9 @@ class HtmlGenerator extends Generator {
|
|
|
692
684
|
bodyDepth++;
|
|
693
685
|
}
|
|
694
686
|
},
|
|
695
|
-
// Collected on exit
|
|
696
|
-
// closes
|
|
697
|
-
//
|
|
698
|
-
// exiting keeps them in source order.
|
|
687
|
+
// Collected on exit, since an element's `end` is final only once it
|
|
688
|
+
// closes. `script`, `style`, `link` and `meta` never nest in each
|
|
689
|
+
// other, so exiting keeps them in source order.
|
|
699
690
|
exit: (path) => {
|
|
700
691
|
const name = path.tagName();
|
|
701
692
|
if (name === "head") {
|
|
@@ -1047,19 +1038,19 @@ class HtmlGenerator extends Generator {
|
|
|
1047
1038
|
* Creates an instance of HtmlGenerator.
|
|
1048
1039
|
* @param {HtmlGeneratorOptions=} options generator options
|
|
1049
1040
|
* @param {ModuleGraph=} moduleGraph the module graph; used to detect when an HTML module is reached as a compilation entry so `extract` can default to `true` for it
|
|
1041
|
+
* @param {((module: NormalModule) => boolean)=} isPageOnly tells whether the module's only output is its emitted page, so it exposes no JavaScript
|
|
1050
1042
|
*/
|
|
1051
|
-
constructor(options, moduleGraph) {
|
|
1043
|
+
constructor(options, moduleGraph, isPageOnly) {
|
|
1052
1044
|
super();
|
|
1053
1045
|
/** @type {HtmlGeneratorOptions} */
|
|
1054
1046
|
this.options = options || {};
|
|
1055
1047
|
/** @type {ModuleGraph | undefined} */
|
|
1056
1048
|
this._moduleGraph = moduleGraph;
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
//
|
|
1060
|
-
//
|
|
1061
|
-
// so
|
|
1062
|
-
// and releases with it. The two passes differ only in `undoPath`.
|
|
1049
|
+
/** @type {((module: NormalModule) => boolean) | undefined} */
|
|
1050
|
+
this._isPageOnly = isPageOnly;
|
|
1051
|
+
// Raw render shared between the JS and HTML passes of one `codeGeneration()`
|
|
1052
|
+
// call, which differ only in `undoPath`. Keyed by that call's
|
|
1053
|
+
// `runtimeRequirements` Set, so the entry is scoped to it and releases with it.
|
|
1063
1054
|
/** @type {WeakMap<RuntimeRequirements, string>} */
|
|
1064
1055
|
this._rawRenderCache = new WeakMap();
|
|
1065
1056
|
}
|
|
@@ -1071,11 +1062,9 @@ class HtmlGenerator extends Generator {
|
|
|
1071
1062
|
* @returns {string | undefined} reason why this module can't be concatenated, undefined when it can be concatenated
|
|
1072
1063
|
*/
|
|
1073
1064
|
getConcatenationBailoutReason(module, context) {
|
|
1074
|
-
// The HMR shim references the per-module `module.hot
|
|
1075
|
-
//
|
|
1076
|
-
//
|
|
1077
|
-
// would target the wrong module id. Bail out of concatenation so the
|
|
1078
|
-
// HMR-aware HTML module keeps its own module scope.
|
|
1065
|
+
// The HMR shim references the per-module `module.hot`, and a concatenated
|
|
1066
|
+
// file shares one `module`, so the self-accept wiring would target the wrong
|
|
1067
|
+
// id. Bail out, keeping the module's own scope.
|
|
1079
1068
|
if (module.hot) {
|
|
1080
1069
|
return "HTML module needs its own module scope for HMR";
|
|
1081
1070
|
}
|
|
@@ -1134,6 +1123,9 @@ class HtmlGenerator extends Generator {
|
|
|
1134
1123
|
*/
|
|
1135
1124
|
getTypes(module) {
|
|
1136
1125
|
if (this._shouldExposeHtmlType(module)) {
|
|
1126
|
+
// A page nothing else reads has no JavaScript side: that chunk would
|
|
1127
|
+
// only re-export the markup already emitted as the `.html` asset.
|
|
1128
|
+
if (this._isPageOnly && this._isPageOnly(module)) return HTML_TYPES;
|
|
1137
1129
|
return JAVASCRIPT_AND_HTML_TYPES;
|
|
1138
1130
|
}
|
|
1139
1131
|
return JAVASCRIPT_TYPES;
|
|
@@ -1143,10 +1135,9 @@ class HtmlGenerator extends Generator {
|
|
|
1143
1135
|
* @returns {boolean} whether getTypes() depends on the module's incoming connections
|
|
1144
1136
|
*/
|
|
1145
1137
|
getTypesDependOnIncomingConnections() {
|
|
1146
|
-
//
|
|
1147
|
-
//
|
|
1148
|
-
|
|
1149
|
-
return extract !== true && extract !== false && extract !== "inline";
|
|
1138
|
+
// Every page that can expose the html type reads incoming connections —
|
|
1139
|
+
// for the `extract` default, and for the page-only JavaScript drop.
|
|
1140
|
+
return this.options.extract !== false;
|
|
1150
1141
|
}
|
|
1151
1142
|
|
|
1152
1143
|
/**
|
|
@@ -1272,10 +1263,9 @@ class HtmlGenerator extends Generator {
|
|
|
1272
1263
|
* @returns {string} the rewritten HTML
|
|
1273
1264
|
*/
|
|
1274
1265
|
_renderHtml(module, generateContext, undoPath) {
|
|
1275
|
-
//
|
|
1276
|
-
//
|
|
1277
|
-
//
|
|
1278
|
-
// passes diverge only in the `[webpack/auto]` substitution below.
|
|
1266
|
+
// No dependency template branches on `type` or writes
|
|
1267
|
+
// `runtimeRequirements`, so the raw render is computed once per
|
|
1268
|
+
// `codeGeneration()`; the passes diverge only in the substitution below.
|
|
1279
1269
|
const cacheKey = generateContext.runtimeRequirements;
|
|
1280
1270
|
let rawContent = this._rawRenderCache.get(cacheKey);
|
|
1281
1271
|
if (rawContent === undefined) {
|
|
@@ -1339,11 +1329,9 @@ class HtmlGenerator extends Generator {
|
|
|
1339
1329
|
|
|
1340
1330
|
/** @type {string} */
|
|
1341
1331
|
let sourceContent;
|
|
1342
|
-
// `module.hot`
|
|
1343
|
-
//
|
|
1344
|
-
//
|
|
1345
|
-
// would target the wrong id) — `getConcatenationBailoutReason` keeps
|
|
1346
|
-
// us out of concatenation in that case.
|
|
1332
|
+
// `module.hot` marks HMR being enabled, and concatenation merges into a
|
|
1333
|
+
// parent's scope where `module.hot.accept` would target the wrong id.
|
|
1334
|
+
// `getConcatenationBailoutReason` keeps such a module out of it.
|
|
1347
1335
|
if (generateContext.concatenationScope && !module.hot) {
|
|
1348
1336
|
generateContext.concatenationScope.registerNamespaceExport(
|
|
1349
1337
|
ConcatenationScope.NAMESPACE_OBJECT_EXPORT
|
|
@@ -1417,15 +1405,11 @@ class HtmlGenerator extends Generator {
|
|
|
1417
1405
|
const acceptBlock = extracting
|
|
1418
1406
|
? [
|
|
1419
1407
|
"module.hot.accept();",
|
|
1420
|
-
//
|
|
1421
|
-
//
|
|
1422
|
-
//
|
|
1423
|
-
//
|
|
1424
|
-
//
|
|
1425
|
-
// `<body>`/`</body>`/`<title>` inside a comment can no
|
|
1426
|
-
// longer fool the tag regexes (the non-greedy `*?` would
|
|
1427
|
-
// otherwise stop at the FIRST `</body>` it sees, even one
|
|
1428
|
-
// inside a comment).
|
|
1408
|
+
// WHY: a `</body>` inside a comment stops the non-greedy `*?` at the
|
|
1409
|
+
// wrong place, so comments are masked before any tag regex runs.
|
|
1410
|
+
// Masking rather than deleting keeps offsets stable, so the body and
|
|
1411
|
+
// title can still be sliced out of the original HTML with their
|
|
1412
|
+
// comments intact.
|
|
1429
1413
|
`${declare} __webpack_mask_comments__ = ${runtimeTemplate.returningFunction(
|
|
1430
1414
|
`h.replace(/<!--[\\s\\S]*?-->/g, ${runtimeTemplate.returningFunction(
|
|
1431
1415
|
'c.replace(/[^\\n]/g, " ")',
|
|
@@ -1469,9 +1453,8 @@ class HtmlGenerator extends Generator {
|
|
|
1469
1453
|
]
|
|
1470
1454
|
)};`,
|
|
1471
1455
|
// A `<script>` parsed out of a string carries the already-started flag,
|
|
1472
|
-
// so appending
|
|
1473
|
-
//
|
|
1474
|
-
// replaces would have done.
|
|
1456
|
+
// so appending it would never run. A fresh one with the same attributes
|
|
1457
|
+
// and body does, as the reload this replaces would have.
|
|
1475
1458
|
`${declare} __webpack_revive_script__ = ${runtimeTemplate.basicFunction(
|
|
1476
1459
|
"node",
|
|
1477
1460
|
[
|
|
@@ -1487,11 +1470,9 @@ class HtmlGenerator extends Generator {
|
|
|
1487
1470
|
"return script;"
|
|
1488
1471
|
]
|
|
1489
1472
|
)};`,
|
|
1490
|
-
// Apply only the difference between the two authored heads
|
|
1491
|
-
//
|
|
1492
|
-
//
|
|
1493
|
-
// tear them down while a delta never touches them. Reports whether it
|
|
1494
|
-
// could — the caller reloads when it could not.
|
|
1473
|
+
// Apply only the difference between the two authored heads: the
|
|
1474
|
+
// runtime's own injected tags are in neither string, so replacing
|
|
1475
|
+
// `document.head` wholesale would tear them down where a delta cannot.
|
|
1495
1476
|
`${declare} __webpack_patch_head__ = ${runtimeTemplate.basicFunction(
|
|
1496
1477
|
"oldHtml, newHtml",
|
|
1497
1478
|
[
|
|
@@ -1527,14 +1508,12 @@ class HtmlGenerator extends Generator {
|
|
|
1527
1508
|
`${declare} removed = surplus(oldChildren, newChildren);`,
|
|
1528
1509
|
`${declare} added = surplus(newChildren, oldChildren);`,
|
|
1529
1510
|
"if (removed.length === 0 && added.length === 0) return true;",
|
|
1530
|
-
//
|
|
1531
|
-
//
|
|
1532
|
-
// `type` that is neither a JavaScript MIME
|
|
1533
|
-
// `importmap`
|
|
1534
|
-
//
|
|
1535
|
-
//
|
|
1536
|
-
// Every JavaScript MIME essence ends in `script`, and a type
|
|
1537
|
-
// nothing here recognizes falls back to the reload.
|
|
1511
|
+
// WHY: a script that has run cannot be un-run, so dropping one is the
|
|
1512
|
+
// single edit still worth a reload — but only a script that ran. A
|
|
1513
|
+
// `type` that is neither a JavaScript MIME essence, all of which end
|
|
1514
|
+
// in `script`, nor `module`, `importmap` or `speculationrules` is a
|
|
1515
|
+
// data block the browser never executed, as safe to remove as a
|
|
1516
|
+
// `<meta>`. An unrecognized type falls back to the reload.
|
|
1538
1517
|
`if (removed.some(${runtimeTemplate.basicFunction("node", [
|
|
1539
1518
|
'if (node.nodeName !== "SCRIPT") return false;',
|
|
1540
1519
|
`${declare} type = (node.getAttribute("type") || "").trim().toLowerCase();`,
|
|
@@ -1558,11 +1537,9 @@ class HtmlGenerator extends Generator {
|
|
|
1558
1537
|
]),
|
|
1559
1538
|
"}",
|
|
1560
1539
|
`for (${mutable} i = 0; i < live.length; i++) document.head.removeChild(live[i]);`,
|
|
1561
|
-
// Pair each retained element with its live node, scanning
|
|
1562
|
-
//
|
|
1563
|
-
//
|
|
1564
|
-
// cannot express falls back to the reload. Injected nodes simply
|
|
1565
|
-
// never match, so they neither anchor nor block anything.
|
|
1540
|
+
// Pair each retained element with its live node, scanning forward
|
|
1541
|
+
// only: a moved element then finds no match and falls back to the
|
|
1542
|
+
// reload, while an injected node never matches either way.
|
|
1566
1543
|
`${declare} liveByNew = [];`,
|
|
1567
1544
|
`${mutable} searchFrom = 0;`,
|
|
1568
1545
|
`for (${mutable} i = 0; i < newChildren.length; i++) {`,
|
|
@@ -1642,13 +1619,22 @@ class HtmlGenerator extends Generator {
|
|
|
1642
1619
|
*/
|
|
1643
1620
|
generateError(error, module, generateContext) {
|
|
1644
1621
|
if (generateContext.type === HTML_TYPE) {
|
|
1645
|
-
// Strip `<`, `>`, `--` runs from
|
|
1646
|
-
const safe =
|
|
1622
|
+
// Strip `<`, `>`, `--` runs from the message so it can't escape the comment.
|
|
1623
|
+
const safe = Generator.buildErrorMessage(
|
|
1624
|
+
error,
|
|
1625
|
+
generateContext.runtimeTemplate.requestShortener
|
|
1626
|
+
)
|
|
1647
1627
|
.replace(/[<>]/g, "")
|
|
1648
1628
|
.replace(/-{2,}/g, (m) => `${"-".repeat(m.length - 1)} `);
|
|
1649
1629
|
return new RawSource(`<!-- webpack error: ${safe} -->`);
|
|
1650
1630
|
}
|
|
1651
|
-
return new RawSource(
|
|
1631
|
+
return new RawSource(
|
|
1632
|
+
Generator.throwBuildErrorCode(
|
|
1633
|
+
error,
|
|
1634
|
+
undefined,
|
|
1635
|
+
generateContext.runtimeTemplate.requestShortener
|
|
1636
|
+
)
|
|
1637
|
+
);
|
|
1652
1638
|
}
|
|
1653
1639
|
|
|
1654
1640
|
/**
|
|
@@ -1658,10 +1644,9 @@ class HtmlGenerator extends Generator {
|
|
|
1658
1644
|
*/
|
|
1659
1645
|
updateHash(hash, updateHashContext) {
|
|
1660
1646
|
hash.update("html");
|
|
1661
|
-
//
|
|
1662
|
-
// `extracting` branch
|
|
1663
|
-
//
|
|
1664
|
-
// One `_shouldExtract` walk covers both checks (expose = extract ∪ inline).
|
|
1647
|
+
// The source-type set turns on html-type exposure and the HMR shim's
|
|
1648
|
+
// `extracting` branch on the emit decision. They differ only for
|
|
1649
|
+
// `"inline"`, which exposes html without emitting, so hash both.
|
|
1665
1650
|
const extract = this._shouldExtract(updateHashContext.module);
|
|
1666
1651
|
if (extract || this.options.extract === "inline") {
|
|
1667
1652
|
hash.update("html-type");
|