-
Notifications
You must be signed in to change notification settings - Fork 27k
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
Promote and rename server bundling options serverComponentsExternalPackages
and bundlePagesExternals
#65421
Merged
Merged
Promote and rename server bundling options serverComponentsExternalPackages
and bundlePagesExternals
#65421
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
bd9384f
promote and rename serverComponentsExternalPackages and bundlePagesEx…
Ethan-Arrowood 8f6d47b
fix doc link
Ethan-Arrowood 69a45f8
add docs
Ethan-Arrowood ea14a9d
fix validate-externals-doc script
Ethan-Arrowood 333dc5d
update turbopack manifests
Ethan-Arrowood a907762
fix links?
Ethan-Arrowood 617e75c
Merge branch 'canary' into promote-server-bundling-options
Ethan-Arrowood f111e93
more fixes
Ethan-Arrowood f4952bc
fix links
Ethan-Arrowood eeb3636
Merge branch 'canary' into promote-server-bundling-options
Ethan-Arrowood 1ace1e3
Merge branch 'canary' into promote-server-bundling-options
Ethan-Arrowood e0484ee
Merge branch 'canary' into promote-server-bundling-options
Ethan-Arrowood 7aad5cf
fix swc
Ethan-Arrowood File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
docs/03-pages/02-api-reference/03-next-config-js/bundlePagesRouterDependencies.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
--- | ||
title: bundlePagesRouterDependencies | ||
description: Enable automatic dependency bundling for Pages Router | ||
--- | ||
|
||
Enable automatic server-side dependency bundling for Pages Router applications. Matches the automatic dependency bundling in App Router. | ||
|
||
```js filename="next.config.js" | ||
/** @type {import('next').NextConfig} */ | ||
const nextConfig = { | ||
bundlePagesRouterDependencies: true, | ||
} | ||
|
||
module.exports = nextConfig | ||
``` | ||
|
||
Explicitly opt-out certain packages from being bundled using the [`serverExternalPackages`](/docs/pages/api-reference/next-config-js/serverExternalPackages) option. |
77 changes: 77 additions & 0 deletions
77
docs/03-pages/02-api-reference/03-next-config-js/serverExternalPackages.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
--- | ||
title: serverExternalPackages | ||
description: Opt-out specific dependencies from the dependency bundling enabled by `bundlePagesRouterDependencies`. | ||
--- | ||
|
||
Opt-out specific dependencies from being included in the automatic bundling of the [`bundlePagesRouterDependencies`](/docs/pages/api-reference/next-config-js/bundlePagesRouterDependencies) option. | ||
|
||
These pages will then use native Node.js `require` to resolve the dependency. | ||
|
||
```js filename="next.config.js" | ||
/** @type {import('next').NextConfig} */ | ||
const nextConfig = { | ||
serverExternalPackages: ['@acme/ui'], | ||
} | ||
|
||
module.exports = nextConfig | ||
``` | ||
|
||
Next.js includes a [short list of popular packages](https://github.com/vercel/next.js/blob/canary/packages/next/src/lib/server-external-packages.json) that currently are working on compatibility and automatically opt-ed out: | ||
|
||
- `@appsignal/nodejs` | ||
- `@aws-sdk/client-s3` | ||
- `@aws-sdk/s3-presigned-post` | ||
- `@blockfrost/blockfrost-js` | ||
- `@highlight-run/node` | ||
- `@jpg-store/lucid-cardano` | ||
- `@libsql/client` | ||
- `@mikro-orm/core` | ||
- `@mikro-orm/knex` | ||
- `@node-rs/argon2` | ||
- `@node-rs/bcrypt` | ||
- `@prisma/client` | ||
- `@react-pdf/renderer` | ||
- `@sentry/profiling-node` | ||
- `@swc/core` | ||
- `argon2` | ||
- `autoprefixer` | ||
- `aws-crt` | ||
- `bcrypt` | ||
- `better-sqlite3` | ||
- `canvas` | ||
- `cpu-features` | ||
- `cypress` | ||
- `eslint` | ||
- `express` | ||
- `firebase-admin` | ||
- `isolated-vm` | ||
- `jest` | ||
- `jsdom` | ||
- `libsql` | ||
- `mdx-bundler` | ||
- `mongodb` | ||
- `mongoose` | ||
- `next-mdx-remote` | ||
- `next-seo` | ||
- `node-pty` | ||
- `node-web-audio-api` | ||
- `oslo` | ||
- `pg` | ||
- `playwright` | ||
- `postcss` | ||
- `prettier` | ||
- `prisma` | ||
- `puppeteer-core` | ||
- `puppeteer` | ||
- `rimraf` | ||
- `sharp` | ||
- `shiki` | ||
- `sqlite3` | ||
- `tailwindcss` | ||
- `ts-node` | ||
- `typescript` | ||
- `vscode-oniguruma` | ||
- `undici` | ||
- `webpack` | ||
- `websocket` | ||
- `zeromq` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -120,6 +120,9 @@ pub struct NextConfig { | |
typescript: TypeScriptConfig, | ||
use_file_system_public_routes: bool, | ||
webpack: Option<serde_json::Value>, | ||
/// A list of packages that should be treated as external in the RSC server | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this comment probably needs to be changed |
||
/// build. @see [api reference](https://nextjs.org/docs/app/api-reference/next-config-js/server_external_packages) | ||
pub server_external_packages: Option<Vec<String>>, | ||
} | ||
|
||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, TraceRawVcs)] | ||
|
@@ -460,9 +463,6 @@ pub struct ExperimentalConfig { | |
/// For use with `@next/mdx`. Compile MDX files using the new Rust compiler. | ||
/// @see [api reference](https://nextjs.org/docs/app/api-reference/next-config-js/mdxRs) | ||
mdx_rs: Option<MdxRsOptions>, | ||
/// A list of packages that should be treated as external in the RSC server | ||
/// build. @see [api reference](https://nextjs.org/docs/app/api-reference/next-config-js/server_components_external_packages) | ||
pub server_components_external_packages: Option<Vec<String>>, | ||
pub strict_next_head: Option<bool>, | ||
pub swc_plugins: Option<Vec<(String, serde_json::Value)>>, | ||
pub turbo: Option<ExperimentalTurboConfig>, | ||
|
@@ -737,11 +737,10 @@ impl NextConfig { | |
} | ||
|
||
#[turbo_tasks::function] | ||
pub async fn server_component_externals(self: Vc<Self>) -> Result<Vc<Vec<String>>> { | ||
pub async fn server_external_packages(self: Vc<Self>) -> Result<Vc<Vec<String>>> { | ||
Ok(Vc::cell( | ||
self.await? | ||
.experimental | ||
.server_components_external_packages | ||
.server_external_packages | ||
.as_ref() | ||
.cloned() | ||
.unwrap_or_default(), | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -279,12 +279,6 @@ export interface ExperimentalConfig { | |
adjustFontFallbacks?: boolean | ||
adjustFontFallbacksWithSizeAdjust?: boolean | ||
|
||
/** | ||
* A list of packages that should be treated as external in the RSC server build. | ||
* @see https://nextjs.org/docs/app/api-reference/next-config-js/serverComponentsExternalPackages | ||
*/ | ||
serverComponentsExternalPackages?: string[] | ||
|
||
webVitalsAttribution?: Array<(typeof WEB_VITALS)[number]> | ||
|
||
/** | ||
|
@@ -420,10 +414,7 @@ export interface ExperimentalConfig { | |
* @internal Used by the Next.js internals only. | ||
*/ | ||
trustHostHeader?: boolean | ||
/** | ||
* Enables the bundling of node_modules packages (externals) for pages server-side bundles. | ||
*/ | ||
bundlePagesExternals?: boolean | ||
|
||
/** | ||
* Uses an IPC server to dedupe build-time requests to the cache handler | ||
*/ | ||
|
@@ -838,6 +829,17 @@ export interface NextConfig extends Record<string, any> { | |
* Enable experimental features. Note that all experimental features are subject to breaking changes in the future. | ||
*/ | ||
experimental?: ExperimentalConfig | ||
|
||
/** | ||
* Enables the bundling of node_modules packages (externals) for pages server-side bundles. | ||
*/ | ||
bundlePagesRouterDependencies?: boolean | ||
|
||
/** | ||
* A list of packages that should be treated as external in the RSC server build. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this comment needs to be changed |
||
* @see https://nextjs.org/docs/app/api-reference/next-config-js/serverExternalPackages | ||
*/ | ||
serverExternalPackages?: string[] | ||
} | ||
|
||
export const defaultConfig: NextConfig = { | ||
|
@@ -942,7 +944,6 @@ export const defaultConfig: NextConfig = { | |
turbotrace: undefined, | ||
typedRoutes: false, | ||
instrumentationHook: false, | ||
bundlePagesExternals: false, | ||
parallelServerCompiles: false, | ||
parallelServerBuildTraces: false, | ||
ppr: | ||
|
@@ -963,6 +964,7 @@ export const defaultConfig: NextConfig = { | |
static: 300, | ||
}, | ||
}, | ||
bundlePagesRouterDependencies: false, | ||
} | ||
|
||
export async function normalizeConfig(phase: string, config: any) { | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 it's an mdx file so u can import the json file where these deps names are written and map to display it here. This way both the lists will stay synced
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.
I'd consider that out of scope for this PR. We have the validate script that manages it for now. It'd be a good follow up change!