Commit 2f6617f
authored
feat: import map integrity mode — native SRI for module chunks (#35)
* feat: add import map integrity key builders
* feat: inject import map integrity into emitted HTML
* feat: let import map integrity subsume JS-level dynamic import enforcement
* docs: document import map integrity mode and runtime fallback
* fix: harden import map integrity per review findings
- honor skipResources in the import map integrity object (the opt-out
now applies to native module-fetch enforcement too)
- keep the JS enforcement rewrite when a manifest is emitted alongside
HTML: manifest consumers render their own HTML without the import
map, so suppressing the rewrite would silently drop their enforcement
- warn when an existing import map pins an integrity value that
differs from the build-computed hash (kept, but surfaced)
- warn when user HTML contains an absolute-URL <base href>, which
changes how import map keys resolve
- match PROCESSABLE_EXTENSIONS query-suffix semantics in the key filter
- share one escapeForScript implementation between the runtime
serializer and the import map injector
- log the relative-base skip once per build instead of once per file
* docs: correct Safari support to 18+ and document review-found boundaries
MDN browser-compat-data records import map integrity as Safari 18.0
(18.4 is the adjacent multiple-import-maps row). Also: import map ToC
entry, mixed HTML+manifest fallback, runtimePatchDynamicLinks:false
old-browser boundary, skipResources exclusion note, facade phrasing.
* fix: keep a leading meta charset ahead of injected import map and preload links
The import map (and the modulepreload links) were unshifted to the very
start of head, displacing <meta charset> — which the HTML spec wants
within the first 1024 bytes. Both grow with chunk count, so a large
bundle could push the charset declaration past that boundary and force
encoding sniffing.
Both injection sites now insert after a leading charset-declaring meta
(charset attribute or http-equiv content-type) when it precedes any
script or link element, falling back to the head start otherwise. The
import map still lands before every injected link and module script.1 parent 5c7d2c3 commit 2f6617f
5 files changed
Lines changed: 778 additions & 36 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| 46 | + | |
46 | 47 | | |
47 | 48 | | |
48 | 49 | | |
| |||
107 | 108 | | |
108 | 109 | | |
109 | 110 | | |
110 | | - | |
| 111 | + | |
111 | 112 | | |
112 | 113 | | |
113 | 114 | | |
| |||
158 | 159 | | |
159 | 160 | | |
160 | 161 | | |
161 | | - | |
162 | | - | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
163 | 165 | | |
164 | 166 | | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
165 | 187 | | |
166 | 188 | | |
167 | 189 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| 12 | + | |
11 | 13 | | |
12 | 14 | | |
13 | 15 | | |
| |||
109 | 111 | | |
110 | 112 | | |
111 | 113 | | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
123 | 119 | | |
124 | 120 | | |
125 | 121 | | |
| |||
250 | 246 | | |
251 | 247 | | |
252 | 248 | | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
253 | 257 | | |
254 | 258 | | |
255 | 259 | | |
| |||
268 | 272 | | |
269 | 273 | | |
270 | 274 | | |
271 | | - | |
272 | | - | |
273 | | - | |
274 | | - | |
275 | | - | |
276 | | - | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
277 | 293 | | |
278 | 294 | | |
279 | 295 | | |
| |||
0 commit comments