[turbopack] Fix CSS HMR on Safari#92123
Conversation
|
Allow CI Workflow Run
Note: this should only be enabled once the PR is ready to go and can only be enabled by a maintainer |
1 similar comment
|
Allow CI Workflow Run
Note: this should only be enabled once the PR is ready to go and can only be enabled by a maintainer |
b84033f to
6b02071
Compare
|
Looks good, can we add a test to catch this? |
Merging this PR will degrade performance by 4.26%
Performance Changes
Comparing Footnotes
|
Tests Passed |
not easily. afaict we don't have any hmr tests for safari or firefox in CI |
|
i did manually test this with firefox and safari (and chrome) so css loading is working, but yeah it is a risk |
|
ok, this is easy we actualyl already have css hmr tests, just not for firefox and safari |
6845022 to
8bb964e
Compare
Stats from current PR✅ No significant changes detected📊 All Metrics📖 Metrics GlossaryDev Server Metrics:
Build Metrics:
Change Thresholds:
⚡ Dev Server
📦 Dev Server (Webpack) (Legacy)📦 Dev Server (Webpack)
⚡ Production Builds
📦 Production Builds (Webpack) (Legacy)📦 Production Builds (Webpack)
📦 Bundle SizesBundle Sizes⚡ TurbopackClient Main Bundles
Server Middleware
Build DetailsBuild Manifests
📦 WebpackClient Main Bundles
Polyfills
Pages
Server Edge SSR
Middleware
Build DetailsBuild Manifests
Build Cache
🔄 Shared (bundler-independent)Runtimes
📎 Tarball URL |
8bb964e to
f3853f2
Compare
f3853f2 to
4956ed0
Compare
Merge activity
|
4956ed0 to
2da0796
Compare
Fixes #91818 **Regression source:** Commit `b7e4c6a011` ("Turbopack: transpile CHUNK_SUFFIX") introduced `getChunkSuffixFromScriptSrc()` which reads query strings from `<script>` tags. On Safari, this picks up the `?ts=` param injected by the server-side cache-busting workaround in `render.tsx` (for [WebKit into `ASSET_SUFFIX`. This causes HMR CSS URLs to match the preloaded URL exactly, re-triggering the Safari preload cache bug and preventing style updates. **Changes:** - **`dev-backend-dom.ts`**: Match existing `<link>` elements by base path (strip query string) so selectors work across HMR updates with different `?ts=` values. Add Safari to the Firefox cache-busting branch so new stylesheet links always get a fresh `?ts=`. - **`hmr-client.ts`**: Fix `mergeChunkUpdates` so a `total` update always supersedes any prior update type. (cherry picked from commit 8be5a3c)
## Summary - Backport of #92123 to `next-16-2` release branch - Cherry-picked the CSS HMR Safari fix and regenerated turbopack-tests snapshot goldens for the release branch ## Test plan - [x] `UPDATE=1 cargo nextest r -p turbopack-tests` — all 297 tests pass - [x] `pnpm build-all` — clean build, no issues with `generated-native.d.ts`

Fixes #91818
Regression source: Commit
b7e4c6a011("Turbopack: transpile CHUNK_SUFFIX") introducedgetChunkSuffixFromScriptSrc()which reads query strings from<script>tags. On Safari, this picks up the?ts=param injected by the server-side cache-busting workaround inrender.tsx(for WebKit #187726), baking it intoASSET_SUFFIX. This causes HMR CSS URLs to match the preloaded URL exactly, re-triggering the Safari preload cache bug and preventing style updates.Changes:
dev-backend-dom.ts: Match existing<link>elements by base path (strip query string) so selectors work across HMR updates with different?ts=values. Add Safari to the Firefox cache-busting branch so new stylesheet links always get a fresh?ts=.hmr-client.ts: FixmergeChunkUpdatesso atotalupdate always supersedes any prior update type.