bun icon indicating copy to clipboard operation
bun copied to clipboard

Package isolation on a Next.js app: `Can't resolve './out/isolated_vm'`

Open baptisteArno opened this issue 6 months ago • 3 comments

What version of Bun is running?

1.3.0+b0a6feca5

What platform is your computer?

Darwin 25.0.0 arm64 arm

What steps can reproduce the bug?

  1. Clone Turborepo kitchen-sink example
  2. Make sure to use bun v1.30 to have package isolation
  3. Import isolated-vm anywhere in storefront (Next.js app)
  4. Run build

What is the expected behavior?

The same steps work fine with hoisted strategy

What do you see instead?

Module not found: Can't resolve './out/isolated_vm' error

Additional information

No response

baptisteArno avatar Oct 14 '25 13:10 baptisteArno

ENG-20975

linear[bot] avatar Oct 14 '25 13:10 linear[bot]

Most likely due to how EXTERNAL_PACKAGES is matched against their optOutBundlingPackageRegex regex?

https://github.com/vercel/next.js/blob/d0ffcfcb3774731d1baef017c0c329ef2d1d6c89/packages/next/src/build/webpack-config.ts#L876C3-L885C4

isolated_vm is indeed listed in their default external packages list: https://github.com/vercel/next.js/blob/canary/packages/next/src/lib/server-external-packages.json

baptisteArno avatar Oct 15 '25 09:10 baptisteArno

The resolvers fail to consistently resolve these relative symlinks when resolving from different starting points (importing module context vs project root), causing the verification to fail.

Both webpack and turbopack are failing here

baptisteArno avatar Dec 04 '25 14:12 baptisteArno