question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Bug: Build adds peerDependecies from test files to package output.

See original GitHub issue

Current 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:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
wallace41290commented, Jul 26, 2022

Would be nice if we could tell it to ignore dependencies found in test files, mock files, storybook files etc…

1reaction
shaharkazazcommented, Jan 15, 2022

@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 🤷

Read more comments on GitHub >

github_iconTop Results From Across the Web

Peer dependencies still showing as "unused" after being ...
Ran yarn depcheck --ignore-bin-package=true and got this output: Unused dependencies * @octokit/core error Command failed with exit code 255.
Read more >
How to test an npm module with peerDependencies?
For example, I have a package that has a peer dependency, a custom logger, and this logger needs to be configured by its...
Read more >
Common npm mistakes - Medium
Sometimes peer dependencies are used as a workaround due to missing peer dependencies only raising warnings, but that is semantically incorrect ...
Read more >
package.json - npm Docs
This document is all you need to know about what's required in your package.json file. It must be actual JSON, not just a...
Read more >
Error Codes | Yarn - Package Manager
The author of packageA can fix this problem by adding a peer dependency on packagePeer . If relevant, they can use optional peer...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found