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

Yarn PnP #53

Closed
Boshen opened this issue Jan 12, 2024 · 10 comments · Fixed by #217
Closed

Yarn PnP #53

Boshen opened this issue Jan 12, 2024 · 10 comments · Fixed by #217
Assignees

Comments

@Boshen
Copy link
Member

Boshen commented Jan 12, 2024

https://yarnpkg.com/features/pnp

Please +1 and link your public repository if you're using yarn pnp.

@Boshen
Copy link
Member Author

Boshen commented Jan 12, 2024

https://github.com/sveltejs/kit/issues/11578#issuecomment-1884974247

Yarn PnP is broken, and we don't support it — if it ever worked, it was by accident. It is a frequent source of misery for OSS maintainers, and we strongly recommend using nodeLinker: 'node-modules' or (better) just using npm/pnpm.

@Boshen Boshen closed this as not planned Won't fix, can't repro, duplicate, stale Feb 6, 2024
@Boshen Boshen reopened this Feb 6, 2024
@ematipico
Copy link
Collaborator

Personally, I don't think this resolver should support Yarn PnP

@Boshen
Copy link
Member Author

Boshen commented Jul 9, 2024

Please +1 and link your public repository if you're using yarn pnp.

Please link your project with yarn pnp setup here for the possibility of reopening this issue.

Personally, I don't think this resolver should support Yarn PnP

We can provide yarn pnp support with a feature flag.

Supporting yarn pnp is a big maintenance burden for us, but I'm happy to add another maintainer who is willing to implement, maintain and triage issues related with yarn pnp, since triaging a resolution error usually takes an hour at least.

If I get a bug report that looks similar to the 120+ open issues in yarn relating to pnp, how much time should I spend on triaging them? https://github.com/search?q=repo%3Ayarnpkg%2Fberry+pnp++&type=issues&state=open

@BasixKOR
Copy link

BasixKOR commented Jul 9, 2024

Probably the biggest and most useful reference for Yarn monorepo would be Yarn itself: https://github.com/yarnpkg/berry

AFAIK Yarn (berry) is still used well on corporate projects due to its highly configurable nature but hasn't seen wide usage outside of it. I'd love to help this issue but I think I should look more deep into oxc before promising anything ;)

@arcanis
Copy link
Contributor

arcanis commented Jul 9, 2024

Note that I implemented a PnP resolver in Rust as a package: https://github.com/arcanis/pnp-rust; I had a prototype integrating it with Parcel and the work was quite minimal.

So if you're interested, I'm more than happy to help integrate the pnp-rs crate with oxc, and move it to the official yarnpkg org so it keeps being maintained in the future.

If I get a bug report that looks similar to the 120+ open issues in yarn relating to pnp, how much time should I spend on triaging them? https://github.com/search?q=repo%3Ayarnpkg%2Fberry+pnp++&type=issues&state=open

The repo issues aren't the right metric - rather, the interesting one is Esbuild, which has natively supported PnP for a while. There's been ~60 issues in ~3 years, most of them closed. In your case it'd be lower if you leveraged the pnp-rs crate, as we'd take ownership of many of these issues.

@Boshen
Copy link
Member Author

Boshen commented Jul 9, 2024

Note that I implemented a PnP resolver in Rust as a package: https://github.com/arcanis/pnp-rust; I had a prototype integrating it with Parcel and the work was quite minimal.

So if you're interested, I'm more than happy to help integrate the pnp-rs crate with oxc, and move it to the official yarnpkg org so it keeps being maintained in the future.

If I get a bug report that looks similar to the 120+ open issues in yarn relating to pnp, how much time should I spend on triaging them? https://github.com/search?q=repo%3Ayarnpkg%2Fberry+pnp++&type=issues&state=open

The repo issues aren't the right metric - rather, the interesting one is Esbuild, which has natively supported PnP for a while. There's been ~60 issues in ~3 years, most of them closed. In your case it'd be lower if you leveraged the pnp-rs crate, as we'd take ownership of many of these issues.

Thank you @arcanis. The pnp-rs crate + redirecting issues is a good solution.

Let's collaborate and integrate. Just ping me if you need anything from me.

@Boshen
Copy link
Member Author

Boshen commented Jul 19, 2024

The Rust side is complete.

For future reference:

  • Calling require.resolve('pnpapi') will return the path to the current .pnp.cjs file
  • Calling require('module').findPnpApi?.(cwd) will crawl the filesystem starting from cwd (which can be __dirname, process.cwd(), ...)

Rust option is

pub pnp_manifest: Option<pnp::Manifest>,

Feature is

oxc-resolver/Cargo.toml

Lines 105 to 106 in 5310589

## [Yarn Plug'n'Play](https://yarnpkg.com/features/pnp)
yarn_pnp = ["pnp"]

@Boshen
Copy link
Member Author

Boshen commented Jul 19, 2024

Now I need a collaborator to help me test this in their tool.

@psychobolt
Copy link

I'm willing to test, but I'm not a contributor. I am looking to set the resolution for @swc-node/register/oxc-resolver@npm:??? to point to a version that includes this fix.

SoonIter pushed a commit to SoonIter/rspack-resolver that referenced this issue Jul 23, 2024
SoonIter added a commit to web-infra-dev/rspack-resolver that referenced this issue Jul 23, 2024
* chore: update lockfiles

* Release v1.9.4

* feat(napi): expose module type info in ResolveResult (#223)

* chore: update devDependencies

* Release v1.10.0

* fix(napi): update buggy NAPI-RS versions (#225)

fix(napi): update buggy @napi-rs/cli

* ci: all `--all-features` to various commands

* chore(deps): update crate-ci/typos action to v1.23.2

* chore(deps): update rust crate napi to 3.0.0-alpha

* chore(deps): update rust crates

* ci: add x86_64-unknown-freebsd target (#226)

* fix: resolve module `ipaddr.js` correctly when `extensionAlias` is provided (#228)

closes #227

* Release v1.10.1

* ci: fix FreeBSD build (#230)

* ci: add `needs` check in build-freebsd

* ci: publish needs build-freebsd (#232)

* Release v1.10.2

* feat: Yarn PnP (#217)

Part of oxc-project/oxc-resolver#53

* chore(deps): update rust crate napi-derive to 3.0.0-alpha

* chore(deps): update rust crates

* chore(deps): fix the lock

---------

Co-authored-by: Boshen <[email protected]>
Co-authored-by: LongYinan <[email protected]>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Maël Nison <[email protected]>
@Boshen
Copy link
Member Author

Boshen commented Aug 23, 2024

This is now behind a feature flag

oxc-resolver/Cargo.toml

Lines 105 to 106 in 509dc00

## [Yarn Plug'n'Play](https://yarnpkg.com/features/pnp)
yarn_pnp = ["pnp"]

Feel free to create an issue for integration.

@Boshen Boshen closed this as completed Aug 23, 2024
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

Successfully merging a pull request may close this issue.

5 participants