Skip to content

Commit

Permalink
fix: workaround inconsitent hmr path issue
Browse files Browse the repository at this point in the history
  • Loading branch information
hi-ogawa committed Jul 31, 2024
1 parent a12ce8f commit a8ab872
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
3 changes: 1 addition & 2 deletions packages/react-server/examples/basic/e2e/basic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -324,8 +324,7 @@ test("client hmr @dev", async ({ page }) => {
expect(resText).toContain("<div>test-hmr-edit-div</div>");
});

// TODO
test.skip("rsc + client + rsc hmr @dev", async ({ page }) => {
test("rsc + client + rsc hmr @dev", async ({ page }) => {
checkNoError(page);

await page.goto("/test");
Expand Down
10 changes: 9 additions & 1 deletion packages/react-server/src/features/assets/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,14 @@ export function vitePluginServerAssets({

createVirtualPlugin(DEV_SSR_CSS.split(":")[1]!, async () => {
tinyassert(!manager.buildType);
// normalize it again to workaround inconsistent hmr path issue
// https://github.com/hi-ogawa/reproductions/tree/main/vite-v6-hmr-path
const root = manager.config.root;
const clientReferences = [...manager.clientReferenceMap.keys()].map(
(file) => {
return file.startsWith(root) ? file.slice(root.length) : file;
},
);
const styles = await Promise.all([
`/******* react-server ********/`,
collectStyle($__global.dev.reactServer, {
Expand All @@ -106,7 +114,7 @@ export function vitePluginServerAssets({
entries: [
entryBrowser,
// TODO: dev should also use RouteManifest to manage client css
...manager.clientReferenceMap.keys(),
...clientReferences,
],
ssr: false,
}),
Expand Down

0 comments on commit a8ab872

Please sign in to comment.