-
Notifications
You must be signed in to change notification settings - Fork 27.1k
@angular/core/testing imports @angular/compiler without it being a listed dependency #38096
Copy link
Copy link
Closed
Closed
Copy link
Labels
P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentAn issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: build & ciRelated the build and CI infrastructure of the projectRelated the build and CI infrastructure of the projectarea: coreIssues related to the framework runtimeIssues related to the framework runtimearea: dev-infraIssues related to Angular's own dev infra (build, test, CI, releasing)Issues related to Angular's own dev infra (build, test, CI, releasing)
Milestone
Description
🐞 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
- Clone https://github.com/bgotink/angular-core-dependency-repro.git
- Run
yarn ng testto see the issue. - To see it work with the workaround, uncomment the commented lines in
.yarnrc.yml, runyarnand tryyarn ng testagain.
🔥 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
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentAn issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: build & ciRelated the build and CI infrastructure of the projectRelated the build and CI infrastructure of the projectarea: coreIssues related to the framework runtimeIssues related to the framework runtimearea: dev-infraIssues related to Angular's own dev infra (build, test, CI, releasing)Issues related to Angular's own dev infra (build, test, CI, releasing)