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] Yarn PnP installs #2369

Closed
arcanis opened this issue Oct 26, 2022 · 4 comments
Closed

[Turbopack] Yarn PnP installs #2369

arcanis opened this issue Oct 26, 2022 · 4 comments

Comments

@arcanis
Copy link

arcanis commented Oct 26, 2022

Which project is this feature idea for?

Turbopack

(note: I saw #693, and specifically #693 (comment), but that issue was about Turborepo, not Turbopack. I checked with @sokra who confirmed that the goal is for Turbopack to eventually support everything Webpack supports, hence this issue specifically about Turbopack)

Describe the feature you'd like to request

Turbopack isn't compatible with Yarn PnP installs, unlike both Webpack and Esbuild. There are two reasons for this:

  • Turbopack doesn't implement the PnP resolution (the formal spec is here, Esbuild followed it in their implementation)
  • Turbopack doesn't support accessing files from zip archives (see the "Package Locations" section of the spec)

Reproduction

yarn create next-app my-app && cd my-app
yarn set version canary
yarn config set nodeLinker pnp
yarn install
yarn next dev

Describe the solution you'd like

Two options:

  • Implement the zip fs logic within Turbopack, and make it take into account the .pnp.data.json data file as per spec

    • It'd be useful if someone familiar with the Turbopack codebase could share some pointers showing where we can find the relevant sections, and what would be the potential problems
  • Allow Node plugins to handle specific file loading and resolution (like Webpack plugins; but then it'd be slower than necessary, and wouldn't be supported natively as it currently is in other bundlers)

Describe alternatives you've considered

In the meantime users can workaround this problem by reverting to the node-modules linker, but they don't get the PnP benefits anymore (fast installs, ghost dependency protection, semantic erroring, ...), which is often a blocker.

yarn config set nodeLinker node-modules
@IhsenBouallegue
Copy link

Any updates? This would be pretty awesome, but I assume it's a huge undertaking.

@arcanis
Copy link
Author

arcanis commented Sep 19, 2023

Not directly related to Turbopack, but I implemented the PnP resolution algorithm (whose specs are here) as a Rust package, see here. It's still a bit experimental, but I'm more than open to merge PRs and make it compatible with Turbopack.

@robertwt7
Copy link

Yarn 4 is great, I don't know why vercel doesn't want to implement the PnP resolution. It'll help us a lot in the CI build time and the only package that's not supported right now in my repo is turbo

@ForsakenHarmony
Copy link
Contributor

Closing as a duplicate of vercel/next.js#42651

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants