Skip to content

Commit

Permalink
Skip route chunk HMR preloads when disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
markdalgleish authored Oct 4, 2024
1 parent 9a2ddcf commit d8697b2
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/react-router-dev/vite/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1914,6 +1914,10 @@ function addRefreshWrapper(
REACT_REFRESH_FOOTER.replaceAll("__SOURCE__", JSON.stringify(id))
.replaceAll("__ACCEPT_EXPORTS__", JSON.stringify(acceptExports))
.replaceAll("__ROUTE_ID__", JSON.stringify(route?.id))
.replaceAll(
"__ROUTE_CHUNKS_ENABLED__",
JSON.stringify(reactRouterConfig.future.unstable_routeChunks)
)
) +
"\n"
);
Expand Down Expand Up @@ -1963,7 +1967,7 @@ if (import.meta.hot && !inWebWorker) {
// handle cases where route chunks don't exist on initial load but are
// subsequently created while editing the route module.
""
}if (__ROUTE_ID__) {
}if (__ROUTE_ID__ && __ROUTE_CHUNKS_ENABLED__) {
const routeBase = import.meta.url.split("?")[0];
RefreshRuntime.__hmr_import(routeBase + "${IMPORT_CLIENT_ACTION_CHUNK_QUERY_STRING}");
RefreshRuntime.__hmr_import(routeBase + "${IMPORT_CLIENT_LOADER_CHUNK_QUERY_STRING}");
Expand Down

0 comments on commit d8697b2

Please sign in to comment.