rspack icon indicating copy to clipboard operation
rspack copied to clipboard

[Feature Request]: Yarn PnP workspace

Open MarshallChen opened this issue 1 year ago β€’ 21 comments

System Info

System: OS: macOS 12.6.4 CPU: (8) x64 Intel(R) Core(TM) i7-4770HQ CPU @ 2.20GHz Memory: 2.54 GB / 16.00 GB Shell: 5.8.1 - /bin/zsh Binaries: Node: 14.17.4 - /private/var/folders/wv/hb8dy4gs4xq51jx7k9bbtthm0000gn/T/xfs-ce0be687/node Yarn: 3.4.1 - /private/var/folders/wv/hb8dy4gs4xq51jx7k9bbtthm0000gn/T/xfs-ce0be687/yarn npm: 6.14.14 - ~/.nvm/versions/node/v14.17.4/bin/npm

Details

is yarn workspace pnp mode supported already or its not support currently. I got lots of errors like this.


error[internal]: Resolve error
   β”Œβ”€ src/components/SomeComponent.js:8:1
   β”‚
 8 β”‚ β•­ import React, {
 9 β”‚ β”‚   useCallback,
10 β”‚ β”‚   useMemo,
11 β”‚ β”‚   useState,
12 β”‚ β”‚   useRef,
13 β”‚ β”‚ } from 'react';
   β”‚ ╰───────────────^ Failed to resolve react in /my/local/absolute/path/to/some/other/Component

Reproduce link

No response

Reproduce Steps

NODE_ENV=development yarn rspack serve --config ./rspack.config.js

MarshallChen avatar Mar 14 '23 07:03 MarshallChen

This feature is not yet supported

bvanjoi avatar Mar 14 '23 07:03 bvanjoi

@bvanjoi Thank you for your prompt response. Could you please let me know if this feature is planned for development and if so, can you provide an estimated timeline for release?

MarshallChen avatar Mar 14 '23 07:03 MarshallChen

@bvanjoi Thank you for your prompt response. Could you please let me know if this feature is planned for development and if so, can you provide an estimated timeline for release?

We have no plans to support it for now

bvanjoi avatar Mar 14 '23 07:03 bvanjoi

Thats bad news, I don't know how big the PnP community is, but since webpack v5 supports yarn PnP by default which means if you guys plan to support this it would be awesome.

MarshallChen avatar Mar 14 '23 07:03 MarshallChen

Thats bad news, I don't know how big the PnP community is, but since webpack v5 supports yarn PnP by default which means if you guys plan to support this it would be awesome.

Of course, PnP is a really great feature and part of the reason we don't support it at the moment is a lack of manpower, I'll be trying this out over the weekend, and if you're interested, feel free to mention PR, and we can make it happen together!

bvanjoi avatar Mar 14 '23 10:03 bvanjoi

Of course, PnP is a really great feature and part of the reason we don't support it at the moment is a lack of manpower, I'll be trying this out over the weekend, and if you're interested, feel free to mention PR, and we can make it happen together!

Lately I did some research and found this pnp-rust implementation of yarn PnP in rust written by yarn maintainer, maybe this repo could give some insights? Looks like this package still in WIP.

MarshallChen avatar Mar 17 '23 02:03 MarshallChen

Module Resolution is tricky - but this is a big one I think would be good to ensure we include its ecosystem appropriately

ScriptedAlchemy avatar Apr 04 '23 00:04 ScriptedAlchemy

It's still possible to use rspack with yarn 3 by using the node modules plugin/

https://yarnpkg.com/getting-started/migration#if-required-enable-the-node-modules-plugin

NyanHelsing avatar Apr 25 '23 11:04 NyanHelsing

@Boshen we need to consider support yarn pnp now

hardfist avatar Jan 11 '24 23:01 hardfist

How many feature requests have we received? It's been almost a year and this is the only feature request I see so far.

