nrwl / nx

Smart Monorepos · Fast CI
https://nx.dev
MIT License
23.61k stars 2.36k forks source link

updateBuildableProjectDepsInPackageJson alternative missing #19897

Open sonikasharma1403 opened 1 year ago

sonikasharma1403 commented 1 year ago

Current Behavior

As far as I understand, updateBuildableProjectDepsInPackageJson option modified the distribution's package.json. I tried the @nx/dependency-checks but it is not modifying my package.json post build instead it modifies the package.json which was specified.

I am looking for a way to restore the previous behavior.

Also, what if I am not using a third-party module? but still want to add it as my library's dependency.. can we do that with Nx 17 (used to work with NX 16)

Expected Behavior

Should work as with Nx 16

GitHub Repo

No response

Steps to Reproduce

  1. Generate a library using NX 16.. and set updateBuildableProjectDepsInPackageJson as true..
    1. do not specify a third module being used e.g @something/a
    2. specify a third party module NOT being used e.g @something/b

build the project and notice the package.json. notice that the package.json has both @something/a and @something/b.

Repeat the same with NX 17..

Nx Report

Node   : 18.16.0
   OS     : darwin-x64
   yarn   : 1.22.10

   nx                 : 17.1.0-beta.0
   @nx/js             : 17.1.0-beta.0
   @nx/jest           : 17.1.0-beta.0
   @nx/linter         : 17.1.0-beta.0
   @nx/eslint         : 17.1.0-beta.0
   @nx/workspace      : 17.1.0-beta.0
   @nx/angular        : 17.1.0-beta.0
   @nx/cypress        : 17.1.0-beta.0
   @nx/devkit         : 17.1.0-beta.0
   @nx/eslint-plugin  : 17.1.0-beta.0
   @nx/plugin         : 17.1.0-beta.0
   @nx/storybook      : 17.1.0-beta.0
   @nrwl/tao          : 17.1.0-beta.0
   @nx/web            : 17.1.0-beta.0
   @nx/webpack        : 17.1.0-beta.0
   typescript         : 5.1.6
   ---------------------------------------
   Community plugins:
   @ngrx/store         : 16.3.0
   @storybook/angular  : 7.5.1
   @torque/clr-angular : 5.0.0-trq.105
   ng-mocks            : 14.11.0
   nx-stylelint        : 15.0.0

Failure Logs

No response

Package Manager Version

No response

Operating System

Additional Information

No response

sonikasharma1403 commented 1 year ago

@AgentEnder , @jaysoo, @Coly010

origranot commented 1 year ago

Following.

sonikasharma1403 commented 1 year ago

@AgentEnder - any update or workaround for this?

Tom910 commented 11 months ago

The same issue. My project uses a lot updateBuildableProjectDepsInPackageJson and interesting to find how we can upgrade the project on NX 17 without removing updateBuildableProjectDepsInPackageJson

sonikasharma1403 commented 11 months ago

I did it via nx-dependency-checks https://nx.dev/nx-api/eslint-plugin/documents/dependency-checks. had to turn off a couple of functionality to get the same output as before.. Also, instead of modifying the distribution's package.json, it modifies the root one.

ianldgs commented 11 months ago

We were already considering to declare all of our dependencies manually, because updateBuildableProjectDepsInPackageJson would sometimes get it kinda wrong. E.g. some devDependency imported in storybook file ended up in the dist package.json. So the dependency-checks eslint rule was very welcome.

However, for internal dependencies, it sets the version to *, which ends up in the final package.json. That is not ideal, as we loose the ability to tell which versions of our packages work together.

If you have many unrelated packages (differently from the nrwl/nx repo), it doesn't make sense to release all packages on every release, so using semver's independent mode.

Edit: related to https://github.com/nrwl/nx/issues/20121

PowerSupply commented 1 week ago

This seems to be fixed? Using --fix now seems to insert an exact dependency version for internal dependencies for me at least.

Close?