You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Build the rust-lib package (needs a working rust installation).
pnpm -C packages/rust-lib build
Try to build the web-app package.
pnpm -C packages/web-app build
Current vs. Expected behavior
I expect the greet function from the rust-lib package to be imported and called. Instead the web-app build process throws the following error: [cause]: Error: Cannot find module '../rust-lib/dist/index.node'.
Hmm, pretty weird, looks like some kind of path resolution issue
import { ... } from 'rust-lib' is somehow resolved to a path that's relative to packages/web-app, the project root (require("../rust-lib/dist/index.node").
But then that require() call is placed in packages/web-app/.next/server/app/page.js, so the ../ ends up being incorrect... Manually editing page.js to do require("../../../../rust-lib/dist/index.node") fixes the problem.
This still seems to be a problem in 15.0.2, but in a different way.
We've removed the code that was resolving paths incorrectly in #71723, so the original error is no longer reproducible.
But now, it's failing with
Module parse failed: Unexpected character '�' (1:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
(Source code omitted for this binary file)
Import trace for requested module:
../rust-lib/dist/index.node
./src/app/page.tsx
○ Compiling /_error ...
⨯ ../rust-lib/dist/index.node
...and making the package external doesn't seem to have any effect, which is pretty suspicious:
this makes me suspect that something's buggy with serverExternalPackages that point to local packages
(edit: i think this is because in our optOutBundlingPackageRegex we assume that the resolved path contains /node_modules/, but "rust-lib" resolves to a path that doesn't have it. because the node_modules symlink for rust-lib is resolved to its real path)
Link to the code that reproduces this issue
https://github.com/daanboer/next-load-native-module
To Reproduce
Install dependencies.
Build the
rust-lib
package (needs a working rust installation).Try to build the
web-app
package.Current vs. Expected behavior
I expect the
greet
function from therust-lib
package to be imported and called. Instead theweb-app
build process throws the following error:[cause]: Error: Cannot find module '../rust-lib/dist/index.node'
.Full build logs
Provide environment information
Operating System: Platform: linux Arch: x64 Version: #1-NixOS SMP PREEMPT_DYNAMIC Thu Aug 29 15:33:59 UTC 2024 Available memory (MB): 31938 Available CPU cores: 20 Binaries: Node: 22.8.0 npm: N/A Yarn: N/A pnpm: 9.10.0 Relevant Packages: next: 15.0.0 // Latest available version is detected (15.0.0). eslint-config-next: N/A react: 18.3.1 react-dom: 18.3.1 typescript: 5.6.2 Next.js Config: output: N/A
Which area(s) are affected? (Select all that apply)
Not sure
Which stage(s) are affected? (Select all that apply)
next dev (local), next build (local)
Additional context
The same setup compiles when using Next.js
v14.2.13
forweb-app
. It seems that the bug is introduced inv14.2.14
.The text was updated successfully, but these errors were encountered: