-
Notifications
You must be signed in to change notification settings - Fork 524
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 Support #1599
Comments
PnP is pretty neat, as it allows strong flexibility in linking, giving better performance. I actually thing it could be appealing to use in rule_nodejs for everything. |
How would this be done? As far as I understand .pnp.js resolves paths. Would this script be queried to generate build files? |
Apart from the pnp, a few things that I want from yarn 2 are:
I guess adopting yarn2 is not easy, as all the existing rules are built around the |
@ashi009 I've done a small prototype here #1856 and you're right it makes the implementation of the rules in this repository simple.
I havn't had much time to work on it lately so im open for any contributions here |
@Toxicable I have answers to some of those (I guess):
Probably like how rules_go handles this. Install dependencies in a repository rule declared directory and cache those files. But I guess it's not particularly remote execution friendly.
Let facebook deal with that, they are staffed to roll yarn2 forward.
I don't think supporting both sound. After all, people will only keep either |
Just to note: you can use Yarn v2 with
Facebook has nothing to do with Yarn https://yarnpkg.com/advanced/qa/#is-yarn-operated-by-facebook |
As a first step, it would be nice to enable node_repositories(
node_version = "14.8.0",
vendored_yarn = "@wksp//projects/support/bazel/toolchains/javascript:yarn",
yarn_version = "2.4.1",
)
yarn_install(
name="test"
args = ["--immutable"]
frozen_lockfile = False, # make work with yarn2
use_global_yarn_cache = False, # make work with yarn2
data = [":.yarnrc.yml"],
package_json = ":package.json",
yarn_lock = ":yarn.lock",
) With the following nodeLinker: node-modules
yarnPath: <...input correct path...>/bin/yarn.js For that to work I had to set the option as shown above and delete https://github.com/bazelbuild/rules_nodejs/blob/aa09b5796faaf2470b84246a8f00e6e27181c63b/internal/npm_install/npm_install.bzl#L431. So for minimal support I see three options:
I'd be happy to provide a PR, but am unsure which of these three options is preferred. Note that this is not yet real support as PNP will not work / a special |
To second @lummax, I think it would be awesome if Bazel could support yarn berry, which I'd consider as the only actively maintained version at the time of this writing. Working at least with the Are there any good next steps? Should the direction be to make modifications mentioned above, or should this be it's own yarn_berry_install? |
Any news on this? Using yarn berry currently. It is even speedier with pnp. |
There's a recent proposal to make pnpm semantics in npm itself. Given limited time of maintainers here I think we have to focus exclusively on the "canonical" tooling which is npm. If anyone wants to maintain yarn-for-Bazel it would be interesting to discuss forking that feature set to a separate repo. |
npm/rfcs#436 |
Fwiw this issue should rather be called "PnP support", since Yarn 2+ can install classical As for npm/rfcs#436, imo it should be another issue about broader "Symlink-based node_modules support" in general (which I think has value, Yarn as well will support it as another install strategy). Note however that, just like classical
npm isn't canonical by any means - the ecosystem seem fairly evenly split between package managers. In fact, even future Node release will tend to provide more options than just npm through the Corepack initiative. |
Hey @arcanis thanks for stopping by! I agree PnP support is the real request here. We are kinda novice at the details of what that means for the package manager itself. We probably have a conflated view of silos where you see the nuance of the layering. We are starting work on this soon. We start from tarballs downloaded from the registry, and have control needed to optimize how these end up on disk for each Bazel action. It's like we need to install every time we run node, so it has to be fast. Maybe we'll ping you for help! |
#3071 tracked supporting yarn 2+, let's continue using this one for supporting PnP. The former is solved at HEAD but the latter isn't, so I reopened this. |
This repo no longer supports any package managers. aspect-build/rules_js supports pnpm, and others are free to make rulesets specific to Yarn or npm (or whatever new flavor-of-the-month is invented next) |
Yarn 2.0 has been released. https://dev.to/arcanis/introducing-yarn-2-4eh1
This release has some massive changes, the biggest one is using PnP by default. https://next.yarnpkg.com/features/pnp
However, we can disable the use of this with a pluin for a first cut, then later on aim to support PnP.
The migration guide is here https://next.yarnpkg.com/advanced/migration
From what I can see, with keeping node_modules, there aren't too many big changes, needs more investigation.
The text was updated successfully, but these errors were encountered: