web-infra-dev / rspack

The fast Rust-based web bundler with webpack-compatible API 🦀️
https://rspack.dev
MIT License
9.71k stars 559 forks source link

[Feature Request]: Yarn PnP workspace #2236

Open MarshallChen opened 1 year ago

MarshallChen commented 1 year ago

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
bvanjoi commented 1 year ago

This feature is not yet supported

MarshallChen commented 1 year ago

@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?

bvanjoi commented 1 year ago

@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

MarshallChen commented 1 year ago

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.

bvanjoi commented 1 year ago

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!

MarshallChen commented 1 year ago

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.

ScriptedAlchemy commented 1 year ago

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

NyanHelsing commented 1 year ago

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

hardfist commented 9 months ago

@Boshen we need to consider support yarn pnp now

Boshen commented 9 months ago

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.

hardfist commented 9 months ago

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

Boshen commented 9 months ago

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

NyanHelsing commented 7 months ago

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

malyzeli commented 5 months ago

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!

hardfist commented 5 months ago

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

malyzeli commented 5 months ago

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?

hardfist commented 5 months ago

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

madjam002 commented 4 months ago

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

hardfist commented 4 months ago

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

hardfist commented 3 months ago

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

malyzeli commented 3 months ago

@hardfist that's great news!

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

hardfist commented 2 months ago

https://github.com/web-infra-dev/rspack/pull/7639 @malyzeli you can track here

chess1 commented 2 months ago

Hi all, any updates on this feature? (@hardfist) :)

hardfist commented 2 months ago

Hi all, any updates on this feature? (@hardfist) :)

still working on it