Skip to content

Commit

Permalink
add missing node modules to externals (#70382)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
ztanner authored and ijjk committed Sep 24, 2024
1 parent ab03c77 commit e19d91c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/next/src/build/webpack-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -844,6 +844,8 @@ export default async function getBaseWebpackConfig(

const aliasCodeConditionTest = [codeCondition.test, pageExtensionsRegex]

const builtinModules = require('module').builtinModules

let webpackConfig: webpack.Configuration = {
parallelism: Number(process.env.NEXT_WEBPACK_PARALLELISM) || undefined,
...(isNodeServer ? { externalsPresets: { node: true } } : {}),
Expand All @@ -867,6 +869,7 @@ export default async function getBaseWebpackConfig(
: []),
]
: [
...builtinModules,
({
context,
request,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import timers from 'timers'
import tty from 'tty'
import util from 'util'
import zlib from 'zlib'

import '_http_common'
import 'setimmediate'

async function getData() {
Expand Down

0 comments on commit e19d91c

Please sign in to comment.