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 2.0 Support Status #16980

Open
clydin opened this issue Feb 14, 2020 · 6 comments
Open

Yarn 2.0 Support Status #16980

clydin opened this issue Feb 14, 2020 · 6 comments

Comments

@clydin
Copy link
Member

@clydin clydin commented Feb 14, 2020

With the release of Yarn 2.0, many users may be interested in trying out the new version of the package manager with the Angular CLI. As of 9.0, the Angular CLI does not natively support Yarn 2.0 and its new package management strategy named Plug’n’Play (PnP). However, native support is currently and actively being investigated with several initial steps already in place. Native support is tentatively scheduled for inclusion in 10.0 or beyond with the goal of integrating new major versions of upstream dependencies that provide native support.

For those that are interested in experimenting with building applications using the new package manager, you can use the following instructions to workaround the current issues.
WARNING: This is not recommended for use with deployed applications and should not be used in a production environment.

  1. Install the workspace dependencies using Yarn 2.0
  2. Install the pnpify package: yarn add -D @yarnpkg/pnpify
  3. Unplug all Angular related packages including third-party libraries used within the application via yarn unplug <package_name>. This should include at a minimum all @angular scoped packages.
  4. If using the E2E command, the webdriver-manager package also needs to be unplugged: yarn unplug webdriver-manager

Once these steps are complete, Angular CLI operations such as serve or build can be used by executing yarn pnpify ng build or yarn pnpify ng serve, respectively.

Please note that manually running the ngcc command with or without the pnpify utility does not currently work.

If any issues are encountered using the workaround steps or for Yarn 2.0 in general, please open a separate issue detailing the problem.

@clydin clydin changed the title Yarn PnP Support Status Yarn 2.0 Support Status Feb 14, 2020
@larixer
Copy link

@larixer larixer commented Feb 15, 2020

Another way of making Angular 9 work with Yarn 2.0 is to use nodeLinker: node-modules in <project_root>/.yarnrc.yml, this will use node_modules scheme for installation.

Yarn team is investing into node_modules support and trying to make it work better than it was in Yarn 1.x, but the future is definitely not with node_modules. node_modules scheme has fundamental technical limitations that makes it not as scalable as Plug'n'Play scheme both in terms of projects size (things become extremely slow on projects with lots of dependencies) and in terms of features we can attach to the scheme (it is hard to keep up with good installation performance even for minimal set of features).

@ngbot ngbot bot modified the milestone: Backlog Feb 15, 2020
@clydin clydin pinned this issue Feb 18, 2020
@andreialecu
Copy link
Contributor

@andreialecu andreialecu commented Feb 25, 2020

Some possibly relevant information regarding improving yarn 2.0 support:

#14841 (comment)

Replacing read-package-tree with a createRequire implementation might be a first step in that direction. The comment above links to a PR in gatsby where they did something similar.

I noticed that @clydin authored most of the code in that file, perhaps #14841 could be fixed in the process as well.

@Langstra
Copy link

@Langstra Langstra commented Jul 11, 2020

@klemenoslaj
Copy link

@klemenoslaj klemenoslaj commented Sep 13, 2020

With nodeLinker configured to node_modules I was able to migrate a small Angular CLI project without a single issue, with zero installs configuration even.

@ronnyek
Copy link

@ronnyek ronnyek commented Oct 6, 2020

I'm not suggesting it would be trivial to fix this and have it automatically work the way yarn 2 works by default out of box, in addition to continuing to support NPM... but I would say this would probably go a long ways to improve developer experience.

Can't wait until node_modules (at least the way it works today) is a thing of the past.

@andreialecu
Copy link
Contributor

@andreialecu andreialecu commented Oct 6, 2020

There is ongoing work right now in @angular core packages to rework things in a way that would allow Yarn2+PnP to work natively.

You can read more and track the progress here: angular/angular#38099

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
8 participants
You can’t perform that action at this time.