Skip to content

Commit 5fcff19

Browse files
committed
fix(turbopack): remove css chunk prefix under devRuntime
1 parent 2a5e166 commit 5fcff19

File tree

1 file changed

+6
-5
lines changed
  • turbopack/crates/turbopack-ecmascript-runtime/js/src/browser/runtime/dom

1 file changed

+6
-5
lines changed

turbopack/crates/turbopack-ecmascript-runtime/js/src/browser/runtime/dom/dev-backend-dom.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,14 @@ let DEV_BACKEND: DevRuntimeBackend
5151
return
5252
}
5353

54-
const decodedChunkUrl = decodeURI(chunkUrl)
54+
const withoutNormalizedChunkUrl = chunkUrl.replace(NORMALIZED_CHUNK_BASE_PATH, '/')
55+
const decodedChunkUrl = decodeURI(withoutNormalizedChunkUrl)
5556
const previousLinks = document.querySelectorAll(
56-
`link[rel=stylesheet][href="${chunkUrl}"],link[rel=stylesheet][href^="${chunkUrl}?"],link[rel=stylesheet][href="${decodedChunkUrl}"],link[rel=stylesheet][href^="${decodedChunkUrl}?"]`
57+
`link[rel=stylesheet][href="${decodedChunkUrl}"],link[rel=stylesheet][href^="${decodedChunkUrl}?"],link[rel=stylesheet][href="${withoutNormalizedChunkUrl}"],link[rel=stylesheet][href^="${withoutNormalizedChunkUrl}?"]`
5758
)
5859

5960
if (previousLinks.length === 0) {
60-
reject(new Error(`No link element found for chunk ${chunkUrl}`))
61+
reject(new Error(`No link element found for chunk ${withoutNormalizedChunkUrl}`))
6162
return
6263
}
6364

@@ -72,9 +73,9 @@ let DEV_BACKEND: DevRuntimeBackend
7273
//
7374
// Safari has a similar issue, but only if you have a `<link rel=preload ... />` tag
7475
// pointing to the same URL as the stylesheet: https://bugs.webkit.org/show_bug.cgi?id=187726
75-
link.href = `${chunkUrl}?ts=${Date.now()}`
76+
link.href = `${withoutNormalizedChunkUrl}?ts=${Date.now()}`
7677
} else {
77-
link.href = chunkUrl
78+
link.href = withoutNormalizedChunkUrl
7879
}
7980

8081
link.onerror = () => {

0 commit comments

Comments
 (0)