Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@nx/js tsc compiler cannot add compiler external helper (tslib) when use pnpm workspace #17674

Closed
1 of 4 tasks
lucasvieirasilva opened this issue Jun 19, 2023 · 1 comment · Fixed by #17694
Closed
1 of 4 tasks

Comments

@lucasvieirasilva
Copy link
Contributor

Current Behavior

When the package manager pnpm is used to manage the workspace dependencies the buildable js libraries cannot add the tslib as a dependency.

This issue is not a blocker because Nx continues and builds the library, however, the generated package.json doesn't have the tslib as a dependency.

Expected Behavior

Should not present the warning message and add the tslib as a dependency when the workspace uses pnpm to manage the dependencies and the js libraries are built.

GitHub Repo

No response

Steps to Reproduce

  1. Create empty nx workspace (npx create-nx-workspace@latest pnpm-issue --packageManager pnpm
  2. nx generate @nx/js:library lib1
  3. nx run lib1:build

Nx Report

>  NX   Report complete - copy this into the issue template

   Node   : 16.20.0
   OS     : darwin x64
   pnpm   : 8.6.1
   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/devkit         : 16.3.2
   @nx/eslint-plugin  : 16.3.2
   @nx/nest           : 16.3.2
   @nx/node           : 16.3.2
   @nrwl/tao          : 16.3.2
   @nx/webpack        : 16.3.2
   typescript         : 5.0.2
   ---------------------------------------
   Local workspace plugins:
         @nx16-pnpm-issue/lib1

Failure Logs

Your library compilation option specifies that the compiler external helper (tslib) is needed but it is not installed.

Operating System

  • macOS
  • Linux
  • Windows
  • Other (Please specify)

Additional Information

After some investigation, the @nx/js package at https://github.com/nrwl/nx/blob/master/packages/js/src/utils/compiler-helper-dependency.ts#L74,

const libNode = projectGraph.externalNodes[helperDependency];

The helperDependency contains the value tslib, however, the way the external nodes are generated when nx resolves the dependencies from pnpm lock file makes the object have the version in the keys, like this:

[ 'npm:[email protected].', 'npm:[email protected].', 'npm:[email protected].' ]

so, the tslib is installed in the workspace, but in multiple versions, even in the most basic workspace, because there are some base packages that use tslib as a dependency, like @typescript-eslint/parser.

Which results in multiple versions of the tslib.

I guess the better approach is to try to resolve the tslib version from the project's package.json or the root package.json.

@jaysoo jaysoo self-assigned this Jun 20, 2023
jaysoo added a commit to jaysoo/nx that referenced this issue Jun 20, 2023
…ed with version

When using pnpm, the version might be added to avoid ambiguity, but it causes the wrong warning when detecting missing helper packages.

Closes nrwl#17674
jaysoo added a commit to jaysoo/nx that referenced this issue Jun 20, 2023
…ed with version

When using pnpm, the version might be added to avoid ambiguity, but it causes the wrong warning when detecting missing helper packages.

Closes nrwl#17674
jaysoo added a commit to jaysoo/nx that referenced this issue Jun 21, 2023
…ed with version

When using pnpm, the version might be added to avoid ambiguity, but it causes the wrong warning when detecting missing helper packages.

Closes nrwl#17674
jaysoo added a commit to jaysoo/nx that referenced this issue Jun 21, 2023
…ed with version

When using pnpm, the version might be added to avoid ambiguity, but it causes the wrong warning when detecting missing helper packages.

Closes nrwl#17674
jaysoo added a commit to jaysoo/nx that referenced this issue Jun 21, 2023
…ed with version

When using pnpm, the version might be added to avoid ambiguity, but it causes the wrong warning when detecting missing helper packages.

Closes nrwl#17674
jaysoo added a commit to jaysoo/nx that referenced this issue Jun 21, 2023
…ed with version

When using pnpm, the version might be added to avoid ambiguity, but it causes the wrong warning when detecting missing helper packages.

Closes nrwl#17674
@github-actions
Copy link

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 github-actions bot locked as resolved and limited conversation to collaborators Jul 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants