Skip to content

Starting 22.2.4 external modules are not excluded from @nx/esbuild bundle #33990

@ayashkov

Description

@ayashkov

Current Behavior

After migrating from 22.2.3 to 22.2.4, the bundle produced by @nx/esbuild plugin now includes 3rd party libraries into the bundle, in my case rxjs. This behavior can be mitigated by explicitly setting targets.build.options.external to ["rxjs"].

Expected Behavior

By default, I expect the bundle not to include 3rd party libraries without the need to list them explicitly in the plugin's options.

GitHub Repo

https://github.com/granito-source/vitest-marbles/tree/v1.0.2

Steps to Reproduce

  1. Execute nx migrate 22.2.4 in the repo.
  2. Run nx run-many -t build.
  3. Inspect the produced dist/vitest-marbles/index.js to see that it inlines rxjs library.
  4. Set nx.targets.build.options.external to ["rxjs"] in package.json.
  5. Run nx run-many -t build --skip-nx-cache.
  6. Inspect the produced dist/vitest-marbles/index.js to see that it no longer inlines the library.

Nx Report

Node           : 24.12.0
OS             : darwin-arm64
Native Target  : aarch64-macos
npm            : 11.6.2

nx (global)    : 22.3.3
nx             : 22.2.4
@nx/js         : 22.2.4
@nx/workspace  : 22.2.4
@nx/devkit     : 22.2.4
@nx/esbuild    : 22.2.4
@nx/vitest     : 22.2.4
typescript     : 5.9.3
---------------------------------------
Registered Plugins:
@nx/vitest
---------------------------------------
Cache Usage: 0.00 B / 92.64 GB

Failure Logs

Package Manager Version

No response

Operating System

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

Additional Information

The same issue exists in 22.2.7 and in 22.3.3.

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