/* MIT License http://www.opensource.org/licenses/mit-license.php Author sheo13666q @sheo13666q */ "use strict"; /** @import { DeferredEmbeddedSource, HtmlPrintOptions } from "../html/syntax" */ /** * What a renderer made of one embedded body: the minified text, and anything it * has to report about it. A bare string is the text alone. * @typedef {{ code?: string, warnings?: (Error | string)[], errors?: (Error | string)[] }} EmbeddedSourceResult */ /** * Minifies source a document embeds; may answer asynchronously. * @typedef {(source: string, info: { type: string, hostType: string, as?: string }) => Promise | string | EmbeddedSourceResult | undefined} AsyncEmbeddedSourceRenderer */ /** @import { RawSourceMap } from "webpack-sources" */ /** * A `minify` function for `minimizer-webpack-plugin` (passed as its `minify` * option): safely serializes one HTML asset's minimized form. Every node is * rebuilt from its parsed form to the same DOM (text whitespace and attribute * values preserved); the transforms are dropping inert comments (conditional / * SSI comments are kept) and rewriting opening tags to their shortest equivalent * spelling. HTML minification thus reuses that plugin's pipeline — caching and * worker-thread parallelization. * * The parser is read from the public `webpack.html.syntax` API inside the body, not * imported at module scope: `minimizer-webpack-plugin` ships this function to its * worker pool as source (a top-level import wouldn't survive), and `require("webpack")` * re-resolves in the worker — via the installed package, or the dev self-link. * @param {{ [file: string]: string }} input a single `{ filename: code }` entry * @param {(RawSourceMap | undefined)=} sourceMap input source map (unused: safe serialize keeps positions token-coarse, so no map is produced yet) * @param {Omit & { css?: { convertLengthUnits?: boolean, rewriteCustomProperties?: boolean }, minifyConditionalComments?: boolean, minifySrcdoc?: 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 — and `minifySrcdoc` takes an `