Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Turbopack crashes with SWC plugins when using absolute paths in swcPlugins configuration #78156

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
jantimon opened this issue Apr 14, 2025 · 1 comment
Labels
linear: turbopack Confirmed issue that is tracked by the Turbopack team. Turbopack Related to Turbopack with Next.js.

Comments

@jantimon
Copy link
Contributor

jantimon commented Apr 14, 2025

Link to the code that reproduces this issue

https://github.com/jantimon/yak-n-run

To Reproduce

  1. Create a Next.js project with a custom SWC plugin
  2. Configure the SWC plugin using require.resolve() which returns an absolute path
    a. clone https://github.com/jantimon/yak-n-run
    b. (alternative): use require resolve directly
nextConfig.experimental.swcPlugins.push([
  require.resolve("some-swc-plugin"),
  {
    // ...
  },
])
  1. Run next build --turbopack

Current vs. Expected behavior

Current behavior:
Turbopack immediately crashes with an error message indicating that the plugin path does not exist:

./
Module not found: Can't resolve './path/to/yak-n-run/node_modules/yak-swc/target/wasm32-wasip1/release/yak_swc.wasm'
server relative imports are not implemented yet. Please try an import relative to the file you are importing from.

./
Module not found: Can't resolve '/path/to/yak-n-run/node_modules/yak-swc/target/wasm32-wasip1/release/yak_swc.wasm'


https://nextjs.org/docs/messages/module-not-found


    at <unknown> (https://nextjs.org/docs/messages/module-not-found)
    at <unknown> (https://nextjs.org/docs/messages/module-not-found)
    at <unknown> (https://nextjs.org/docs/messages/module-not-found)
    at <unknown> (https://nextjs.org/docs/messages/module-not-found)
    at <unknown> (https://nextjs.org/docs/messages/module-not-found)
    at <unknown> (https://nextjs.org/docs/messages/module-not-found)
    at <unknown> (https://nextjs.org/docs/messages/module-not-found)
    at <unknown> (https://nextjs.org/docs/messages/module-not-found)

The error message shows the path with a leading dot (e.g., ./foo/bar/yak-n-run/node_modules/yak-swc/target/wasm32-wasip1/release/yak_swc.wasm) - so I guess it is trying to resolve it relatively

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.3.0: Thu Jan  2 20:24:16 PST 2025; root:xnu-11215.81.4~3/RELEASE_ARM64_T6000
  Available memory (MB): 65536
  Available CPU cores: 10
Binaries:
  Node: 20.18.2
  npm: 10.8.2
  Yarn: 1.22.22
  pnpm: 10.2.0
Relevant Packages:
  next: 15.3.1-canary.7 // Latest available version is detected (15.3.1-canary.7).
  eslint-config-next: N/A
  react: 19.1.0
  react-dom: 19.1.0
  typescript: 5.8.3
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Turbopack

Which stage(s) are affected? (Select all that apply)

next build (local)

Additional context

✅ Works correctly with webpack (without --turbopack)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
linear: turbopack Confirmed issue that is tracked by the Turbopack team. Turbopack Related to Turbopack with Next.js.
Projects
None yet
Development

No branches or pull requests

3 participants
@jantimon @mischnic and others