nrwl / nx

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

tsc "external" does not respect "external" setting of an "external" dependency #20015

Open ajwootto opened 11 months ago

ajwootto commented 11 months ago

Current Behavior

Given the following scenario: Package A depends on Package B which depends on Package C and D (all are Nx libs in a workspace)

Package B uses tsc to build, and defines a list of external packages which includes package C. This causes package B to be built without bundling package C inside it, but it will bundle package D inside.

Package A uses tsc to build, and defines a list of external packages which includes package B. It does not directly depend on package 'C' or 'D'.

When building package A, it will not bundle in package B (as specified by external setting) but it will bundle in package C and D despite not having a direct dependency on either of those.

The package.json output of package A also seems to include all the dependencies of package B, even though it has no direct dependency on any of them. This is likely the underlying reason for the above behaviour.

Expected Behavior

Package A should build without bundling package B, C or D in it.

GitHub Repo

https://github.com/DevCycleHQ/js-sdks/commit/e7b163e2a2f939e119cfd19d0582c7415ebb3cea

Steps to Reproduce

  1. Check out repo at that commit
  2. yarn
  3. yarn build openfeature-nodejs-provider
  4. check dist/ output

the build output for openfeature-nodejs-provider contains things like js-cloud-server-sdk which is an external dependency of nodejs, which is a dependency of this package. It should not include that dependency in the bundle.

Nx Report

>  NX  Falling back to ts-node for local typescript execution. This may be a little slower.
  - To fix this, ensure @swc-node/register and @swc/core have been installed

 >  NX   Report complete - copy this into the issue template

   Node   : 18.16.0
   OS     : darwin-arm64
   yarn   : 3.6.0

   nx                 : 16.7.4
   lerna              : 5.6.2
   @nx/js             : 16.7.4
   @nx/jest           : 16.7.4
   @nx/linter         : 16.7.4
   @nx/workspace      : 16.7.4
   @nx/cypress        : 16.7.4
   @nx/detox          : 16.7.4
   @nx/devkit         : 16.7.4
   @nx/esbuild        : 16.7.4
   @nx/eslint-plugin  : 16.7.4
   @nx/next           : 16.7.4
   @nx/node           : 16.7.4
   @nx/react          : 16.7.4
   @nx/react-native   : 16.7.4
   @nrwl/rollup       : 16.7.4
   @nx/web            : 16.7.4
   @nx/webpack        : 16.7.4
   typescript         : 5.1.6
   ---------------------------------------
   Community plugins:
   @altack/nx-bundlefy : 0.16.0

Failure Logs

No response

Package Manager Version

No response

Operating System

Additional Information

No response

github-actions[bot] commented 4 months ago

This issue has been automatically marked as stale because it hasn't had any activity for 6 months. Many things may have changed within this time. The issue may have already been fixed or it may not be relevant anymore. If at this point, this is still an issue, please respond with updated information. It will be closed in 21 days if no further activity occurs. Thanks for being a part of the Nx community! 🙏

ajwootto commented 4 months ago

not stale