How much effort does it go into supporting yarn-pnp?

This feature seems to have a really low benefit–cost ratio.

Boshen avatar Jan 12 '24 03:01 Boshen

I don't know how many users are using yarn pnp, but both yarn、pnpm、webpack、nx support pnp, see https://pnpm.io/blog/2020/10/17/node-modules-configuration-options-with-pnpm#plugnplay-the-strictest-configuration , so don't think it's a outdated feature

hardfist avatar Jan 12 '24 03:01 hardfist

I'll consider it if we receive more feature requests. https://github.com/oxc-project/oxc_resolver/issues/53

Boshen avatar Jan 12 '24 03:01 Boshen

Many people might see a feature req. already exists and might consider it duplicative to request it again.

NyanHelsing avatar Mar 28 '24 16:03 NyanHelsing

Definitely not a outdated feature, in my opinion Yarn PnP is still a bit underrated mainly because of some compatibility issues during its beginnings. Strictly isolating dependencies (described in link shared by @hardfist above) is very powerful safeguard against weird bugs caused by importing transitive dependencies or using multiple conflicting versions etc., especially in larger codebase. Of course you can check (some of) it with linter, but PnP is preventing that potentially-errorneous import on the lowest level possible. Also having individual dependencies stored as a zip archive instead humongous node_modules with millions of extracted files performs operations a bit faster. Again something which might be improved by pnpm with hardlinks, but you don't always have a global cache to link from - especially when working in a isolated environment. And the icing on the cake is its zero-install strategy because it simplifies the workflow and saves some precious minutes in CI jobs. All in all we would really appreciate if this was supported!

malyzeli avatar May 27 '24 10:05 malyzeli

Definitely not a outdated feature, in my opinion Yarn PnP is still a bit underrated mainly because of some compatibility issues during its beginnings. Strictly isolating dependencies (described in link shared by @hardfist above) is very powerful safeguard against weird bugs caused by importing transitive dependencies or using multiple conflicting versions etc., especially in larger codebase. Of course you can check (some of) it with linter, but PnP is preventing that potentially-errorneous import on the lowest level possible. Also having individual dependencies stored as a zip archive instead humongous node_modules with millions of extracted files performs operations a bit faster. Again something which might be improved by pnpm with hardlinks, but you don't always have a global cache to link from - especially when working in a isolated environment. And the icing on the cake is its zero-install strategy because it simplifies the workflow and saves some precious minutes in CI jobs. All in all we would really appreciate if this was supported!

yeah, i agree it's not a outdated feature, we would love to support it in rspack if people help to contribute to support it

hardfist avatar May 31 '24 15:05 hardfist

yeah, i agree it's not a outdated feature, we would love to support it in rspack if people help to contribute to support it

@hardfist I would love to help if possible, but I'm not sure if I have the skills required... This PnP loader must be implemented in Rust I guess?

malyzeli avatar May 31 '24 16:05 malyzeli

yeah, i agree it's not a outdated feature, we would love to support it in rspack if people help to contribute to support it

@hardfist I would love to help if possible, but I'm not sure if I have the skills required... This PnP loader must be implemented in Rust I guess?

for performance reason, it would be better implemented in rust side

hardfist avatar Jun 03 '24 12:06 hardfist

There is a Rust implementation of the PnP module resolution algorithm here https://github.com/arcanis/pnp-rust

madjam002 avatar Jul 02 '24 12:07 madjam002

it seems when resolve hook is landed, yarn pnp workspace could be supported by resolve hook, cc @ahabhgk

hardfist avatar Jul 02 '24 12:07 hardfist

yarn pnp support is on the roadmap, we will implement it in near future

hardfist avatar Jul 12 '24 02:07 hardfist

@hardfist that's great news!

Is this roadmap published somewhere on GitHub? (I've found only tracking issue for v1.0)

malyzeli avatar Jul 29 '24 13:07 malyzeli