Skip to content

Wrong dependencies calculation during builds #10227

Closed
@gperdomor

Description

@gperdomor

I have a project with many lib packages, I'm using the updateBuildableProjectDepsInPackageJson(which is enabled by default) to generate the package json of my libs but I notice some weird behavior

Current Behavior

Lib core imports some package, let's say @actions/exec, I build this library and the package.json inside dist/core directory is something like this:

{
  "name": "@sample/core",
  "version": "0.0.1",
  "type": "commonjs",
  "main": "./src/index.js",
  "typings": "./src/index.d.ts",
  "dependencies": {
    "@actions/exec": "1.1.1"
  },
  "peerDependencies": {}
}

which is fine...

Also, I have a second libe, let's say lib1 which depends on core and do something... I build this library and the package.json inside dist/core directory is something like this:

{
  "name": "@sample/lib1",
  "version": "0.0.1",
  "type": "commonjs",
  "main": "./src/index.js",
  "typings": "./src/index.d.ts",
  "dependencies": {
    "@sample/core": "0.0.1",
    "@actions/exec": "1.1.1"
  },
  "peerDependencies": {}
}

but @actions/exec is not imported in lib1 and is a dependency of core

If I have a third lib which import core and lib1, this lib will have all deps from core and lib1 in their package.json after I build it

Expected Behavior

Only @sample/coremust be present in the package.json of lib1

Steps to Reproduce

Use this repo https://github.com/gperdomor/nx-sample-buildable-bug

Failure Logs

N/A

Environment

NX Report complete - copy this into the issue template

Node : 16.15.0
OS : darwin x64
npm : 8.9.0

nx : 14.1.4
@nrwl/angular : Not Found
@nrwl/cypress : Not Found
@nrwl/detox : Not Found
@nrwl/devkit : 14.1.4
@nrwl/eslint-plugin-nx : 14.1.4
@nrwl/express : Not Found
@nrwl/jest : 14.1.4
@nrwl/js : 14.1.4
@nrwl/linter : 14.1.4
@nrwl/nest : Not Found
@nrwl/next : Not Found
@nrwl/node : Not Found
@nrwl/nx-cloud : Not Found
@nrwl/nx-plugin : Not Found
@nrwl/react : Not Found
@nrwl/react-native : Not Found
@nrwl/schematics : Not Found
@nrwl/storybook : Not Found
@nrwl/web : Not Found
@nrwl/workspace : 14.1.4
typescript : 4.6.4
rxjs : 6.6.7

Community plugins:

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions