Skip to content
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

perf: vercel lambdas, drop unrequired deps #3581

Merged
merged 6 commits into from
Mar 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions apps/nextjs-app/next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,36 @@ const nextConfig = {
// @link https://nextjs.org/docs/advanced-features/output-file-tracing#caveats
outputFileTracingRoot: workspaceRoot,

// Useful to keep lambdas sizes low when vercel/nft isn't able to drop unneeded deps for you.
// This is particularly useful to remove musl binaries when deploying on vercel for example.
// (ie esbuild-musl, swc-musl...). This also also help to keep docker images smaller
//
// Note that yarn 3+/4 is less impacted thanks to supportedArchitectures.
// See https://yarnpkg.com/configuration/yarnrc#supportedArchitectures and
// config example in https://github.com/belgattitude/nextjs-monorepo-example/pull/3582
// NPM/PNPM might adopt https://github.com/npm/rfcs/pull/519 in the future.
//
// Caution: use it with care because you'll have to maintain this over time.
//
// How to debug in vercel: set NEXT_DEBUG_FUNCTION_SIZE=1 in vercel env, then
// check the last lines of vercel build.
//
// Related issue: https://github.com/vercel/next.js/issues/42641

// outputFileTracingExcludes: {
// '*': [
// '**/node_modules/@swc/core-linux-x64-gnu/**/*',
// '**/node_modules/@swc/core-linux-x64-musl/**/*',
// // If you're nor relying on mdx-remote... drop this
// '**/node_modules/esbuild/linux/**/*',
// '**/node_modules/webpack/**/*',
// '**/node_modules/terser/**/*',
// // If you're not relying on sentry edge or any weird stuff... drop this too
// // https://github.com/getsentry/sentry-javascript/pull/6982
// '**/node_modules/rollup/**/*',
// ],
// },

// Prefer loading of ES Modules over CommonJS
// @link {https://nextjs.org/blog/next-11-1#es-modules-support|Blog 11.1.0}
// @link {https://github.com/vercel/next.js/discussions/27876|Discussion}
Expand Down