Skip to content
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

next dev --turbo unable to import ESM-only packages when marked with serverComponentsExternalPackages #64525

Closed
dstaley opened this issue Apr 15, 2024 · 3 comments · Fixed by #64918
Labels
bug Issue was opened via the bug report template. linear: turbopack Confirmed issue that is tracked by the Turbopack team. locked Module Resolution Module resolution (CJS / ESM, module resolving) Turbopack Related to Turbopack with Next.js.

Comments

@dstaley
Copy link
Contributor

dstaley commented Apr 15, 2024

Link to the code that reproduces this issue

https://github.com/dstaley/next-turbo-external-esm

To Reproduce

  1. npm run dev:turbo
  2. Get error "The package seems invalid. require() resolves to a EcmaScript module, which would result in an error in Node.js."
  3. npm run dev
  4. Confirm that the page renders

Current vs. Expected behavior

Current behavior:

Package srcset (serverComponentsExtenalPackages or default list) can't be external
The request srcset matches serverComponentsExtenalPackages (or the default list), but it can't be external:
The package seems invalid. require() resolves to a EcmaScript module, which would result in an error in Node.js.

Expected behavior:
When running with next dev --turbo ESM-only packages that have been marked with serverComponentsExternalPackages should still be correctly imported.

Provide environment information

Operating System:
  Platform: linux
  Arch: x64
  Version: #1 SMP Thu Jan 11 04:09:03 UTC 2024
  Available memory (MB): 32101
  Available CPU cores: 16
Binaries:
  Node: 18.19.0
  npm: 10.5.0
  Yarn: 1.22.22
  pnpm: 8.15.4
Relevant Packages:
  next: 14.2.1 // Latest available version is detected (14.2.1).
  eslint-config-next: N/A
  react: 18.2.0
  react-dom: 18.2.0
  typescript: 5.4.5
Next.js Config:
  output: N/A

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

Module resolution (CJS / ESM, module resolving), Turbopack (--turbo)

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

next dev (local)

Additional context

This reproduction uses the srcset package which is ESM-only.

PACK-2967

@dstaley dstaley added the bug Issue was opened via the bug report template. label Apr 15, 2024
@github-actions github-actions bot added Module Resolution Module resolution (CJS / ESM, module resolving) Turbopack Related to Turbopack with Next.js. labels Apr 15, 2024
@timneutkens timneutkens added the linear: turbopack Confirmed issue that is tracked by the Turbopack team. label Apr 16, 2024
vandorsx added a commit to vandorsx/next-jade that referenced this issue Jun 6, 2024
Needed for use with Turbopack (vercel/next.js#64525)
@RPDeshaies
Copy link

As a general FYI, the same issue also affects Shiki

localhost3000en-uscomponentsaccordions (Arc - CleanShot) 2024-06-06 at 12 31 49

@Rahim-444

This comment has been minimized.

ForsakenHarmony added a commit that referenced this issue Jun 19, 2024
### What?
Writes the async flag to the client reference manifest to support ESM
externals in app dir.

The `app-ssr` context can't have esm externals as that might cause a
module to be async in ssr but not on the client.

Closes PACK-2967
Fixes #64525
Copy link
Contributor

github-actions bot commented Jul 4, 2024

This closed issue has been automatically locked because it had no new activity for 2 weeks. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@github-actions github-actions bot added the locked label Jul 4, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 4, 2024
ForsakenHarmony added a commit that referenced this issue Aug 14, 2024
Writes the async flag to the client reference manifest to support ESM
externals in app dir.

The `app-ssr` context can't have esm externals as that might cause a
module to be async in ssr but not on the client.

Closes PACK-2967
Fixes #64525
ForsakenHarmony added a commit that referenced this issue Aug 15, 2024
Writes the async flag to the client reference manifest to support ESM
externals in app dir.

The `app-ssr` context can't have esm externals as that might cause a
module to be async in ssr but not on the client.

Closes PACK-2967
Fixes #64525
ForsakenHarmony added a commit that referenced this issue Aug 16, 2024
Writes the async flag to the client reference manifest to support ESM
externals in app dir.

The `app-ssr` context can't have esm externals as that might cause a
module to be async in ssr but not on the client.

Closes PACK-2967
Fixes #64525
lubieowoce pushed a commit that referenced this issue Sep 3, 2024
Writes the async flag to the client reference manifest to support ESM
externals in app dir.

The `app-ssr` context can't have esm externals as that might cause a
module to be async in ssr but not on the client.

Closes PACK-2967
Fixes #64525
lubieowoce pushed a commit that referenced this issue Sep 3, 2024
Writes the async flag to the client reference manifest to support ESM
externals in app dir.

The `app-ssr` context can't have esm externals as that might cause a
module to be async in ssr but not on the client.

Closes PACK-2967
Fixes #64525
lubieowoce pushed a commit that referenced this issue Sep 3, 2024
Writes the async flag to the client reference manifest to support ESM
externals in app dir.

The `app-ssr` context can't have esm externals as that might cause a
module to be async in ssr but not on the client.

Closes PACK-2967
Fixes #64525
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue was opened via the bug report template. linear: turbopack Confirmed issue that is tracked by the Turbopack team. locked Module Resolution Module resolution (CJS / ESM, module resolving) Turbopack Related to Turbopack with Next.js.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants