@nx/js
doesn't work properly on TS configs that extend ESM-based configs
#28492
Labels
@nx/js
doesn't work properly on TS configs that extend ESM-based configs
#28492
Current Behavior
We're using Nx release management over a TS project, which requires
@nx/js
. Our TS config files are based off various presets, either well-known community resources like@tsconfig/recommended
or our own in-house presets. The latter are ESM packages that useexports
fields in theirpackage.json
to expose/tsconfig.json
over a file not located at package root.Unfortunately,
@nx/js
relies onts-node
for parsing TS configs, with a fixed version of 10.9.1, when 10.9.2 was published over 10 months ago, allowing for proper import conditions handling, which fixes this issue.So attempting to run
nx release
on such a project right now yields very confusing errors, as this happens deeply nested in your code when trying to set up the changelog generator, and any error in that scope is surfaced as "couldn't resolve the generator," when the file is actually right there.(Generally, ts-node is basically abandonware at this point and it would be advisable for Nx JS-related projects to switch to other options for handling TS code, even more so for handling JS code.)
Expected Behavior
Generally, Nx should be able to process any TS Config that
tsc
itself can process, and should be able to work over any ESM module that uses conditional exports / imports.In this particular case, it shouldn't fail to resolve the changelog generator just because the scope's TS config extends from a file that is exposed through a module's ESM
exports
field.This can easily be achieve by bumping your
ts-node
dependency within thepackages/js/package.json
file to10.9.2
. I'm going to send a PR that does just that.Note to readers: in the meantime, you can get this on your existing codebase by adding an npm override to your root
package.json
:GitHub Repo
https://github.com/tdd/nx-js-issue-demo
Steps to Reproduce
git clone https://github.com/tdd/nx-js-issue-demo.git cd nx-js-issue-demo npm install npx nx release --first-release --dry-run
Nx Report
NX Report complete - copy this into the issue template
Node : 20.11.1
OS : darwin-arm64
Native Target : aarch64-macos
npm : 10.2.4
nx : 20.0.0
@nx/js : 20.0.0
@nx/workspace : 20.0.0
@nx/devkit : 20.0.0
typescript : 5.6.3
Failure Logs
Convert compiler options from json failed, File '@nx-demo/tsconfig/exported-config.json' not found.
NX There was an error when resolving the configured changelog renderer at path: node_modules/nx/release/changelog-renderer
The relevant config is defined here: nx.json, lines 5-10
NX Cannot read properties of undefined (reading 'map')
Pass --verbose to see the stacktrace.
NOTE: The "dryRun" flag means no changes were made.
Package Manager Version
No response
Operating System
Additional Information
No response
The text was updated successfully, but these errors were encountered: