Skip to content

NxAppWebpackPlugin doesn't bundle transitive dependencies of nonBuildableLibraries #32575

@andycmaj

Description

@andycmaj

Current Behavior

Looking at 7c13ed3#diff-4bf0a91a9f97bd852e8e0b9261af2a26bcdef16778610f8feb5f07b02a14c6e5 and associated bugs, it looks like the fix only checks direct deps of the current entrypoint project being bundled by webpack.

But what if those deps also depend on internal non-buildable libraries? I'm not seeing those transitive deps being added to the bundle.

Is this expected?

Expected Behavior

Expect all degrees of transitive dependency to be bundled into webpack output.
Only seeing the direct deps bundled, while THEIR deps remain external

GitHub Repo

No response

Steps to Reproduce

  1. create a new non-buildable TS package A
  2. create package B
  3. package A imports from package B
  4. APP imports from package A
  5. run a webpack bundle on A

Nx Report

NX   Report complete - copy this into the issue template

Node           : 22.14.0
OS             : darwin-arm64
Native Target  : aarch64-macos
pnpm           : 10.11.0

nx                     : 21.1.2
@nx/js                 : 21.1.2
@nx/jest               : 21.1.2
@nx/eslint             : 21.1.2
@nx/workspace          : 21.1.2
@nx/cypress            : 21.1.2
@nx/devkit             : 21.1.2
@nx/esbuild            : 21.1.2
@nx/eslint-plugin      : 21.1.2
@nx/express            : 21.1.2
@nx/module-federation  : 21.1.2
@nx/nest               : 21.1.2
@nx/node               : 21.1.2
@nx/plugin             : 21.1.2
@nx/react              : 21.1.2
@nx/rollup             : 21.1.2
@nx/storybook          : 21.1.2
@nx/vite               : 21.2.2
@nx/web                : 21.1.2
@nx/webpack            : 21.1.2
typescript             : 5.9.2

---------------------------------------
Nx key licensed packages
Licensed to REDACTED.

@nx/s3-cache  : 3.0.0

---------------------------------------
Registered Plugins:
@nx/js/typescript
@nxrocks/nx-quarkus
...REDACTED
---------------------------------------
Community plugins:
@nx-tools/nx-container            : 4.0.4
@nx/s3-cache                      : 3.0.0
@nxrocks/nx-quarkus               : 9.0.1
...REDACTED
---------------------------------------
Local workspace plugins:
         ...REDACTED
---------------------------------------
Cache Usage: 391.84 KB / 92.64 GB
---------------------------------------
The following packages should match the installed version of nx
  - @nx/vite@21.2.2

To fix this, run `nx migrate nx@21.2.2`

Failure Logs

❯ pnpm node apps/stitcher/dist/main.js
Debugger attached.
Debugger attached.
Waiting for the debugger to disconnect...
node:internal/modules/esm/resolve:1000
    throw error;
    ^

<===== THIS IS THE PROJECT THAT IS A TRANSITIVE DEP
Error [ERR_UNSUPPORTED_DIR_IMPORT]: Directory import '/Users/ac/workspace/.../.../monorepo-tooling/libs/shared/util-types/src/lib' is not supported resolving ES modules imported from /Users/ac/workspace/.../.../monorepo-tooling/libs/shared/util-types/src/index.ts
    at finalizeResolution (node:internal/modules/esm/resolve:263:11)
    at moduleResolve (node:internal/modules/esm/resolve:860:10)
    at defaultResolve (node:internal/modules/esm/resolve:984:11)
    at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:685:12)
    at #cachedDefaultResolve (node:internal/modules/esm/loader:634:25)
    at ModuleLoader.getModuleJobForRequire (node:internal/modules/esm/loader:384:53)
    at new ModuleJobSync (node:internal/modules/esm/module_job:341:34)
    at ModuleLoader.importSyncForRequire (node:internal/modules/esm/loader:357:11)
    at loadESMFromCJS (node:internal/modules/cjs/loader:1385:24)
    at Module._compile (node:internal/modules/cjs/loader:1536:5) {
  code: 'ERR_UNSUPPORTED_DIR_IMPORT',
  url: 'file:///Users/ac/workspace/.../...-worktrees/monorepo-tooling/libs/shared/util-types/src/lib'
}

Node.js v22.14.0
Waiting for the debugger to disconnect...

Package Manager Version

No response

Operating System

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

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions