@depup/webpack 5.110.1-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/ChunkGraph.js +20 -18
- package/lib/CircularModulesPlugin.js +157 -55
- package/lib/CleanPlugin.js +2 -2
- package/lib/CompatibilityPlugin.js +3 -4
- package/lib/Compilation.js +337 -338
- package/lib/Compiler.js +213 -51
- package/lib/ConcatenationScope.js +25 -35
- 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 +64 -40
- package/lib/ErrorHelpers.js +113 -0
- package/lib/ExportsInfo.js +30 -16
- package/lib/ExternalModule.js +47 -22
- package/lib/FileSystemInfo.js +17 -14
- package/lib/FlagDependencyExportsPlugin.js +53 -34
- package/lib/FlagDependencyUsagePlugin.js +17 -15
- 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 +148 -70
- package/lib/NormalModuleFactory.js +1 -1
- package/lib/RuntimeGlobals.js +21 -7
- package/lib/RuntimeModule.js +28 -12
- package/lib/RuntimePlugin.js +33 -3
- package/lib/RuntimeTemplate.js +1147 -847
- 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/async-modules/AsyncModuleHelpers.js +10 -4
- 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 +162 -142
- package/lib/config/getClaimedAssetTypes.js +10 -11
- package/lib/config/normalization.js +100 -20
- 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 +92 -15
- package/lib/css/CssModule.js +1 -1
- package/lib/css/CssModulesPlugin.js +3 -10
- 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 +3526 -871
- package/lib/css/syntax.js +6455 -1237
- 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 +32 -9
- package/lib/dependencies/CommonJsSelfReferenceDependency.js +2 -4
- package/lib/dependencies/ContextDependency.js +1 -1
- package/lib/dependencies/ContextDependencyHelpers.js +3 -9
- package/lib/dependencies/ContextDependencyTemplateAsRequireCall.js +20 -7
- 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/HarmonyEvaluatedImportSpecifierDependency.js +10 -4
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +12 -7
- package/lib/dependencies/HarmonyExportExpressionDependency.js +47 -33
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +217 -34
- 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 +99 -41
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +198 -25
- package/lib/dependencies/HarmonyImportSideEffectDependency.js +117 -4
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +40 -3
- package/lib/dependencies/HarmonyModulesPlugin.js +20 -0
- package/lib/dependencies/HtmlEntryDependency.js +136 -104
- package/lib/dependencies/HtmlInlineScriptDependency.js +3 -4
- package/lib/dependencies/HtmlInlineStyleDependency.js +3 -4
- package/lib/dependencies/ImportContextDependency.js +43 -3
- package/lib/dependencies/ImportDependency.js +8 -29
- 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 +25 -15
- package/lib/dependencies/LoaderPlugin.js +26 -1
- package/lib/dependencies/RequireContextDependencyParserPlugin.js +1 -1
- package/lib/dependencies/RequireHeaderDependency.js +20 -21
- 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 +16 -21
- package/lib/dependencies/WorkerDependency.js +12 -18
- package/lib/dependencies/WorkletDependency.js +12 -20
- package/lib/dependencies/importOptionsCheck.js +47 -0
- 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/DotenvFileError.js +29 -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/ImportedBindingAssignmentError.js +30 -0
- 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 +21 -5
- package/lib/esm/ModuleChunkLoadingRuntimeModule.js +91 -53
- 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 +479 -215
- 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 +2031 -1556
- 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 +76 -80
- 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 +170 -14
- package/lib/node/NodeWatchFileSystem.js +3 -9
- package/lib/node/ReadFileChunkLoadingRuntimeModule.js +22 -0
- package/lib/node/ReadFileCompileAsyncWasmPlugin.js +8 -15
- package/lib/node/RequireChunkLoadingRuntimeModule.js +22 -0
- package/lib/optimize/AggressiveMergingPlugin.js +3 -5
- package/lib/optimize/ConcatenatedModule.js +222 -125
- package/lib/optimize/ConstExportsPlugin.js +50 -34
- package/lib/optimize/FlagIncludedChunksPlugin.js +3 -11
- package/lib/optimize/InlineExports.js +20 -2
- 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 +179 -44
- 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 +29 -35
- 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 +103 -67
- 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 +313 -222
- 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/HttpUriPlugin.js +22 -5
- package/lib/schemes/VirtualUrlPlugin.js +1 -1
- package/lib/serialization/BinaryMiddleware.js +9 -9
- package/lib/serialization/FileMiddleware.js +31 -18
- 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 +10 -13
- package/lib/url/URLParserPlugin.js +6 -8
- package/lib/util/ArrayQueue.js +3 -3
- package/lib/util/LocConverter.js +4 -7
- package/lib/util/SourceProcessor.js +115 -99
- package/lib/util/URLAbsoluteSpecifier.js +3 -1
- 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/conventions.js +5 -1
- package/lib/util/createHooksRegistry.js +1 -2
- package/lib/util/createMappings.js +25 -3
- 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 +7 -1
- package/lib/util/registerExternalSerializer.js +6 -45
- package/lib/util/removeBOM.js +82 -1
- package/lib/util/semver.js +5 -3
- package/lib/wasm-async/AsyncWasmCompileRuntimeModule.js +14 -3
- package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +14 -3
- package/lib/wasm-async/AsyncWebAssemblyGenerator.js +6 -1
- package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +5 -1
- package/lib/wasm-async/UniversalCompileAsyncWasmPlugin.js +7 -12
- 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/FetchCompileAsyncWasmPlugin.js +10 -6
- package/lib/web/FetchCompileWasmPlugin.js +4 -2
- 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 +388 -76
- 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 +1795 -608
- package/lib/dependencies/ExportBindingInitFragment.js +0 -191
- package/lib/errors/EntrypointOverlapWarning.js +0 -45
- package/lib/performance/EntrypointOverlapPlugin.js +0 -122
package/lib/html/data.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"use strict";
|
|
7
7
|
|
|
8
8
|
// GENERATED by tooling/generate-html-data.js — do not edit.
|
|
9
|
-
// cspell:ignore advasoft altglyph altglyphdef altglyphitem animatecolor animatemotion animatetransform arcrole aswedit attributename attributetype basefrequency baseprofile bgsound calcmode clippathunits contenteditable diffuseconstant enterkeyhint fedropshadow filterunits formenctype formmethod formtarget glyphref gradienttransform gradientunits hotjava hotmetal inputmode jscript kernelmatrix kernelunitlength keypoints keysplines keytimes limitingconeangle livescript markerheight markerwidth maskcontentunits maskunits metrius mtext numoctaves pathlength patterncontentunits patterntransform patternunits pointsatx pointsaty pointsatz preservealpha primitiveunits refx refy repeatcount repeatdur requiredextensions requiredfeatures silmaril softquad specularconstant specularexponent startoffset stddeviation stitchtiles surfacescale systemlanguage tablevalues targetx targety textlength viewbox viewtarget webtechs writingsuggestions xchannelselector ychannelselector
|
|
9
|
+
// cspell:ignore advasoft altglyph altglyphdef altglyphitem animatecolor animatemotion animatetransform arcrole aswedit attributename attributetype basefrequency baseprofile bgsound calcmode clippathunits contenteditable diffuseconstant enterkeyhint fedropshadow filterunits formenctype formmethod formtarget glyphref gradienttransform gradientunits hotjava hotmetal inputmode jscript kernelmatrix kernelunitlength keypoints keysplines keytimes limitingconeangle livescript markerheight markerwidth maskcontentunits maskunits metrius mtext numoctaves pathlength patterncontentunits patterntransform patternunits pointsatx pointsaty pointsatz preservealpha primitiveunits refx refy repeatcount repeatdur requiredextensions requiredfeatures silmaril softquad specularconstant specularexponent startoffset stddeviation stitchtiles surfacescale systemlanguage tablevalues targetx targety textlength viewbox viewtarget webtechs writingsuggestions xchannelselector ychannelselector onabort onafterprint onauxclick onbeforeinput onbeforematch onbeforeprint onbeforetoggle onbeforeunload onblur oncancel oncanplay oncanplaythrough onchange onclick onclose oncommand oncontextlost oncontextmenu oncontextrestored oncopy oncuechange oncut ondblclick ondrag ondragend ondragenter ondragleave ondragover ondragstart ondrop ondurationchange onemptied onended onerror onfocus onformdata onhashchange oninput oninvalid onkeydown onkeypress onkeyup onlanguagechange onload onloadeddata onloadedmetadata onloadstart onmessage onmessageerror onmousedown onmouseenter onmouseleave onmousemove onmouseout onmouseover onmouseup onoffline ononline onpagehide onpagereveal onpageshow onpageswap onpaste onpause onplay onplaying onpopstate onprogress onratechange onrejectionhandled onreset onresize onscroll onscrollend onsecuritypolicyviolation onseeked onseeking onselect onslotchange onstalled onstorage onsubmit onsuspend ontimeupdate ontoggle onunhandledrejection onunload onvolumechange onwaiting onwebkitanimationend onwebkitanimationiteration onwebkitanimationstart onwebkittransitionend onwheel
|
|
10
10
|
// Reflected-attribute tables from webref's extraction of the HTML IDL (see tooling/generate-html-data.js); everything else is the
|
|
11
11
|
// generator's SUPPLEMENT, which carries the spec facts no dataset states.
|
|
12
12
|
|
|
@@ -130,6 +130,7 @@ const REWRITABLE_ATTRIBUTES = new Set([
|
|
|
130
130
|
"blocking",
|
|
131
131
|
"cite",
|
|
132
132
|
"class",
|
|
133
|
+
"closedby",
|
|
133
134
|
"codebase",
|
|
134
135
|
"cols",
|
|
135
136
|
"colspan",
|
|
@@ -170,6 +171,7 @@ const REWRITABLE_ATTRIBUTES = new Set([
|
|
|
170
171
|
"part",
|
|
171
172
|
"ping",
|
|
172
173
|
"popover",
|
|
174
|
+
"popovertargetaction",
|
|
173
175
|
"poster",
|
|
174
176
|
"preload",
|
|
175
177
|
"referrerpolicy",
|
|
@@ -178,6 +180,9 @@ const REWRITABLE_ATTRIBUTES = new Set([
|
|
|
178
180
|
"rowspan",
|
|
179
181
|
"sandbox",
|
|
180
182
|
"scope",
|
|
183
|
+
"scrollamount",
|
|
184
|
+
"scrolldelay",
|
|
185
|
+
"shadowrootmode",
|
|
181
186
|
"size",
|
|
182
187
|
"sizes",
|
|
183
188
|
"span",
|
|
@@ -204,6 +209,7 @@ const REWRITABLE_ATTRIBUTES = new Set([
|
|
|
204
209
|
const ENUMERATED_ATTRIBUTE_NAMES = new Set([
|
|
205
210
|
"autocapitalize",
|
|
206
211
|
"autocomplete",
|
|
212
|
+
"closedby",
|
|
207
213
|
"contenteditable",
|
|
208
214
|
"crossorigin",
|
|
209
215
|
"decoding",
|
|
@@ -220,9 +226,11 @@ const ENUMERATED_ATTRIBUTE_NAMES = new Set([
|
|
|
220
226
|
"loading",
|
|
221
227
|
"method",
|
|
222
228
|
"popover",
|
|
229
|
+
"popovertargetaction",
|
|
223
230
|
"preload",
|
|
224
231
|
"referrerpolicy",
|
|
225
232
|
"scope",
|
|
233
|
+
"shadowrootmode",
|
|
226
234
|
"spellcheck",
|
|
227
235
|
"translate",
|
|
228
236
|
"type",
|
|
@@ -330,7 +338,7 @@ const BOOLEAN_ATTRIBUTES = new Map([
|
|
|
330
338
|
["autofocus", null],
|
|
331
339
|
["autoplay", new Set(["audio", "video"])],
|
|
332
340
|
["checked", new Set(["input"])],
|
|
333
|
-
["compact", new Set(["dl", "menu", "ol", "ul"])],
|
|
341
|
+
["compact", new Set(["dir", "dl", "menu", "ol", "ul"])],
|
|
334
342
|
["controls", new Set(["audio", "img", "video"])],
|
|
335
343
|
["declare", new Set(["object"])],
|
|
336
344
|
["default", new Set(["track"])],
|
|
@@ -358,6 +366,7 @@ const BOOLEAN_ATTRIBUTES = new Map([
|
|
|
358
366
|
["muted", new Set(["audio", "video"])],
|
|
359
367
|
["nohref", new Set(["area"])],
|
|
360
368
|
["nomodule", new Set(["script"])],
|
|
369
|
+
["noresize", new Set(["frame"])],
|
|
361
370
|
["noshade", new Set(["hr"])],
|
|
362
371
|
["novalidate", new Set(["form"])],
|
|
363
372
|
["nowrap", new Set(["td", "th"])],
|
|
@@ -369,7 +378,8 @@ const BOOLEAN_ATTRIBUTES = new Map([
|
|
|
369
378
|
["selected", new Set(["option"])],
|
|
370
379
|
["shadowrootclonable", new Set(["template"])],
|
|
371
380
|
["shadowrootdelegatesfocus", new Set(["template"])],
|
|
372
|
-
["shadowrootserializable", new Set(["template"])]
|
|
381
|
+
["shadowrootserializable", new Set(["template"])],
|
|
382
|
+
["truespeed", new Set(["marquee"])]
|
|
373
383
|
]);
|
|
374
384
|
|
|
375
385
|
/**
|
|
@@ -435,7 +445,7 @@ const URL_ATTRIBUTES = new Map([
|
|
|
435
445
|
["data", new Set(["object"])],
|
|
436
446
|
["formaction", new Set(["button", "input"])],
|
|
437
447
|
["href", new Set(["a", "area", "base", "link"])],
|
|
438
|
-
["longdesc", new Set(["iframe", "img"])],
|
|
448
|
+
["longdesc", new Set(["frame", "iframe", "img"])],
|
|
439
449
|
["lowsrc", new Set(["img"])],
|
|
440
450
|
["manifest", new Set(["html"])],
|
|
441
451
|
["poster", new Set(["video"])],
|
|
@@ -444,6 +454,7 @@ const URL_ATTRIBUTES = new Map([
|
|
|
444
454
|
new Set([
|
|
445
455
|
"audio",
|
|
446
456
|
"embed",
|
|
457
|
+
"frame",
|
|
447
458
|
"iframe",
|
|
448
459
|
"img",
|
|
449
460
|
"input",
|
|
@@ -480,17 +491,19 @@ const INTEGER_ATTRIBUTES = new Map([
|
|
|
480
491
|
"video"
|
|
481
492
|
])
|
|
482
493
|
],
|
|
483
|
-
["hspace", new Set(["img", "object"])],
|
|
494
|
+
["hspace", new Set(["img", "marquee", "object"])],
|
|
484
495
|
["maxlength", new Set(["input", "textarea"])],
|
|
485
496
|
["minlength", new Set(["input", "textarea"])],
|
|
486
497
|
["rows", new Set(["textarea"])],
|
|
487
498
|
["rowspan", new Set(["td", "th"])],
|
|
499
|
+
["scrollamount", new Set(["marquee"])],
|
|
500
|
+
["scrolldelay", new Set(["marquee"])],
|
|
488
501
|
["size", new Set(["input", "select"])],
|
|
489
502
|
["span", new Set(["col", "colgroup"])],
|
|
490
503
|
["start", new Set(["ol"])],
|
|
491
504
|
["tabindex", null],
|
|
492
505
|
["value", new Set(["li"])],
|
|
493
|
-
["vspace", new Set(["img", "object"])],
|
|
506
|
+
["vspace", new Set(["img", "marquee", "object"])],
|
|
494
507
|
[
|
|
495
508
|
"width",
|
|
496
509
|
new Set([
|
|
@@ -499,10 +512,12 @@ const INTEGER_ATTRIBUTES = new Map([
|
|
|
499
512
|
"iframe",
|
|
500
513
|
"img",
|
|
501
514
|
"input",
|
|
515
|
+
"listing",
|
|
502
516
|
"object",
|
|
503
517
|
"pre",
|
|
504
518
|
"source",
|
|
505
|
-
"video"
|
|
519
|
+
"video",
|
|
520
|
+
"xmp"
|
|
506
521
|
])
|
|
507
522
|
]
|
|
508
523
|
]);
|
|
@@ -524,6 +539,110 @@ const SIGNED_INTEGER_ATTRIBUTES = new Set(["start", "tabindex", "value"]);
|
|
|
524
539
|
*/
|
|
525
540
|
const COMMA_LIST_ATTRIBUTES = new Set(["accept", "coords", "sizes"]);
|
|
526
541
|
|
|
542
|
+
/**
|
|
543
|
+
* Event handler content attributes, mapped to the elements each is one on
|
|
544
|
+
* (`null` = a global attribute). Elsewhere the same name is an ordinary
|
|
545
|
+
* attribute holding text — `onunload` is a handler on `<body>` and data on a
|
|
546
|
+
* `<div>` — so the value is only read as JavaScript where the table says it is.
|
|
547
|
+
* @type {Map<string, Set<string> | null>}
|
|
548
|
+
*/
|
|
549
|
+
const EVENT_HANDLER_ATTRIBUTES = new Map([
|
|
550
|
+
["onabort", null],
|
|
551
|
+
["onafterprint", new Set(["body", "frameset"])],
|
|
552
|
+
["onauxclick", null],
|
|
553
|
+
["onbeforeinput", null],
|
|
554
|
+
["onbeforematch", null],
|
|
555
|
+
["onbeforeprint", new Set(["body", "frameset"])],
|
|
556
|
+
["onbeforetoggle", null],
|
|
557
|
+
["onbeforeunload", new Set(["body", "frameset"])],
|
|
558
|
+
["onblur", null],
|
|
559
|
+
["oncancel", null],
|
|
560
|
+
["oncanplay", null],
|
|
561
|
+
["oncanplaythrough", null],
|
|
562
|
+
["onchange", null],
|
|
563
|
+
["onclick", null],
|
|
564
|
+
["onclose", null],
|
|
565
|
+
["oncommand", null],
|
|
566
|
+
["oncontextlost", null],
|
|
567
|
+
["oncontextmenu", null],
|
|
568
|
+
["oncontextrestored", null],
|
|
569
|
+
["oncopy", null],
|
|
570
|
+
["oncuechange", null],
|
|
571
|
+
["oncut", null],
|
|
572
|
+
["ondblclick", null],
|
|
573
|
+
["ondrag", null],
|
|
574
|
+
["ondragend", null],
|
|
575
|
+
["ondragenter", null],
|
|
576
|
+
["ondragleave", null],
|
|
577
|
+
["ondragover", null],
|
|
578
|
+
["ondragstart", null],
|
|
579
|
+
["ondrop", null],
|
|
580
|
+
["ondurationchange", null],
|
|
581
|
+
["onemptied", null],
|
|
582
|
+
["onended", null],
|
|
583
|
+
["onerror", null],
|
|
584
|
+
["onfocus", null],
|
|
585
|
+
["onformdata", null],
|
|
586
|
+
["onhashchange", new Set(["body", "frameset"])],
|
|
587
|
+
["oninput", null],
|
|
588
|
+
["oninvalid", null],
|
|
589
|
+
["onkeydown", null],
|
|
590
|
+
["onkeypress", null],
|
|
591
|
+
["onkeyup", null],
|
|
592
|
+
["onlanguagechange", new Set(["body", "frameset"])],
|
|
593
|
+
["onload", null],
|
|
594
|
+
["onloadeddata", null],
|
|
595
|
+
["onloadedmetadata", null],
|
|
596
|
+
["onloadstart", null],
|
|
597
|
+
["onmessage", new Set(["body", "frameset"])],
|
|
598
|
+
["onmessageerror", new Set(["body", "frameset"])],
|
|
599
|
+
["onmousedown", null],
|
|
600
|
+
["onmouseenter", null],
|
|
601
|
+
["onmouseleave", null],
|
|
602
|
+
["onmousemove", null],
|
|
603
|
+
["onmouseout", null],
|
|
604
|
+
["onmouseover", null],
|
|
605
|
+
["onmouseup", null],
|
|
606
|
+
["onoffline", new Set(["body", "frameset"])],
|
|
607
|
+
["ononline", new Set(["body", "frameset"])],
|
|
608
|
+
["onpagehide", new Set(["body", "frameset"])],
|
|
609
|
+
["onpagereveal", new Set(["body", "frameset"])],
|
|
610
|
+
["onpageshow", new Set(["body", "frameset"])],
|
|
611
|
+
["onpageswap", new Set(["body", "frameset"])],
|
|
612
|
+
["onpaste", null],
|
|
613
|
+
["onpause", null],
|
|
614
|
+
["onplay", null],
|
|
615
|
+
["onplaying", null],
|
|
616
|
+
["onpopstate", new Set(["body", "frameset"])],
|
|
617
|
+
["onprogress", null],
|
|
618
|
+
["onratechange", null],
|
|
619
|
+
["onrejectionhandled", new Set(["body", "frameset"])],
|
|
620
|
+
["onreset", null],
|
|
621
|
+
["onresize", null],
|
|
622
|
+
["onscroll", null],
|
|
623
|
+
["onscrollend", null],
|
|
624
|
+
["onsecuritypolicyviolation", null],
|
|
625
|
+
["onseeked", null],
|
|
626
|
+
["onseeking", null],
|
|
627
|
+
["onselect", null],
|
|
628
|
+
["onslotchange", null],
|
|
629
|
+
["onstalled", null],
|
|
630
|
+
["onstorage", new Set(["body", "frameset"])],
|
|
631
|
+
["onsubmit", null],
|
|
632
|
+
["onsuspend", null],
|
|
633
|
+
["ontimeupdate", null],
|
|
634
|
+
["ontoggle", null],
|
|
635
|
+
["onunhandledrejection", new Set(["body", "frameset"])],
|
|
636
|
+
["onunload", new Set(["body", "frameset"])],
|
|
637
|
+
["onvolumechange", null],
|
|
638
|
+
["onwaiting", null],
|
|
639
|
+
["onwebkitanimationend", null],
|
|
640
|
+
["onwebkitanimationiteration", null],
|
|
641
|
+
["onwebkitanimationstart", null],
|
|
642
|
+
["onwebkittransitionend", null],
|
|
643
|
+
["onwheel", null]
|
|
644
|
+
]);
|
|
645
|
+
|
|
527
646
|
/**
|
|
528
647
|
* §13.1.2 void elements: no end tag, and no children to close one over.
|
|
529
648
|
* @type {Set<string>}
|
|
@@ -1654,8 +1773,12 @@ const ENUMERATED_KEYWORDS = Object.assign(Object.create(null), {
|
|
|
1654
1773
|
"text/plain"
|
|
1655
1774
|
]),
|
|
1656
1775
|
formmethod: new Set(["get", "post", "dialog"]),
|
|
1776
|
+
popovertargetaction: new Set(["toggle", "show", "hide"]),
|
|
1657
1777
|
type: new Set(["submit", "reset", "button"])
|
|
1658
1778
|
}),
|
|
1779
|
+
dialog: Object.assign(Object.create(null), {
|
|
1780
|
+
closedby: new Set(["any", "closerequest", "none"])
|
|
1781
|
+
}),
|
|
1659
1782
|
form: Object.assign(Object.create(null), {
|
|
1660
1783
|
autocomplete: new Set(["on", "off"]),
|
|
1661
1784
|
enctype: new Set([
|
|
@@ -1681,6 +1804,7 @@ const ENUMERATED_KEYWORDS = Object.assign(Object.create(null), {
|
|
|
1681
1804
|
"text/plain"
|
|
1682
1805
|
]),
|
|
1683
1806
|
formmethod: new Set(["get", "post", "dialog"]),
|
|
1807
|
+
popovertargetaction: new Set(["toggle", "show", "hide"]),
|
|
1684
1808
|
type: new Set([
|
|
1685
1809
|
"hidden",
|
|
1686
1810
|
"text",
|
|
@@ -1717,6 +1841,9 @@ const ENUMERATED_KEYWORDS = Object.assign(Object.create(null), {
|
|
|
1717
1841
|
td: Object.assign(Object.create(null), {
|
|
1718
1842
|
scope: new Set(["row", "col", "rowgroup", "colgroup"])
|
|
1719
1843
|
}),
|
|
1844
|
+
template: Object.assign(Object.create(null), {
|
|
1845
|
+
shadowrootmode: new Set(["open", "closed"])
|
|
1846
|
+
}),
|
|
1720
1847
|
th: Object.assign(Object.create(null), {
|
|
1721
1848
|
scope: new Set(["row", "col", "rowgroup", "colgroup"])
|
|
1722
1849
|
}),
|
|
@@ -1735,6 +1862,12 @@ const ENUMERATED_KEYWORDS = Object.assign(Object.create(null), {
|
|
|
1735
1862
|
})
|
|
1736
1863
|
});
|
|
1737
1864
|
|
|
1865
|
+
/**
|
|
1866
|
+
* `<element> <attribute>` for each enumerated attribute whose invalid value default names a different state from its missing value default, so a value matching no keyword may not be dropped as redundant.
|
|
1867
|
+
* @type {Set<string>}
|
|
1868
|
+
*/
|
|
1869
|
+
const INVALID_VALUE_DEFAULT_DIFFERS = new Set(["track kind"]);
|
|
1870
|
+
|
|
1738
1871
|
/**
|
|
1739
1872
|
* Elements `removeEmptyElements` never drops: with no children and no attributes each is still doing its job, so an empty one is not a leftover.
|
|
1740
1873
|
* @type {Set<string>}
|
|
@@ -1863,6 +1996,7 @@ module.exports.EMPTY_METADATA_ELEMENTS = EMPTY_METADATA_ELEMENTS;
|
|
|
1863
1996
|
module.exports.EMPTY_REMOVABLE_ATTRIBUTES = EMPTY_REMOVABLE_ATTRIBUTES;
|
|
1864
1997
|
module.exports.ENUMERATED_ATTRIBUTE_NAMES = ENUMERATED_ATTRIBUTE_NAMES;
|
|
1865
1998
|
module.exports.ENUMERATED_KEYWORDS = ENUMERATED_KEYWORDS;
|
|
1999
|
+
module.exports.EVENT_HANDLER_ATTRIBUTES = EVENT_HANDLER_ATTRIBUTES;
|
|
1866
2000
|
module.exports.FONT_BREAKOUT_ATTRS = FONT_BREAKOUT_ATTRS;
|
|
1867
2001
|
module.exports.FOREIGN_ATTR_NS = FOREIGN_ATTR_NS;
|
|
1868
2002
|
module.exports.FOREIGN_BREAKOUT = FOREIGN_BREAKOUT;
|
|
@@ -1877,6 +2011,7 @@ module.exports.IGNORED_BODY_TABLE_STARTS = IGNORED_BODY_TABLE_STARTS;
|
|
|
1877
2011
|
module.exports.IMPLIED = IMPLIED;
|
|
1878
2012
|
module.exports.IMPLIED_THOROUGH = IMPLIED_THOROUGH;
|
|
1879
2013
|
module.exports.INTEGER_ATTRIBUTES = INTEGER_ATTRIBUTES;
|
|
2014
|
+
module.exports.INVALID_VALUE_DEFAULT_DIFFERS = INVALID_VALUE_DEFAULT_DIFFERS;
|
|
1880
2015
|
module.exports.IN_HEAD_NOSCRIPT_PASSTHROUGH = IN_HEAD_NOSCRIPT_PASSTHROUGH;
|
|
1881
2016
|
module.exports.IN_TABLE_IGNORED_ENDS = IN_TABLE_IGNORED_ENDS;
|
|
1882
2017
|
module.exports.JAVASCRIPT_SCRIPT_TYPES = JAVASCRIPT_SCRIPT_TYPES;
|
package/lib/html/htmlMinify.js
CHANGED
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
|
|
6
6
|
"use strict";
|
|
7
7
|
|
|
8
|
-
/** @import {
|
|
8
|
+
/** @import { HtmlPrintOptions } from "../html/syntax" */
|
|
9
|
+
/** @import { CssEnvironment } from "../css/syntax" */
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* What a renderer made of one embedded body: the minified text, and anything it
|
|
@@ -32,9 +33,9 @@
|
|
|
32
33
|
* imported at module scope: `minimizer-webpack-plugin` ships this function to its
|
|
33
34
|
* worker pool as source (a top-level import wouldn't survive), and `require("webpack")`
|
|
34
35
|
* re-resolves in the worker — via the installed package, or the dev self-link.
|
|
35
|
-
* @param {{ [file: string]: string }} input a single `{ filename: code }` entry
|
|
36
|
+
* @param {{ [file: string]: string | Buffer }} input a single `{ filename: code }` entry; a `Buffer` is read as UTF-8
|
|
36
37
|
* @param {(RawSourceMap | undefined)=} sourceMap input source map (unused: safe serialize keeps positions token-coarse, so no map is produced yet)
|
|
37
|
-
* @param {Omit<HtmlPrintOptions, "renderEmbeddedSource" | "deferEmbeddedSource"> & { css?: { convertLengthUnits?: boolean, rewriteCustomProperties?: boolean
|
|
38
|
+
* @param {Omit<HtmlPrintOptions, "renderEmbeddedSource" | "deferEmbeddedSource"> & { environment?: CssEnvironment, css?: { convertLengthUnits?: boolean, rewriteCustomProperties?: boolean, unusedSymbols?: string[], pseudoClasses?: { [name: string]: string } }, minifyConditionalComments?: boolean, renderEmbeddedSource?: AsyncEmbeddedSourceRenderer }=} minimizerOptions minimizer options — `environment` and `css` (`optimization.minimize.css`, whole) reach the CSS minifier this runs over inline CSS; the rest is `optimization.minimize.html`. The two stand apart rather than merged: both languages name a `quotes` and a `comments`, and one flat object would hand each the other's answer. `renderEmbeddedSource` minifies source this document embeds and may be asynchronous — one parse serves both it and the output. What it declines this minifies itself, for the languages webpack ships a minifier for
|
|
38
39
|
* @returns {Promise<{ code: string, warnings?: (Error | string)[], errors?: (Error | string)[] }>} the minified HTML, and what a renderer reported over what it embeds
|
|
39
40
|
*/
|
|
40
41
|
const htmlMinify = async (input, sourceMap, minimizerOptions = {}) => {
|
|
@@ -43,21 +44,18 @@ const htmlMinify = async (input, sourceMap, minimizerOptions = {}) => {
|
|
|
43
44
|
require(/** @type {string} */ ("webpack"))
|
|
44
45
|
);
|
|
45
46
|
|
|
46
|
-
// TODO widen the value rewrites the switches below name: a boolean attribute
|
|
47
|
-
// spelled any other way than its own name, an enumerated value the spec does
|
|
48
|
-
// not name.
|
|
49
47
|
const {
|
|
50
48
|
askEmbeddedRenderer,
|
|
49
|
+
builtinEmbeddedRenderer,
|
|
51
50
|
collectEmbeddedDiagnostics,
|
|
52
51
|
embeddedText,
|
|
53
52
|
SourceProcessor,
|
|
54
53
|
NodeType,
|
|
55
|
-
NS_HTML,
|
|
56
|
-
decodeEntities,
|
|
57
|
-
escapeAttribute,
|
|
58
54
|
pickTransforms
|
|
59
55
|
} = webpack.html.syntax;
|
|
60
|
-
const [[,
|
|
56
|
+
const [[, given]] = Object.entries(input);
|
|
57
|
+
// The plugin hands a text minifier a string; the type admits an image's bytes.
|
|
58
|
+
const code = typeof given === "string" ? given : given.toString("utf8");
|
|
61
59
|
// The nested CSS minifier gets the abilities and options a `.css` asset
|
|
62
60
|
// gets, or the inline copy of a declaration would disagree with it.
|
|
63
61
|
const {
|
|
@@ -65,37 +63,39 @@ const htmlMinify = async (input, sourceMap, minimizerOptions = {}) => {
|
|
|
65
63
|
css = {},
|
|
66
64
|
collapseWhitespace,
|
|
67
65
|
mergeStyles,
|
|
66
|
+
mergeScripts,
|
|
68
67
|
removeEmptyAttributes,
|
|
69
68
|
removeEmptyElements,
|
|
70
69
|
removeRedundantAttributes,
|
|
71
70
|
minifyConditionalComments,
|
|
72
|
-
minifySrcdoc,
|
|
73
71
|
sortAttributes,
|
|
74
72
|
sortTokenLists,
|
|
75
73
|
removeImpliedTags,
|
|
76
74
|
renderEmbeddedSource
|
|
77
75
|
} = minimizerOptions;
|
|
78
|
-
// A `<iframe srcdoc>` the pre-pass below owns is not offered, or the same
|
|
79
|
-
// document would be minified twice — once each, and the pre-pass keeps the
|
|
80
|
-
// delimiter and reaches a value written bare, which the printer cannot.
|
|
81
|
-
const ownsSrcdoc = Boolean(minifySrcdoc);
|
|
82
76
|
// One list for the whole run: a nested document reaches this same collector,
|
|
83
77
|
// so what a renderer reports inside an `<iframe srcdoc>` is reported once at
|
|
84
78
|
// the top rather than lost at the level that heard it.
|
|
85
79
|
/** @type {EmbeddedSourceResult[]} */
|
|
86
80
|
const reported = [];
|
|
81
|
+
// Webpack's own renderer, handed the CSS minifier's options so an inline
|
|
82
|
+
// declaration agrees with the `.css` asset; each language picks its switches.
|
|
83
|
+
const builtin = builtinEmbeddedRenderer({
|
|
84
|
+
environment,
|
|
85
|
+
convertLengthUnits: css.convertLengthUnits,
|
|
86
|
+
rewriteCustomProperties: css.rewriteCustomProperties,
|
|
87
|
+
unusedSymbols: css.unusedSymbols,
|
|
88
|
+
pseudoClasses: css.pseudoClasses,
|
|
89
|
+
transforms: webpack.css.syntax.pickTransforms(css)
|
|
90
|
+
});
|
|
87
91
|
// One set of options, handed to the document pass and to each conditional
|
|
88
92
|
// comment's body below.
|
|
89
93
|
const printOptions = {
|
|
90
94
|
mode: /** @type {"minify"} */ ("minify"),
|
|
91
|
-
environment,
|
|
92
|
-
convertLengthUnits: css.convertLengthUnits,
|
|
93
|
-
rewriteCustomProperties: css.rewriteCustomProperties,
|
|
94
|
-
// Each language picks its own switches out of its own options object.
|
|
95
|
-
cssTransforms: webpack.css.syntax.pickTransforms(css),
|
|
96
95
|
transforms: pickTransforms(minimizerOptions),
|
|
97
96
|
collapseWhitespace,
|
|
98
97
|
mergeStyles,
|
|
98
|
+
mergeScripts,
|
|
99
99
|
removeEmptyAttributes,
|
|
100
100
|
removeEmptyElements,
|
|
101
101
|
removeRedundantAttributes,
|
|
@@ -103,35 +103,56 @@ const htmlMinify = async (input, sourceMap, minimizerOptions = {}) => {
|
|
|
103
103
|
sortTokenLists,
|
|
104
104
|
removeImpliedTags
|
|
105
105
|
};
|
|
106
|
-
// Handed each body the print offers,
|
|
107
|
-
//
|
|
108
|
-
//
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
106
|
+
// Handed each body the print offers, keeping what it reported: the element or
|
|
107
|
+
// attribute around one is written from that answer, and a body declined or
|
|
108
|
+
// thrown on is spelled as an untapped run spells it.
|
|
109
|
+
|
|
110
|
+
// A caller's renderer is asked first; whatever it declines this minifies
|
|
111
|
+
// itself, for the languages webpack ships a minifier for.
|
|
112
|
+
const renderer = async (
|
|
113
|
+
/** @type {string} */ source,
|
|
114
|
+
/** @type {EXPECTED_ANY} */ hole
|
|
115
|
+
) => {
|
|
116
|
+
if (renderEmbeddedSource !== undefined) {
|
|
117
|
+
const answered = embeddedText(
|
|
118
|
+
await askEmbeddedRenderer(renderEmbeddedSource, hole, reported)
|
|
119
|
+
);
|
|
120
|
+
|
|
121
|
+
if (typeof answered === "string") return answered;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// Webpack's own answers for what the caller's left: CSS and JSON, and a
|
|
125
|
+
// nested document, which is a document minified the same way.
|
|
126
|
+
const own = builtin(source, hole);
|
|
127
|
+
if (own !== undefined) return own;
|
|
128
|
+
return hole.type === "html" ? minifyDocument(source) : undefined;
|
|
129
|
+
};
|
|
116
130
|
/**
|
|
117
131
|
* @param {string} text a whole document
|
|
118
132
|
* @returns {Promise<string>} the same document, printed
|
|
119
133
|
*/
|
|
120
|
-
const printDocument = async (text) =>
|
|
121
|
-
|
|
134
|
+
const printDocument = async (text) => {
|
|
135
|
+
// The built-in renderer is synchronous, so with no caller's renderer only
|
|
136
|
+
// a nested document needs the async pass — and no `srcdoc`, none is there.
|
|
137
|
+
if (renderEmbeddedSource === undefined && !/srcdoc/i.test(text)) {
|
|
138
|
+
return new SourceProcessor().process(text, {
|
|
139
|
+
...printOptions,
|
|
140
|
+
renderEmbeddedSource: builtin
|
|
141
|
+
}).code;
|
|
142
|
+
}
|
|
143
|
+
return (
|
|
122
144
|
await new SourceProcessor().processAsync(text, {
|
|
123
145
|
...printOptions,
|
|
124
|
-
// The pre-pass below minifies the document an `<iframe srcdoc>` holds,
|
|
125
|
-
// so one is not offered here as well.
|
|
126
|
-
deferSrcdoc: !ownsSrcdoc,
|
|
127
146
|
renderEmbeddedSource: renderer
|
|
128
147
|
})
|
|
129
148
|
).code;
|
|
149
|
+
};
|
|
130
150
|
|
|
131
151
|
// Recursion goes through this local name, never the module's own: the plugin
|
|
132
152
|
// ships this function to its workers as source, where that binding is absent.
|
|
133
|
-
|
|
134
|
-
//
|
|
153
|
+
|
|
154
|
+
// A marker cannot cross a parse, the preprocessor turning its NUL into U+FFFD,
|
|
155
|
+
// so each nested document is finished before it is spliced in.
|
|
135
156
|
/**
|
|
136
157
|
* @param {string} text a whole document
|
|
137
158
|
* @returns {Promise<string>} the same document, minified
|
|
@@ -140,94 +161,49 @@ const htmlMinify = async (input, sourceMap, minimizerOptions = {}) => {
|
|
|
140
161
|
// Put back into the source, not the output: the printer respells an
|
|
141
162
|
// attribute value, so the recorded text is not what the output holds.
|
|
142
163
|
let source = text;
|
|
143
|
-
//
|
|
144
|
-
// located in
|
|
145
|
-
// `srcdoc` is an attribute value and a conditional comment's body is a
|
|
146
|
-
// comment, neither of which this parse reads as markup.
|
|
147
|
-
const wantsSrcdoc = Boolean(minifySrcdoc) && /srcdoc\s*=/i.test(source);
|
|
164
|
+
// A conditional comment's body is markup this parse cannot start a second
|
|
165
|
+
// one over, so each is located in a walk and spliced afterwards.
|
|
148
166
|
const wantsConditional =
|
|
149
167
|
Boolean(minifyConditionalComments) && /<!--\[if\s/i.test(source);
|
|
150
168
|
|
|
151
|
-
if (
|
|
152
|
-
/** @type {{ start: number, end: number,
|
|
169
|
+
if (wantsConditional) {
|
|
170
|
+
/** @type {{ start: number, end: number, value: string }[]} */
|
|
153
171
|
const found = [];
|
|
154
172
|
/** @type {{ [type: number]: (path: EXPECTED_ANY) => void }} */
|
|
155
173
|
const visitors = {};
|
|
156
174
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
if (path.tagName() !== "iframe" || path.namespace() !== NS_HTML) {
|
|
162
|
-
return;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
for (const attribute of path.attributes()) {
|
|
166
|
-
if (attribute.name !== "srcdoc" || attribute.value === "") continue;
|
|
167
|
-
|
|
168
|
-
found.push({
|
|
169
|
-
start: attribute.valueStart,
|
|
170
|
-
end: attribute.valueEnd,
|
|
171
|
-
srcdoc: true,
|
|
172
|
-
value: attribute.value
|
|
173
|
-
});
|
|
174
|
-
}
|
|
175
|
-
};
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
if (wantsConditional) {
|
|
179
|
-
visitors[NodeType.Comment] = (path) => {
|
|
180
|
-
const comment = path.source();
|
|
181
|
-
const opened = comment.indexOf("]>");
|
|
182
|
-
const closes = comment.lastIndexOf("<![endif]");
|
|
175
|
+
visitors[NodeType.Comment] = (path) => {
|
|
176
|
+
const comment = path.source();
|
|
177
|
+
const opened = comment.indexOf("]>");
|
|
178
|
+
const closes = comment.lastIndexOf("<![endif]");
|
|
183
179
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
180
|
+
if (
|
|
181
|
+
!/^<!--\[if\s/i.test(comment) ||
|
|
182
|
+
opened === -1 ||
|
|
183
|
+
closes <= opened
|
|
184
|
+
) {
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
191
187
|
|
|
192
|
-
|
|
193
|
-
|
|
188
|
+
const start = path.start() + opened + 2;
|
|
189
|
+
const end = path.start() + closes;
|
|
194
190
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
};
|
|
202
|
-
}
|
|
191
|
+
found.push({
|
|
192
|
+
start,
|
|
193
|
+
end,
|
|
194
|
+
value: comment.slice(opened + 2, closes)
|
|
195
|
+
});
|
|
196
|
+
};
|
|
203
197
|
|
|
204
198
|
new SourceProcessor().use(visitors).process(source, {});
|
|
205
|
-
// An element's attributes are visited where the element is, so the two
|
|
206
|
-
// kinds do not arrive interleaved by position on their own.
|
|
207
|
-
found.sort((a, b) => a.start - b.start);
|
|
208
199
|
|
|
209
200
|
// Back to front, so an earlier splice does not move a later range.
|
|
210
201
|
for (let i = found.length - 1; i >= 0; i--) {
|
|
211
|
-
const { start, end,
|
|
202
|
+
const { start, end, value } = found[i];
|
|
212
203
|
// Sequential: a later splice must not move an earlier range.
|
|
204
|
+
const inner = await minifyDocument(value);
|
|
213
205
|
|
|
214
|
-
|
|
215
|
-
srcdoc ? decodeEntities(value, true) : value
|
|
216
|
-
);
|
|
217
|
-
let written = inner;
|
|
218
|
-
|
|
219
|
-
if (srcdoc) {
|
|
220
|
-
// A document is not something an unquoted value can hold — a space
|
|
221
|
-
// or a `>` in it would end the attribute — so one written bare gets
|
|
222
|
-
// quotes.
|
|
223
|
-
const delimiter = source.charCodeAt(start - 1);
|
|
224
|
-
const quoted = delimiter === 34 || delimiter === 39;
|
|
225
|
-
const escaped = escapeAttribute(inner, quoted ? delimiter : 34, true);
|
|
226
|
-
|
|
227
|
-
written = quoted ? escaped : `"${escaped}"`;
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
source = `${source.slice(0, start)}${written}${source.slice(end)}`;
|
|
206
|
+
source = `${source.slice(0, start)}${inner}${source.slice(end)}`;
|
|
231
207
|
}
|
|
232
208
|
}
|
|
233
209
|
// `process` parses once, and with `mode: "minify"` its walk also prints the
|
|
@@ -255,30 +231,24 @@ htmlMinify.getTypes = () => ["html"];
|
|
|
255
231
|
|
|
256
232
|
/**
|
|
257
233
|
* The languages this can offer a caller through `renderEmbeddedSource` — an
|
|
258
|
-
* inline `<style>`, a `<script>`,
|
|
259
|
-
*
|
|
260
|
-
* `style=""`
|
|
261
|
-
* reading the minified text back, so it stays with the built-in CSS minifier,
|
|
262
|
-
* which is webpack's own `cssMinify`.
|
|
263
|
-
* @param {{ minifySrcdoc?: boolean }=} minimizerOptions the options this will run with
|
|
234
|
+
* inline `<style>`, a `<script>`, every event handler attribute (as the
|
|
235
|
+
* function body it is), an `<svg>` subtree and the document an
|
|
236
|
+
* `<iframe srcdoc>` holds, and every `style=""` as the block's contents it is.
|
|
264
237
|
* @returns {string[]} the languages
|
|
265
238
|
*/
|
|
266
|
-
htmlMinify.getEmbeddedTypes = (
|
|
239
|
+
htmlMinify.getEmbeddedTypes = () => {
|
|
267
240
|
/** @type {string[]} */
|
|
268
241
|
const languages =
|
|
269
242
|
/** @type {typeof import("../index")} */
|
|
270
243
|
// eslint-disable-next-line import/no-extraneous-dependencies -- webpack self-require, as the body does
|
|
271
244
|
require(/** @type {string} */ ("webpack")).html.syntax.EMBEDDED_LANGUAGES;
|
|
272
245
|
|
|
273
|
-
return
|
|
274
|
-
? languages.filter((language) => language !== "html")
|
|
275
|
-
: languages;
|
|
246
|
+
return languages;
|
|
276
247
|
};
|
|
277
248
|
|
|
278
|
-
//
|
|
279
|
-
//
|
|
280
|
-
//
|
|
281
|
-
// plugin / worker pool.
|
|
249
|
+
// Sharing one `minimizer-webpack-plugin` instance, each asset reaches only the
|
|
250
|
+
// minify functions whose `filter` accepts it. This claims HTML, so terser and
|
|
251
|
+
// cssMinify coexist with it in one worker pool.
|
|
282
252
|
/**
|
|
283
253
|
* @param {string} name asset filename
|
|
284
254
|
* @returns {boolean} true for HTML assets
|