-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Description
Current Behavior
When building with @nx/js:tsc
I get the following warning:
Package type is set to "module" but "cjs" format is included. Going to use "esm" format instead. You can change the package type to "commonjs" or remove type in the package.json file.
Despite me not setting format: "cjs"
anywhere.
My module format is set to NodeNext
in my tsconfig.json
Expected Behavior
When building an ESM package with module set to NodeNext
this warning should not be shown
GitHub Repo
https://github.com/morganstanley/fdc3-web
Steps to Reproduce
Clone above repo
nx build fdc3-web
Nx Report
Node : 22.13.1
OS : win32-x64
Native Target : x86_64-windows
npm : 10.9.2
nx (global) : 21.0.3
nx : 21.0.3
@nx/js : 21.0.3
@nx/jest : 21.0.3
@nx/eslint : 21.0.3
@nx/workspace : 21.0.3
@nx/devkit : 21.0.3
@nx/esbuild : 21.0.3
@nx/node : 21.0.3
@nx/vite : 21.0.3
@nx/web : 21.0.3
typescript : 5.8.3
---------------------------------------
Registered Plugins:
@nx/eslint/plugin
@nx/vite/plugin
@nx/vite/plugin
---------------------------------------
Cache Usage: 726.05 KB / 47.69 GB
Failure Logs
Package Manager Version
No response
Operating System
- macOS
- Linux
- Windows
- Other (Please specify)
Additional Information
the format that is used is not set in the options of the @nx/js:tsc
executor (this caused quite a bit of confusion as when I tried to set it it had no effect). It is instead generated from the tsconfig file that is used. The format comes from the function determineModuleFormatFromTsConfig
which only considers:
ts.ModuleKind.ES2015
ts.ModuleKind.ES2020
ts.ModuleKind.ES2022
ts.ModuleKind.ESNext
to be esm. NodeNext
should be added
export function determineModuleFormatFromTsConfig( |