Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
b19f0980
Unverified
Commit
b19f0980
authored
Nov 05, 2024
by
Jiachi Liu
Committed by
GitHub
Nov 05, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix: revert the bad node binary handling (#72356)
backport #71723
parent
c7f7de96
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
27 additions
and
45 deletions
+27
-45
webpack-config.ts
packages/next/src/build/webpack-config.ts
+8
-12
next-server-binary-loader.ts
...xt/src/build/webpack/loaders/next-server-binary-loader.ts
+0
-14
externalize-node-binary-browser-error.test.ts
...owser-error/externalize-node-binary-browser-error.test.ts
+17
-18
externalize-node-binary.test.ts
...r/externalize-node-binary/externalize-node-binary.test.ts
+2
-1
No files found.
packages/next/src/build/webpack-config.ts
View file @
b19f0980
...
...
@@ -1192,7 +1192,6 @@ export default async function getBaseWebpackConfig(
'next-metadata-route-loader'
,
'modularize-import-loader'
,
'next-barrel-loader'
,
'next-server-binary-loader'
,
'next-error-browser-binary-loader'
,
].
reduce
((
alias
,
loader
)
=>
{
// using multiple aliases to replace `resolveLoader.modules`
...
...
@@ -1278,17 +1277,14 @@ export default async function getBaseWebpackConfig(
or
:
WEBPACK_LAYERS
.
GROUP
.
nonClientServerTarget
,
},
},
{
test
:
/
[\\/]
.*
?\.
node$/
,
loader
:
isNodeServer
?
'next-server-binary-loader'
:
'next-error-browser-binary-loader'
,
// On server side bundling, only apply to app router, do not apply to pages router;
// On client side or edge runtime bundling, always error.
...(
isNodeServer
&&
{
issuerLayer
:
isWebpackAppLayer
,
}),
},
...(
isNodeServer
?
[]
:
[
{
test
:
/
[\\/]
.*
?\.
node$/
,
loader
:
'next-error-browser-binary-loader'
,
},
]),
...(
hasAppDir
?
[
{
...
...
packages/next/src/build/webpack/loaders/next-server-binary-loader.ts
deleted
100644 → 0
View file @
c7f7de96
import
type
{
webpack
}
from
'next/dist/compiled/webpack/webpack'
import
path
from
'path'
export
default
function
nextErrorBrowserBinaryLoader
(
this
:
webpack
.
LoaderContext
<
any
>
)
{
let
relativePath
=
path
.
relative
(
this
.
rootContext
,
this
.
resourcePath
)
if
(
!
relativePath
.
startsWith
(
'.'
))
{
relativePath
=
'./'
+
relativePath
}
return
`module.exports = __non_webpack_require__(
${
JSON
.
stringify
(
relativePath
)}
)`
}
test/development/app-dir/externalize-node-binary-browser-error/externalize-node-binary-browser-error.test.ts
View file @
b19f0980
...
...
@@ -4,26 +4,25 @@ import {
getRedboxDescription
,
getRedboxSource
,
}
from
'next-test-utils'
;(
process
.
env
.
TURBOPACK
?
describe
.
skip
:
describe
)(
'externalize-node-binary-browser-error'
,
()
=>
{
const
{
next
}
=
nextTestSetup
({
files
:
__dirname
,
})
it
(
'should error when import node binary on browser side'
,
async
()
=>
{
const
browser
=
await
next
.
browser
(
'/'
)
await
hasRedbox
(
browser
)
const
redbox
=
{
description
:
await
getRedboxDescription
(
browser
),
source
:
await
getRedboxSource
(
browser
),
}
// FIXME: er-enable when we have a better implementation of node binary resolving
describe
.
skip
(
'externalize-node-binary-browser-error'
,
()
=>
{
const
{
next
}
=
nextTestSetup
({
files
:
__dirname
,
})
expect
(
redbox
.
description
).
toBe
(
'Failed to compile'
)
expect
(
redbox
.
source
).
toMatchInlineSnapshot
(
`
it
(
'should error when import node binary on browser side'
,
async
()
=>
{
const
browser
=
await
next
.
browser
(
'/'
)
await
hasRedbox
(
browser
)
const
redbox
=
{
description
:
await
getRedboxDescription
(
browser
),
source
:
await
getRedboxSource
(
browser
),
}
expect
(
redbox
.
description
).
toBe
(
'Failed to compile'
)
expect
(
redbox
.
source
).
toMatchInlineSnapshot
(
`
"./node_modules/foo-browser-import-binary/binary.node
Error: Node.js binary module ./node_modules/foo-browser-import-binary/binary.node is not supported in the browser. Please only use the module on server side"
`
)
})
}
)
})
})
test/e2e/app-dir/externalize-node-binary/externalize-node-binary.test.ts
View file @
b19f0980
import
{
nextTestSetup
}
from
'e2e-utils'
describe
(
'externalize-node-binary'
,
()
=>
{
// FIXME: er-enable when we have a better implementation of node binary resolving
describe
.
skip
(
'externalize-node-binary'
,
()
=>
{
const
{
next
}
=
nextTestSetup
({
files
:
__dirname
,
})
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment