nx icon indicating copy to clipboard operation
nx copied to clipboard

@nx/rollup does not pick up exact version of root package.json dependencies

Open davidren-apt opened this issue 2 years ago • 3 comments

Current Behavior

If I have a library dependency - a@^1.0.0 in root package.json, after build using @nx/rollup bundler, the version is picked up partially with 1.0.0 instead of ^1.0.0 which would cause some potential upgrade issue when I try to consume this component in other applications.

{
  //...
  "dependencies": {
    "a": "1.0.0",
  },
}

Just to compare, for another component I wrote, executor @nx/js:tsc is used as it is pure typescript library, the version is picked up correctly with ^1.0.0.

Expected Behavior

The dependency version in my publishable component bundle should be:

{
  //...
  "dependencies": {
    "a": "^1.0.0",
  },
}

GitHub Repo

No response

Steps to Reproduce

  1. Generate a component using: npx nx g @nx/react:library ${COMPONENT_NAME} --bundler=rollup --style="styled-components" --publishable --importPath="@myOrg/${COMPONENT_NAME}"

  2. Define build executor for this library using:

"executor": "@nx/rollup:rollup",
"options": {
  // ...
  "external": "all",
  "buildableProjectDepsInPackageJsonType": "dependencies",
  "updateBuildableProjectDepsInPackageJson": true,
  // ...
}
  1. Write code with global dependency defined in root package.json.

  2. Run npx nx run component:build.

  3. Check the package.json file in dist folder bundle resources.

Nx Report

Node   : 16.19.0
   OS     : darwin arm64
   npm    : 8.19.3
   Hasher : Native

   nx                 : 16.3.2
   @nx/js             : 16.3.2
   @nx/jest           : 16.3.2
   @nx/linter         : 16.3.2
   @nx/workspace      : 16.3.2
   @nx/cypress        : 16.3.2
   @nx/devkit         : 16.3.2
   @nx/eslint-plugin  : 16.3.2
   @nx/express        : 16.3.2
   @nx/next           : 16.3.2
   @nx/node           : 16.3.2
   @nx/react          : 16.3.2
   @nx/rollup         : 16.3.2
   @nx/storybook      : 16.3.2
   @nrwl/tao          : 16.3.2
   @nx/web            : 16.3.2
   @nx/webpack        : 16.3.2
   nx-cloud           : 16.0.5
   typescript         : 5.0.4
   ---------------------------------------
   Community plugins:
   @jscutlery/semver : 3.0.0
   ---------------------------------------

Failure Logs

No response

Operating System

  • [X] macOS
  • [ ] Linux
  • [ ] Windows
  • [ ] Other (Please specify)

Additional Information

No response

davidren-apt avatar Jun 14 '23 09:06 davidren-apt

@mandarini any update on this? Thanks!

davidren-apt avatar Aug 03 '23 06:08 davidren-apt

@davidren-apt no sorry, no updates yet :( I will try to see if anyone has time to look at it this week, or else I can take a look next week maybe! Have you managed to find any workarounds, maybe?

mandarini avatar Aug 03 '23 08:08 mandarini

This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs. If we missed this issue please reply to keep it active. Thanks for being a part of the Nx community! 🙏

github-actions[bot] avatar Jan 31 '24 00:01 github-actions[bot]

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.

github-actions[bot] avatar Mar 17 '24 00:03 github-actions[bot]