-
Notifications
You must be signed in to change notification settings - Fork 88
feat: Use none
bundler for SSR Routes
#2084
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
Conversation
✅ Deploy Preview for netlify-plugin-nextjs-nx-monorepo-demo ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
✅ Deploy Preview for netlify-plugin-nextjs-static-root-demo ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
✅ Deploy Preview for nextjs-plugin-custom-routes-demo ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
✅ Deploy Preview for netlify-plugin-nextjs-demo ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
✅ Deploy Preview for netlify-plugin-nextjs-export-demo ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
✅ Deploy Preview for netlify-plugin-nextjs-next-auth-demo ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
✅ Deploy Preview for next-plugin-edge-middleware ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
✅ Deploy Preview for next-i18next-demo ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
✅ Deploy Preview for next-plugin-canary ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
98025e1
to
a8aa12e
Compare
@@ -29,3 +29,10 @@ export const splitApiRoutes = (featureFlags: Record<string, unknown>, publish: s | |||
|
|||
return isEnabled | |||
} | |||
|
|||
export const bundleBasedOnNftFiles = (featureFlags: Record<string, unknown>): boolean => { |
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.
Note to self: We should probably make splitApiRoute
another activation guard for this.
it looks like most of our tests are successful with this enabled! The failing "app-dir" tests look unrelated to this PR. @orinokai would love your review on this :D |
none
bundler for SSR Routesnone
bundler for SSR Routes
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.
Hey @Skn0tt, just a couple of questions, but otherwise this looks great and very exciting to see!
@@ -206,6 +206,8 @@ export const getHandler = ({ | |||
throw new Error('Could not find Next.js server') | |||
} | |||
|
|||
process.env.NODE_ENV = 'production'; |
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.
What is the reason for this? Just wondering because this will also be the case when running netlify dev
.
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're filtering out .development.js
, to reduce bundle size:
https://github.com/netlify/next-runtime/blob/main/packages/runtime/src/helpers/functions.ts#L274
(This needs to be done manually for whatever reason)
react-dom is an example for where this helps: https://www.npmjs.com/package/react-dom?activeTab=code
By setting node_env
to production
, we ensure these files are never require
d.
Just wondering because this will also be the case when running netlify dev.
AFAIK, we're directly proxying next dev
there - so this runtime wouldn't run.
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, I see. Thanks, that makes sense. And yes, you're absolutely right about proxying next dev
- i was having a Friday moment and was mistakenly thinking about netlify serve
!
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.
🚢 🚢 🚢
Summary
This PR adds a new behaviour where the
none
bundler is used for SSR Routes. It leverages the*.nft.json
-based file tracing logic added in previous PRs, and extends that to SSR Routes. Before, it was only applied to API Routes.The new behaviour is behind a flag, which I have enabled for our test suite. It allows us to slowly roll out the change accross customers.
When both the split-api behaviour and this new behaviour are used in conjunction, bundling times can be significantly reduced to a few seconds.
Test plan
Relevant links (GitHub issues, Notion docs, etc.) or a picture of cute animal
Standard checks:
🧪 Once merged, make sure to update the version if needed and that it was published correctly.