-
-
Notifications
You must be signed in to change notification settings - Fork 602
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
feat(core): add Yarn PnP support #7639
Conversation
✅ Deploy Preview for rspack canceled.
|
!bench |
⏳ Triggered benchmark: Open |
packages/rspack-test-tools/tests/configCases/resolve/pnp/.yarn/install-state.gz
Outdated
Show resolved
Hide resolved
This pull request has been automatically marked as stale because it has not had recent activity. If this pull request is still relevant, please leave any comment (for example, "bump"). |
Bump, I still have it in my backlog (I've been in on-and-off paternity leave since August, so my bandwidth has been limited - but I'm still very interested to bring it to the finish line). |
thank you, we'll continue investigating yarn pnp support |
This pull request has been automatically marked as stale because it has not had recent activity. If this pull request is still relevant, please leave any comment (for example, "bump"). |
bump |
d14db9f
to
43b4278
Compare
43b4278
to
3eaae99
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great to me! Just a couple of nits.
Co-authored-by: Maël Nison <[email protected]>
📝 Benchmark detail: Open task failure |
📝 Benchmark detail: Open
|
📝 Benchmark detail: Open
|
0c97691
to
54abf58
Compare
Co-authored-by: neverland <[email protected]>
Co-authored-by: neverland <[email protected]>
nice work!!! |
Summary
This pull request implements the Yarn PnP feature and closes #2236. Special thanks to @arcanis for implementing PnP resolution in rspack_resolver.
Differences from Webpack Implementation
Intercepting FS on the Rust Side
A significant part of Webpack’s implementation is that it leverages PnP runtime to intercept all filesystem calls in Node.js via the .pnp.cjs file, correctly handling Yarn’s zip file paths as regular files. However, intercepting all filesystem calls on the JavaScript side incurs a significant performance cost in Rspack. Therefore, for performance reasons, Rspack intercepts standard filesystem calls in a custom native FS implementation in rust side.
Enabling PnP Only When resolve.enablePnp is Set
For performance optimization, Yarn PnP is enabled by default only when running in a PnP environment (when
process.versions.pnp
is truthy). This avoids unnecessary overhead for users not utilizing Yarn PnP.Limitations
After discussions with @arcanis, supporting multiple Yarn PnP resolver instances would complicate the implementation and negatively impact cache efficiency. Since multiple PnP instances are rarely used in most Yarn PnP applications, Rspack supports only a single PnP resolver instance. Consequently, only the root
resolve.enablePnp
setting is effective, and settings within module.rule have no impact. This approach suffices for most Yarn PnP applications.Implementation Caveats
Yarn PnP requires filesystem interception for zip file calls, coupled the filesystem implementation with
resolve.enablePnP
configuration. Introducing a rootenablePnP
setting might decouple the filesystem and resolver but could also add confusion and complexity to the configuration. Therefore, I have adhered to the current implementation.Checklist