-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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 produces CommonJS instead of ESM for module: Node16 #18801
Comments
From my understanding, the See the relevant explanation here For that reason I don't think it's possible to determine the "correct" type of module to output based solely on that tsconfig setting. It would actually need to look at whether your source package.json "type" is already set to "module" Because of this I don't really think determining the type of module from the "module" tsconfig setting actually makes sense in general, it should probably be forced to be specified in the package.json file of the source.. |
This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs. |
Not stale. |
Also mentioning this related issue since I think basically Nx's whole handling of the |
This issue has been automatically marked as stale because it hasn't had any activity for 6 months. |
Not stale. |
Current Behavior
Introduced in NX 16.7.0, the function
determineModuleFormatFromTsConfig
looks attsconfig.json
to determine whether@nx/js:tsc
should produce a CommonJS or an ESM module:However, the function doesn't consider
"module": "Node16"
, so if a TypeScript module happens to use it,@nx/js:tsc
produces apackage.json
with all the export fields indicating anesm
module, but with"type": "commonjs"
.Expected Behavior
"module": "Node16"
setting should result in@ns/js:tsc
producing anesm
module.GitHub Repo
No response
Steps to Reproduce
Create a TypeScript library module and configure its
tsconfig.json
as follows:Run
build
and notice resultingpackage.json
similar to the below:Since the module is incorrectly marked as
commonjs
, consumers can't import its exports.Nx Report
Failure Logs
No response
Operating System
Additional Information
No response
The text was updated successfully, but these errors were encountered: