Skip to main content

serverExternalPackages

服务器组件路由处理程序 中使用的依赖将自动由 Next.js 打包。

¥Dependencies used inside Server Components and Route Handlers will automatically be bundled by Next.js.

如果依赖使用 Node.js 特定功能,你可以选择从服务器组件打包中选择退出特定依赖并使用原生 Node.js require

¥If a dependency is using Node.js specific features, you can choose to opt-out specific dependencies from the Server Components bundling and use native Node.js require.

/** @type {import('next').NextConfig} */
const nextConfig = {
serverExternalPackages: ['@acme/ui'],
}

module.exports = nextConfig

Next.js 包含一个 流行软件包的简短列表,目前正在处理兼容性并自动选择退出:

¥Next.js includes a short list of popular packages 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

  • playwright-core

  • postcss

  • prettier

  • prisma

  • puppeteer-core

  • puppeteer

  • rimraf

  • sharp

  • shiki

  • sqlite3

  • ts-node

  • ts-morph

  • typescript

  • vscode-oniguruma

  • webpack

  • websocket

  • zeromq

版本变化
v15.0.0从实验移至稳定。从 serverComponentsExternalPackages 重命名为 serverExternalPackages