Bug: Build adds peerDependecies from test files to package output.
See original GitHub issueCurrent Behavior
I have an Angular lib that I added a peer dependency of @angular/core
and rxjs
, when I build the package I see that 2 peerDependecies were added by nx during build time.
The issue is that these dependencies are not part of the lib and are used in the test-steup
Pre-build package.json
:
"peerDependencies": {
"@angular/core": ">=12.0.0",
"rxjs": ">=6.0.0"
},
Post-build package.json
:
"peerDependencies": {
"@angular/core": ">=12.0.0",
"rxjs": ">=6.0.0",
"zone.js": "0.11.4",
"@angular/platform-browser-dynamic": "12.2.5"
},
test-steup.ts
is the only place importing zone.js
and @angular/platform-browser-dynamic
.
Expected Behavior
Dependencies from test-related files shouldn’t be part of the peer dependencies. Also, is there a way to disable adding peer dependencies during build time?
Steps to Reproduce
You can see this behavior in Transloco repo, just run nx run transloco:build
and see the package.json
file in the dist folder.
Environment
Node : 12.20.0 OS : darwin x64 npm : 7.24.1
nx : 12.9.0 @nrwl/angular : 12.9.0 @nrwl/cli : 12.9.0 @nrwl/cypress : 12.9.0 @nrwl/devkit : 12.9.0 @nrwl/eslint-plugin-nx : 12.9.0 @nrwl/express : Not Found @nrwl/jest : 12.9.0 @nrwl/linter : 12.9.0 @nrwl/nest : Not Found @nrwl/next : Not Found @nrwl/node : Not Found @nrwl/nx-cloud : Not Found @nrwl/react : Not Found @nrwl/schematics : Not Found @nrwl/tao : 12.9.0 @nrwl/web : Not Found @nrwl/workspace : 12.9.0 @nrwl/storybook : 12.9.0 @nrwl/gatsby : Not Found typescript : 4.3.5
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:5 (2 by maintainers)
Would be nice if we could tell it to ignore dependencies found in test files, mock files, storybook files etc…
@leosvelperez seems kind of odd to me that the fix is to disable the feature and manually resolve the dependencies instead of fixing the bug in this feature 🤷