-
-
Notifications
You must be signed in to change notification settings - Fork 10.5k
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
Fix custom SSR build input with serverBundles
#13107
base: dev
Are you sure you want to change the base?
Fix custom SSR build input with serverBundles
#13107
Conversation
🦋 Changeset detectedLatest commit: 7fea63d The changes in this PR will be included in the next version bump. This PR includes changesets to release 11 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 |
"bundle-a._index.tsx", | ||
"bundle-a.route-a.tsx", | ||
"bundle-a.route-b.tsx", | ||
"bundle_a.tsx", |
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.
As noted in the changeset, we needed to replace hyphens with underscores in our server bundle IDs since we're also testing against the Vite Environment API. This is technically a breaking change but unlikely to break anyone in practice, and only those who have opted into an unstable API.
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.
Is this something the Vercel preset will need to do as well? i.e. currently it generates a bundle ID such as nodejs-eyJydW50aW1lIjoibm9kZWpzIn0
. Does that need to be nodejs_eyJydW50aW1lIjoibm9kZWpzIn0
instead?
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.
Ah nice catch, I didn't realise this. Yep, swapping for an underscore now is a good idea.
input: | ||
(ctx.reactRouterConfig.future.unstable_viteEnvironmentApi | ||
? viteUserConfig.environments?.ssr?.build?.rollupOptions?.input | ||
: viteUserConfig.build?.rollupOptions?.input) ?? | ||
virtual.serverBuild.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.
Since the route-ids
query string is no longer used, this config is now common across all SSR builds including server bundles.
@@ -184,15 +183,18 @@ async function viteBuild( | |||
optimizeDeps: { force }, | |||
clearScreen, | |||
logLevel, | |||
...{ __reactRouterEnvironmentBuildContext: environmentBuildContext }, | |||
...{ | |||
__reactRouterPluginContext: ctx, |
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.
We now pass the resolved plugin context object into each build so we can re-use the build manifest rather than re-evaluating the serverBundles
function whenever our Vite plugin is instantiated.
Fixes #13104.
This fixes two issues:
build.rollupOptions.input
value was provided in the SSR build, this was not honoured whenserverBundles
were configured. This PR ensures that all SSR builds honour this value.virtual:react-router/server-build
, this fails to account for the query string used to supportserverBundles
(e.g.virtual:react-router/server-build?route-ids=foo,bar,baz
. This PR alters the logic for getting the route IDs of a server bundle build so they're no longer encoded in the query string. Instead, the server bundle ID is extracted from the environment name, and this is then used to look up its routes in the React Router build manifest.