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

Turbopack does not import from exports correctly when *.ts and *.tsx are specified #71001

Open
RhysSullivan opened this issue Oct 9, 2024 · 2 comments
Labels
bug Issue was opened via the bug report template. linear: turbopack Confirmed issue that is tracked by the Turbopack team. Turbopack Related to Turbopack with Next.js.

Comments

@RhysSullivan
Copy link

Link to the code that reproduces this issue

https://github.com/RhysSullivan/bun-transpile-packages-turbopack

To Reproduce

To validate it is broken with Turbo:

The only difference between these packages is the exports section of package.json

To validate it works with Turbo disabled

Current vs. Expected behavior

Turbopack should work with multiple file extensions in the exports field

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 23.4.0: Fri Mar 15 00:19:22 PDT 2024; root:xnu-10063.101.17~1/RELEASE_ARM64_T8112
  Available memory (MB): 16384
  Available CPU cores: 8
Binaries:
  Node: 20.13.1
  npm: 10.5.2
  Yarn: N/A
  pnpm: 9.1.2
Relevant Packages:
  next: 15.0.0-canary.181 // Latest available version is detected (15.0.0-canary.181).
  eslint-config-next: N/A
  react: 19.0.0-rc-2d16326d-20240930
  react-dom: 19.0.0-rc-2d16326d-20240930
  typescript: 5.3.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 dev (local), next build (local), next start (local)

Additional context

No response

@RhysSullivan RhysSullivan added the bug Issue was opened via the bug report template. label Oct 9, 2024
@github-actions github-actions bot added the Turbopack Related to Turbopack with Next.js. label Oct 9, 2024
@mischnic mischnic added the linear: turbopack Confirmed issue that is tracked by the Turbopack team. label Oct 9, 2024
@mischnic
Copy link
Contributor

mischnic commented Oct 11, 2024

In Node (which introduced the exports field that Next.js/Webpack/Turbopack are imitating), this is actually the intended behavior. It always uses the first entry in the array.

The reason it currently works in Next.js without Turbo is that Next.js is still using Webpack 5.90.0, and this was only changed back to be compatible with Node in 5.94.0

(There's a section about this in the Webpack docs as well, under the "Alternatives" section: https://webpack.js.org/guides/package-exports/#alternatives)

@RhysSullivan
Copy link
Author

Interesting thanks, looks like this isn't a bug then thanks for investigating

Might be worth throwing in a warning to turbopack if when using an internal package w/ an exports array, that only the first entry will be used? The error is a little unintuitive at the moment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue was opened via the bug report template. 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

2 participants