-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clean redundant ?client-route=1
usage in dev
#9395
Clean redundant ?client-route=1
usage in dev
#9395
Conversation
🦋 Changeset detectedLatest commit: 93ca5d7 The changes in this PR will be included in the next version bump. This PR includes changesets to release 16 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
@@ -1271,8 +1269,8 @@ export const remixVitePlugin: RemixVitePlugin = (remixUserConfig = {}) => { | |||
cssModulesManifest[id] = code; | |||
} | |||
|
|||
if (isClientRoute(id)) { | |||
let routeModuleId = id.replace(CLIENT_ROUTE_QUERY_STRING, ""); | |||
if (id.endsWith(BUILD_CLIENT_ROUTE_QUERY_STRING)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inlined isClientRoute
here since it's now the only usage.
if (isClientRoute(id)) { | ||
return { code: addRefreshWrapper(ctx.remixConfig, code, id) }; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code path is only used in dev, so no longer needed.
@@ -1789,17 +1783,16 @@ function addRefreshWrapper( | |||
id: string | |||
): string { | |||
let route = getRoute(remixConfig, id); | |||
let acceptExports = | |||
route || isClientRoute(id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HMR is no longer needed for these virtual modules since they're only used during build
.
from the client build output. This is important in cases where custom route | ||
exports are only ever used on the server. Without this optimization we can't | ||
tree-shake any unused custom exports because routes are entry points. */ | ||
const BUILD_CLIENT_ROUTE_QUERY_STRING = "?__remix-build-client-route"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this query string is no longer visible in the browser's network tab, I'm not trying to make this look pretty anymore and instead I'm aiming for it to be more explicit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also the =1
suffix is no longer needed since that was to solve an issue when proxying during development. In production builds this query string never goes over the network.
This PR is aiming to address two things:
The
?client-route=1
virtual modules that wrap all client routes are only necessary for a build optimisation that removes unused exports from route files on the client. The only reason these virtual modules were used in development was to keep the dev and build code paths as similar as possible. However, since it's causing other issues, and it also necessitated extra code in dev to special-case HMR for these files, we're opting to remove?client-route=1
usage in dev entirely.