Skip to content

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

Merged
merged 11 commits into from
Jul 3, 2023
Merged

feat: Use none bundler for SSR Routes #2084

merged 11 commits into from
Jul 3, 2023

Conversation

Skn0tt
Copy link
Contributor

@Skn0tt Skn0tt commented May 4, 2023

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

  1. Visit the Deploy Preview (insert link to specific page) ...

Relevant links (GitHub issues, Notion docs, etc.) or a picture of cute animal

Standard checks:

  • Check the Deploy Preview's Demo site for your PR's functionality
  • Add docs when necessary

🧪 Once merged, make sure to update the version if needed and that it was published correctly.

@netlify
Copy link

netlify bot commented May 4, 2023

Deploy Preview for netlify-plugin-nextjs-nx-monorepo-demo ready!

Name Link
🔨 Latest commit 4466347
🔍 Latest deploy log https://app.netlify.com/sites/netlify-plugin-nextjs-nx-monorepo-demo/deploys/64a2a1f7dc7bac0008b27290
😎 Deploy Preview https://deploy-preview-2084--netlify-plugin-nextjs-nx-monorepo-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@netlify
Copy link

netlify bot commented May 4, 2023

Deploy Preview for netlify-plugin-nextjs-static-root-demo ready!

Name Link
🔨 Latest commit 4466347
🔍 Latest deploy log https://app.netlify.com/sites/netlify-plugin-nextjs-static-root-demo/deploys/64a2a1f7b7d478000789429e
😎 Deploy Preview https://deploy-preview-2084--netlify-plugin-nextjs-static-root-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@netlify
Copy link

netlify bot commented May 4, 2023

Deploy Preview for nextjs-plugin-custom-routes-demo ready!

Name Link
🔨 Latest commit 4466347
🔍 Latest deploy log https://app.netlify.com/sites/nextjs-plugin-custom-routes-demo/deploys/64a2a1f793200b00087fe27a
😎 Deploy Preview https://deploy-preview-2084--nextjs-plugin-custom-routes-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@netlify
Copy link

netlify bot commented May 4, 2023

Deploy Preview for netlify-plugin-nextjs-demo ready!

Name Link
🔨 Latest commit 4466347
🔍 Latest deploy log https://app.netlify.com/sites/netlify-plugin-nextjs-demo/deploys/64a2a1f772ad680008a6de33
😎 Deploy Preview https://deploy-preview-2084--netlify-plugin-nextjs-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@netlify
Copy link

netlify bot commented May 4, 2023

Deploy Preview for netlify-plugin-nextjs-export-demo ready!

Name Link
🔨 Latest commit 4466347
🔍 Latest deploy log https://app.netlify.com/sites/netlify-plugin-nextjs-export-demo/deploys/64a2a1f7896979000845ee04
😎 Deploy Preview https://deploy-preview-2084--netlify-plugin-nextjs-export-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@netlify
Copy link

netlify bot commented May 4, 2023

Deploy Preview for netlify-plugin-nextjs-next-auth-demo ready!

Name Link
🔨 Latest commit 4466347
🔍 Latest deploy log https://app.netlify.com/sites/netlify-plugin-nextjs-next-auth-demo/deploys/64a2a1f768395b00084b42a5
😎 Deploy Preview https://deploy-preview-2084--netlify-plugin-nextjs-next-auth-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@netlify
Copy link

netlify bot commented May 4, 2023

Deploy Preview for next-plugin-edge-middleware ready!

Name Link
🔨 Latest commit 4466347
🔍 Latest deploy log https://app.netlify.com/sites/next-plugin-edge-middleware/deploys/64a2a1f74cefe6000896ef2f
😎 Deploy Preview https://deploy-preview-2084--next-plugin-edge-middleware.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@netlify
Copy link

netlify bot commented May 4, 2023

Deploy Preview for next-i18next-demo ready!

Name Link
🔨 Latest commit 4466347
🔍 Latest deploy log https://app.netlify.com/sites/next-i18next-demo/deploys/64a2a1f7032ec70008655cef
😎 Deploy Preview https://deploy-preview-2084--next-i18next-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@netlify
Copy link

netlify bot commented May 4, 2023

Deploy Preview for next-plugin-canary ready!

Name Link
🔨 Latest commit 4466347
🔍 Latest deploy log https://app.netlify.com/sites/next-plugin-canary/deploys/64a2a1f7a2fc150008b2e7d9
😎 Deploy Preview https://deploy-preview-2084--next-plugin-canary.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@Skn0tt Skn0tt force-pushed the no-bundler-for-nothing branch from 98025e1 to a8aa12e Compare June 16, 2023 11:29
@Skn0tt Skn0tt marked this pull request as ready for review June 21, 2023 12:35
@Skn0tt Skn0tt requested a review from a team as a code owner June 21, 2023 12:35
@Skn0tt Skn0tt changed the title draft: no bundler for nothing Use none bundler for SSR Routes Jun 21, 2023
@@ -29,3 +29,10 @@ export const splitApiRoutes = (featureFlags: Record<string, unknown>, publish: s

return isEnabled
}

export const bundleBasedOnNftFiles = (featureFlags: Record<string, unknown>): boolean => {
Copy link
Contributor Author

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.

@Skn0tt
Copy link
Contributor Author

Skn0tt commented Jun 21, 2023

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

@Skn0tt Skn0tt requested a review from orinokai June 21, 2023 12:39
@Skn0tt Skn0tt self-assigned this Jun 21, 2023
@Skn0tt Skn0tt changed the title Use none bundler for SSR Routes feat: Use none bundler for SSR Routes Jun 21, 2023
@github-actions github-actions bot added the type: feature code contributing to the implementation of a feature and/or user facing functionality label Jun 21, 2023
orinokai
orinokai previously approved these changes Jun 30, 2023
Copy link
Contributor

@orinokai orinokai left a 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';
Copy link
Contributor

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.

Copy link
Contributor Author

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 required.

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.

Copy link
Contributor

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!

Copy link
Contributor

@orinokai orinokai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚢 🚢 🚢

@kodiakhq kodiakhq bot merged commit 4b3d3f4 into main Jul 3, 2023
@kodiakhq kodiakhq bot deleted the no-bundler-for-nothing branch July 3, 2023 10:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge type: feature code contributing to the implementation of a feature and/or user facing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants