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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

@angular/core/testing imports @angular/compiler without it being a listed dependency #38096

Open
bgotink opened this issue Jul 16, 2020 · 2 comments 路 May be fixed by #55610
Open

@angular/core/testing imports @angular/compiler without it being a listed dependency #38096

bgotink opened this issue Jul 16, 2020 · 2 comments 路 May be fixed by #55610
Labels
area: build & ci Related the build and CI infrastructure of the project area: core Issues related to the framework runtime area: dev-infra Issues related to Angular's own dev infra (build, test, CI, releasing) P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
Milestone

Comments

@bgotink
Copy link

bgotink commented Jul 16, 2020

馃悶 bug report

Affected Package

@angular/core

Is this a regression?

No

Description

@angular/core/testing imports @angular/compiler, which results in an error in environments where dependencies are enforced strictly, e.g. yarn 2's PnP.

There's a simple workaround in yarn 2, via package extensions in the .yarnrc.yml. The repro shows this as well. As such this isn't very blocking.

The actual solution would be to add an (optional) peer dependency on @angular/compiler in @angular/core. Optional peer dependencies are supported in yarn, pnpm, and npm >= 6.11. I'm not sure about cnpm.

馃敩 Minimal Reproduction

  1. Clone https://github.com/bgotink/angular-core-dependency-repro.git
  2. Run yarn ng test to see the issue.
  3. To see it work with the workaround, uncomment the commented lines in .yarnrc.yml, run yarn and try yarn ng test again.

馃敟 Exception or Error


ERROR in ./.yarn/$$virtual/@angular-core-virtual-211be554a0/0/cache/@angular-core-npm-10.0.4-7ac9451da3-086e71325b.zip/node_modules/@angular/core/fesm2015/testing.js
Module not found: Error: @angular/core tried to access @angular/compiler, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.

Required package: @angular/compiler (via "@angular/compiler")
Required by: @angular/core@virtual:bb6003ff96d426a26f646cc35ceffa141c24878228a2fef52d1ec249699aa32723eb66782cadf256682b54695969dc1ed6146429985526143c5b0e1086b2e58a#npm:10.0.4 (via /private/var/folders/_d/ch2kc4h960d10cy_2c41qqzw0000gn/T/tmp.xuExZBos3m/repro-core-dependency/.yarn/$$virtual/@angular-core-virtual-211be554a0/0/cache/@angular-core-npm-10.0.4-7ac9451da3-086e71325b.zip/node_modules/@angular/core/fesm2015/testing.js)

 @ ./.yarn/$$virtual/@angular-core-virtual-211be554a0/0/cache/@angular-core-npm-10.0.4-7ac9451da3-086e71325b.zip/node_modules/@angular/core/fesm2015/testing.js 9:0-51 1164:59-73
 @ ./src/test.ts

馃實 Your Environment

Angular Version:


$ yarn ng version
An unhandled exception occurred: ENOENT: no such file or directory, scandir '/private/var/folders/_d/ch2kc4h960d10cy_2c41qqzw0000gn/T/tmp.xuExZBos3m/repro-core-dependency/node_modules'
See "/private/var/folders/_d/ch2kc4h960d10cy_2c41qqzw0000gn/T/ng-nvGAj1/angular-errors.log" for further details.

Anything else relevant?

Using yarn 2 (aka berry) with the PnP linker

@AndrewKushnir AndrewKushnir added the area: core Issues related to the framework runtime label Jul 21, 2020
@ngbot ngbot bot added this to the needsTriage milestone Jul 21, 2020
@atscott atscott added area: build & ci Related the build and CI infrastructure of the project area: dev-infra Issues related to Angular's own dev infra (build, test, CI, releasing) labels Oct 19, 2020
@AndrewKushnir AndrewKushnir added the P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent label Oct 28, 2020
@ngbot ngbot bot modified the milestones: needsTriage, Backlog Oct 28, 2020
@sod
Copy link
Contributor

sod commented Feb 12, 2021

As the reproduction is offline: The packageExtension entry in the .yarnrc.yml file looks like:

packageExtensions:
  "@angular/core@*":
    dependencies:
      "@angular/compiler": '*'

just yarn install again so yarn creates a new pnp file with now @angular/core being allowed to require @angular/compiler

https://yarnpkg.com/configuration/yarnrc#packageExtensions

@bgotink
Copy link
Author

bgotink commented Feb 12, 2021

Oh thanks for noticing, it turns out I had the repro repo set to private. It should be up (again?) now.

emilrowland added a commit to emilrowland/angular that referenced this issue May 1, 2024
This fixes an issue with packages managers likes pmpm
that will not link the @angular/compiler package to the @angular/core
package if it is not listed as a peer dependency.
I added it as optional peer dependency as it's only used in special cases.

Fixes angular#38096
@emilrowland emilrowland linked a pull request May 1, 2024 that will close this issue
14 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: build & ci Related the build and CI infrastructure of the project area: core Issues related to the framework runtime area: dev-infra Issues related to Angular's own dev infra (build, test, CI, releasing) P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants