sst / open-next

Open source Next.js serverless adapter
https://open-next.js.org
MIT License
3.7k stars 111 forks source link

Improve custom config support #416

Closed conico974 closed 1 month ago

conico974 commented 1 month ago

Before this PR, OpenNext used a single compiled open-next.config.mjs file even for the edge runtime. It achieved this by setting the platform as neutral in esbuild which caused a lot of trouble when using custom overrides.

With this PR OpenNext will create 2 different bundle for open-next.config.mjs, one for node and one for edge, and copy the correct one depending on the function runtime. To properly support this, there is a new build args --node-externals that is used for esbuild during compilation of open-next.config.ts ( for example --node-externals "@aws-sdk/*,sharp" to remove every aws sdk and sharp deps from the config file ). There is also a new options in open-next.config.ts : edgeExternals that serve the same purpose but for the edge version of open-next.config.mjs

It also fix an issue where custom lazy loaded override where not used for functions other than the default one

changeset-bot[bot] commented 1 month ago

🦋 Changeset detected

Latest commit: 9b483d5fdf5d7e57ec6dfc6dbc7a20d7a6df7642

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 4 packages | Name | Type | | ---------------- | ----- | | open-next | Patch | | app-pages-router | Patch | | app-router | Patch | | tests-unit | Patch |

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

vercel[bot] commented 1 month ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
open-next ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 24, 2024 11:33am