Skip to content

Commit

Permalink
fix CSS HMR (#4815)
Browse files Browse the repository at this point in the history
### Description

* type=stylesheet => rel=stylesheet
* remove timestamp, that's not needed
* ensure correct encoding of the href
  • Loading branch information
sokra authored and Greg Soltis committed May 5, 2023
1 parent d01d70a commit d593105
Show file tree
Hide file tree
Showing 36 changed files with 252 additions and 72 deletions.
9 changes: 7 additions & 2 deletions crates/turbopack-dev/js/src/runtime.dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,13 @@ let BACKEND;
return;
}

const encodedChunkPath = chunkPath
.split("/")
.map((p) => encodeURIComponent(p))
.join("/");

const previousLink = document.querySelector(
`link[type=stylesheet][href^="/${chunkPath}"]`
`link[rel=stylesheet][href^="/${encodedChunkPath}"]`
);

if (previousLink == null) {
Expand All @@ -89,7 +94,7 @@ let BACKEND;

const link = document.createElement("link");
link.rel = "stylesheet";
link.href = `/${chunkPath}?t=${Date.now()}`;
link.href = `/${encodedChunkPath}`;
link.onerror = () => {
reject();
};
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit d593105

Please sign in to comment.