Repository navigation
Commit 78aaae3
authored
test: hold EMBEDDED_LANGUAGES to the sites that offer it (#21936)
* test: hold EMBEDDED_LANGUAGES to the sites that offer it
Both lists say a caller reads them to know which languages it handles, so
each entry needs a live offer site behind it and nothing may arrive that
the list does not name. Neither direction was checked: a language added
with no site, or a site removed, showed up only as an unexplained snapshot
diff somewhere else.
One document and one stylesheet reach every site, and each test asserts the
offered set against the exported list, then that the renderer's answer is
what the serialization carries — being offered a body is only half of
minifying it.
* test: shorten the new comments to the test-file convention
* test: bundle every embedded body a host can nest
The offer sites were covered one level deep and in plain text. Three gaps,
each now a real build:
- A `data:` payload reached through base64 is decoded, minified and encoded
back as base64. Only a declined `image/png;base64` was covered before.
- A nested body nests bodies of its own: SVG through the CSS in an inline
`<style>` and again through a `style` attribute, and CSS through the
document an `<iframe srcdoc>` holds.
- An `asset/inline` module is minified for every language a minimizer
claims, not only CSS and SVG.
* test: shorten the copied comment to the test-file convention
* test: fold the embedded config cases back into one
* test: cover the embedded surface in one case
Every shape a host and a nested body can take, in one build each:
- A document webpack parses as an entry, one it parses as a module, and one
it only emits — each with an inline `<style>`, a `style` attribute, a
`<script>`, a JSON `<script>`, an `<svg>` subtree and an `<iframe srcdoc>`
carrying its own `<style>`, and each `<style>` carrying a `data:` SVG two
levels down. Only the emitted-only document keeps its `<script>` inline,
so it alone reaches a JavaScript minimizer there.
- A stylesheet's `url()` payload in every language a media type names, plain
and base64, plus an `image/png` naming none.
- Every `exportType`: the one that emits a stylesheet, the one that exports
its text, and the two that inject it — those last on a target whose
runtime works without a document.
- An `asset/source` and an `asset/inline` module of every language.
* test: type the shared minimizer helper as an array
* test: offer every embedded language in both configs
The second config carried only terser and the css minifier, so the sheet
its `style` / `css-style-sheet` export types embed kept its nested html,
json and svg payloads unminified. Share one minimizer list, and assert
the export contract rather than `typeof`, which accepts null.
* test: one snapshot per embedded relationship
Each host/language pair gets its own test rather than a handful of cases
carrying hand-written substring expectations: the emitted fragment is
isolated and snapshotted whole, so a regression next to the construct
shows up instead of passing unread.
* test: do not let a tag isolation depend on casing
Match every html construct case-insensitively, and anchor the script one
on the script it means rather than on any script element.
* test: observe each css export type in its own build
Reading the injected stylesheet off a globalThis registry made the test
depend on state shared with every other case in the worker: the harness
clears it before these deferred bodies run, so the assertion saw whatever
case ran next. Build `style` for the web and read this case's document;
leave `css-style-sheet` where no document exists, so its text is the one
webpack wrote rather than one a parser reassembled.
* test: name the css export type each stylesheet is built with
`link` was covered only by omitting the rule, so nothing said which export
type that case exercised or would notice if the default moved.
* test: reach every language through a base64 data url
Only svg and css were carried base64, so the decode, minify and re-encode
path went untested for the three languages most likely to differ in it.
* feat(html): minify an iframe srcdoc through the embedded path
`minifySrcdoc` gated a pre-pass of its own, but not the offer: with a
`renderEmbeddedSource` set — which is how webpack wires html, css and js
minification together — the document was minified whatever the option
said, so its default-off promise was never kept.
The srcdoc is now one more embedded body, minified by webpack's own
minifier when no caller answers for it, and the option is gone. Two
printer changes keep the output where the pre-pass had it: the offer is
made for a value written bare as well as a quoted one, and an attribute
the renderer answered for is written with whichever delimiter needs
fewer escapes, the source's breaking the tie.
BREAKING CHANGE: `optimization.minimize.html.minifySrcdoc` is removed;
an `<iframe srcdoc>` is minified whenever html minification is on.
* feat(html): minify a JSON script through the embedded path
A JSON `<script>` is an embedded body like any other: it is offered to
whatever renderer a caller set, and minified by webpack's own minifier
when nothing answers. `minifyJson` sat in front of that as a transform
switch of its own, so turning it off also took the body away from a
caller that had asked for it.
`minifyStyles` stays: a `style=""` is not among the languages offered —
how the attribute is written is read back off the minified text — so the
switch still names something the embedded path does not reach.
BREAKING CHANGE: `optimization.minimize.html.minifyJson` is removed; a
JSON `<script>` is minified whenever html minification is on.
* feat(html): minify inline css through the embedded path
An inline `<style>` and a `style=""` are both offered as css — the
attribute as the `block-contents` production it is — so `minifyStyles`
sat in front of the same path `minifyJson` did, and turning it off took
the body away from a caller that had asked for css.
This corrects the reasoning in the previous commit, which kept the
switch on the grounds that a `style=""` is not offered. It is: what
`getEmbeddedTypes` leaves out is a separate language entry for it, not
the offer, and a renderer is handed every one the document holds.
BREAKING CHANGE: `optimization.minimize.html.minifyStyles` is removed;
an inline `<style>` and a `style=""` are minified whenever html
minification is on.
* test: one document through every embedded site, with a renderer and without
The two arms answer different questions. With a renderer, every site is
offered exactly once — an inline `<style>`, a JSON `<script>`, a
`<script>`, a `style=""` as the block-contents production it is, an
`<svg>` subtree and one per `<iframe srcdoc>` — and each answer lands
where it was asked for. Without one, the document records what webpack
minifies on its own, which is also where it stops: a `<script>` of
JavaScript, an `<svg>` subtree and every `data:` payload the inline
`<style>` carries are left as written.
A config case cannot drive the second arm: webpack's own pipeline always
supplies a renderer once html, css and js minification share a
minimizer.
* test: one stylesheet through every embedded site, with a renderer and without
The css host's counterpart to the html one. Each language is reached
twice — written out and base64 — so the two arms also say that base64 is
a spelling of the url rather than of the body: the same source is handed
over both times, and an answer is re-encoded to match the url it came
from. A media type naming no language and a url that is not a payload
reach no renderer at all.
Without a renderer the stylesheet around the bodies is minified and the
bodies are not, webpack having nothing of its own to fall back to here.
* test: cover the delimiter an answered srcdoc is written with
Codecov read one line of the tie-break uncovered once every flag had
uploaded, and the branch data named five more paths in the same helper:
an answer holding only a quote of one kind, the source delimiter kept
where the answer needs neither, a bare value quoted from its answer
alone, and the deferring path declining.
The last two need different callers to reach: htmlMinify hands every
renderer to the deferring path, so the synchronous branch is only
reachable through the print API. Declining there restores the raw value
as the source spelled it, references and delimiter included, rather than
the decoded document the renderer was shown -- which is what the test
now states.
* chore: bump the embedded-path changeset to patch
HTML and CSS minification are experimental, so taking three options off
`optimization.minimize.html` breaks no stable surface. The entry was
also a count behind: it dropped three options, not two.
* fix(html): take a style attribute's answer whatever quoting it needs
A deferred `style=""` answer was declined whenever it disagreed with the
built-in about whether the value could be written unquoted, so the
built-in's text stood and the answer was dropped without a word. Only a
foreign element's surviving `/>` reads that, to decide whether a space
must precede it -- an html element's tag just ends. Hold the answer to
the built-in's shape only where something reads it.
The default build showed this as an inconsistency between two sites for
the same language: a `data:` payload inside an inline `<style>` was
minified while the identical one inside a `style=""` was left raw,
because minifying it let the value go unquoted.1 parent f5ef3cd commit 78aaae3
44 files changed
Lines changed: 1362 additions & 319 deletions
File tree
- .changeset
- declarations
- lib/html
- schemas
- test
- __snapshots__
- configCases
- embedded/everything
- __snapshots__
- html
- minimize-srcdoc
- minimize-transforms-off
- __snapshots__
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2549 | 2549 | | |
2550 | 2550 | | |
2551 | 2551 | | |
2552 | | - | |
2553 | | - | |
2554 | | - | |
2555 | | - | |
2556 | | - | |
2557 | | - | |
2558 | | - | |
2559 | | - | |
2560 | | - | |
2561 | | - | |
2562 | | - | |
2563 | | - | |
2564 | | - | |
2565 | | - | |
2566 | | - | |
2567 | 2552 | | |
2568 | 2553 | | |
2569 | 2554 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | | - | |
| 37 | + | |
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | 55 | | |
59 | 56 | | |
60 | 57 | | |
| |||
69 | 66 | | |
70 | 67 | | |
71 | 68 | | |
72 | | - | |
73 | 69 | | |
74 | 70 | | |
75 | 71 | | |
76 | 72 | | |
77 | 73 | | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | 74 | | |
83 | 75 | | |
84 | 76 | | |
| |||
108 | 100 | | |
109 | 101 | | |
110 | 102 | | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
118 | 121 | | |
119 | 122 | | |
120 | 123 | | |
| |||
123 | 126 | | |
124 | 127 | | |
125 | 128 | | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | 129 | | |
130 | 130 | | |
131 | 131 | | |
| |||
142 | 142 | | |
143 | 143 | | |
144 | 144 | | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
| 145 | + | |
| 146 | + | |
150 | 147 | | |
151 | 148 | | |
152 | 149 | | |
153 | | - | |
154 | | - | |
| 150 | + | |
| 151 | + | |
155 | 152 | | |
156 | 153 | | |
157 | 154 | | |
158 | 155 | | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | | - | |
183 | | - | |
184 | | - | |
185 | | - | |
186 | | - | |
187 | | - | |
188 | | - | |
189 | | - | |
190 | | - | |
191 | | - | |
192 | | - | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
193 | 168 | | |
194 | | - | |
195 | | - | |
| 169 | + | |
| 170 | + | |
196 | 171 | | |
197 | | - | |
198 | | - | |
199 | | - | |
200 | | - | |
201 | | - | |
202 | | - | |
203 | | - | |
204 | | - | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
205 | 178 | | |
206 | 179 | | |
207 | | - | |
208 | | - | |
209 | | - | |
210 | 180 | | |
211 | 181 | | |
212 | 182 | | |
213 | | - | |
| 183 | + | |
214 | 184 | | |
| 185 | + | |
215 | 186 | | |
216 | | - | |
217 | | - | |
218 | | - | |
219 | | - | |
220 | | - | |
221 | | - | |
222 | | - | |
223 | | - | |
224 | | - | |
225 | | - | |
226 | | - | |
227 | | - | |
228 | | - | |
229 | | - | |
230 | | - | |
231 | | - | |
232 | | - | |
| 187 | + | |
233 | 188 | | |
234 | 189 | | |
235 | 190 | | |
| |||
258 | 213 | | |
259 | 214 | | |
260 | 215 | | |
261 | | - | |
262 | | - | |
263 | | - | |
264 | | - | |
265 | | - | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
266 | 219 | | |
267 | 220 | | |
268 | | - | |
| 221 | + | |
269 | 222 | | |
270 | 223 | | |
271 | 224 | | |
272 | 225 | | |
273 | 226 | | |
274 | 227 | | |
275 | | - | |
276 | | - | |
277 | | - | |
| 228 | + | |
278 | 229 | | |
279 | 230 | | |
280 | 231 | | |
| |||
0 commit comments