Skip to content

Commit

Permalink
fix(vite): import hmr runtime in main script to ensure script ordering
Browse files Browse the repository at this point in the history
  • Loading branch information
hi-ogawa committed Nov 5, 2023
1 parent 3874120 commit 06856da
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions packages/remix-dev/vite/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,10 @@ export const remixVitePlugin: RemixVitePlugin = (options = {}) => {
imports: [],
},
routes,
hmr: {
runtime: VirtualModule.url(injectHmrRuntimeId),
timestamp: -1, // not used for vite hmr
}
};
};

Expand Down Expand Up @@ -691,12 +695,13 @@ export const remixVitePlugin: RemixVitePlugin = (options = {}) => {
return [
'import { createElement } from "react";',
'export * from "@remix-run/react";',
'export const LiveReload = process.env.NODE_ENV !== "development" ? () => null : ',
'() => createElement("script", {',
' type: "module",',
" async: true,",
` src: "${VirtualModule.url(injectHmrRuntimeId)}"`,
"});",
'export const LiveReload = () => null;',
// 'export const LiveReload = process.env.NODE_ENV !== "development" ? () => null : ',
// '() => createElement("script", {',
// ' type: "module",',
// " async: true,",
// ` src: "${VirtualModule.url(injectHmrRuntimeId)}"`,
// "});",
].join("\n");
}
},
Expand Down

0 comments on commit 06856da

Please sign in to comment.