Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

JoshuaCWebDeveloper
Copy link
Contributor

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 #31295

Copy link

vercel bot commented Aug 12, 2025

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

Copy link
Contributor

nx-cloud bot commented Aug 12, 2025

🤖 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 3b64359

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

@JoshuaCWebDeveloper
Copy link
Contributor Author

JoshuaCWebDeveloper commented Aug 12, 2025

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

@Coly010
Copy link
Contributor

Coly010 commented Aug 18, 2025

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.

@JoshuaCWebDeveloper
Copy link
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Warning shown about cjs format when NodeNext module used
2 participants