Skip to content

Commit e19d91c

Browse files
ztannerijjk
authored andcommitted
add missing node modules to externals (#70382)
We should not attempt to bundle builtin node modules on the server. This adds modules provided by Node.js to our externals list (along with some missing internal ones in Turbopack. These were copied from [here](https://github.com/vercel/next.js/blob/a675bde6c738318264573144663e38819aeb2661/crates/next-custom-transforms/src/transforms/warn_for_edge_runtime.rs#L77-L89)). Fixes #70262 Closes NDX-314 # Conflicts: # turbopack/crates/turbopack-resolve/src/resolve.rs
1 parent ab03c77 commit e19d91c

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

packages/next/src/build/webpack-config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -844,6 +844,8 @@ export default async function getBaseWebpackConfig(
844844

845845
const aliasCodeConditionTest = [codeCondition.test, pageExtensionsRegex]
846846

847+
const builtinModules = require('module').builtinModules
848+
847849
let webpackConfig: webpack.Configuration = {
848850
parallelism: Number(process.env.NEXT_WEBPACK_PARALLELISM) || undefined,
849851
...(isNodeServer ? { externalsPresets: { node: true } } : {}),
@@ -867,6 +869,7 @@ export default async function getBaseWebpackConfig(
867869
: []),
868870
]
869871
: [
872+
...builtinModules,
870873
({
871874
context,
872875
request,

test/development/basic/node-builtins/app/server-component/page.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ import timers from 'timers'
1818
import tty from 'tty'
1919
import util from 'util'
2020
import zlib from 'zlib'
21+
22+
import '_http_common'
2123
import 'setimmediate'
2224

2325
async function getData() {

0 commit comments

Comments
 (0)