Commit 48fb57c
committed
bug #72 [Preload] Preload module script entries as modulepreload (Kocal)
This PR was merged into the main branch.
Discussion
----------
[Preload] Preload module script entries as modulepreload
| Q | A
| -------------- | ---
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Documentation? | no
| Issues | -
| License | MIT
RepriseBundle was preloading entry JavaScript via an HTTP `Link:` header with `rel="preload"; as="script"`, while rendering the entry itself as `<script type="module">`. Classic-script preloads and module scripts use different fetch modes (request credentials, CORS handling), so the browser cannot reuse the preloaded response and discards it, fetching the script a second time. The symptom is a console warning along the lines of "the request credentials mode does not match, consider the crossorigin attribute" or "preloaded ... but not used ... appropriate `as` value".
This mismatch was masked until recently: before SRI integrity was added to preload headers in 0.6.1, browsers rejected these preloads on an integrity mismatch before the credentials issue could surface. The fix changes entry module preloads to `rel="modulepreload"`, which matches `<script type="module">` fetch semantics and lets the browser reuse the response correctly. The `integrity` and `crossorigin` attributes are preserved when SRI is enabled. Imported vendor chunks were already using `modulepreload`, so this just makes all module JavaScript consistent. Verified in a browser with SRI on and off: no preload warning in either case, and no regression.
Commits
-------
9ea933a [Preload] Preload module script entries as modulepreload2 files changed
Lines changed: 7 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
86 | | - | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
87 | 89 | | |
88 | 90 | | |
89 | 91 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
273 | 273 | | |
274 | 274 | | |
275 | 275 | | |
276 | | - | |
277 | | - | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
278 | 280 | | |
279 | 281 | | |
280 | 282 | | |
| |||
0 commit comments