nx icon indicating copy to clipboard operation
nx copied to clipboard

fix(js): recognize tsconfig module `nodenext` as ESM

Open JoshuaCWebDeveloper opened this issue 8 months ago โ€ข 5 comments

Current Behavior

A tsconfig module value of nodenext is treated as a CJS format, which produces a warning when built due to it being used in ESM projects.

Expected Behavior

A tsconfig module value of nodenext is now teated as an ESM format, producing no warning when built.

Related Issue(s)

Fixes https://github.com/nrwl/nx/issues/31295

JoshuaCWebDeveloper avatar Aug 12 '25 18:08 JoshuaCWebDeveloper

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Updated (UTC)
nx-dev Ready Ready Preview Aug 29, 2025 3:44am

vercel[bot] avatar Aug 12 '25 18:08 vercel[bot]

๐Ÿค– Nx Cloud AI has analyzed the error but could not create a fix

No fix generated, but analysis is available โ€ข View Fix โ†—


View your CI Pipeline Execution โ†— for commit 3b643599bbed132d0ae14daef81bc516d85d79a6

Command Status Duration Result
nx affected --targets=lint,test,build,e2e,e2e-c... โŒ Failed 40m 18s View โ†—
nx run-many -t check-imports check-commit check... โœ… Succeeded 1m 56s View โ†—
nx-cloud record -- nx-cloud conformance:check โœ… Succeeded 2s View โ†—
nx-cloud record -- nx format:check โœ… Succeeded 6s View โ†—
nx-cloud record -- nx sync:check โœ… Succeeded 5s View โ†—
nx documentation โœ… Succeeded 3m View โ†—

โ˜๏ธ Nx Cloud last updated this comment at 2025-08-14 03:07:42 UTC

nx-cloud[bot] avatar Aug 12 '25 18:08 nx-cloud[bot]

Failed check is due to failing test in angular:test on master, unclear whether or not the fix is to just update the snapshot.

JoshuaCWebDeveloper avatar Aug 12 '25 19:08 JoshuaCWebDeveloper

Hey @JoshuaCWebDeveloper I'm not sure if this is 100% correct.

NodeNext will be ESM if the nearest package.json type is module, and/or depending on the file extension of files.

Coly010 avatar Aug 18 '25 11:08 Coly010

Hey @JoshuaCWebDeveloper I'm not sure if this is 100% correct.

NodeNext will be ESM if the nearest package.json type is module, and/or depending on the file extension of files.

@Coly010 Good point. Looked at this a bit closer, format is an optional option to updatePackageJson() because it is already checking the package.json type. getUpdatedPackageJsonContent() also has logic for handling no given format.

My new solution passes a format of undefined to updatePackageJson() for the node* module types. This allows updatePackageJson() to determine the correct format (currently checks package.json, and can check file extensions in the future if it needs to). I also check every single tsconfig module option for completeness and to make it super clear what the method returns now that I'm introducing a third return type.

JoshuaCWebDeveloper avatar Aug 29 '25 03:08 JoshuaCWebDeveloper

Should be handled now by: https://github.com/nrwl/nx/pull/31508

Coly010 avatar Dec 11 '25 16:12 Coly010

This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request.

github-actions[bot] avatar Dec 17 '25 00:12 github-actions[bot]