fix: add .js extensions for NodeNext module resolution#614
fix: add .js extensions for NodeNext module resolution#614schickling wants to merge 2 commits intoanomalyco:mainfrom
Conversation
This fixes TypeScript module resolution for consumers using `moduleResolution: "NodeNext"`. Without explicit `.js` extensions, TypeScript cannot resolve re-exports like `export * from "./renderer"` in the generated declaration files. Changes: - Add `.js` extensions to all relative imports/exports in source files - Convert directory imports like `./lib` to `./lib/index.js` - Convert `from "."` imports to `from "./index.js"` Fixes anomalyco#504 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@opentui/core
@opentui/react
@opentui/solid
@opentui/core-darwin-arm64
@opentui/core-darwin-x64
@opentui/core-linux-arm64
@opentui/core-linux-x64
@opentui/core-win32-arm64
@opentui/core-win32-x64
commit: |
|
@schickling mind running a quick |
|
@msmps Thanks for the review! I've resolved the merge conflict and run Resolved:
Ready for another look! |
|
@msmps Is this generally a good approach - i don't write ts enough to know. I guess you could also rewrite the extensions during compile for the |
it's a good and uniform approach! i think we need to introduce a linter though like eslint, biome or oxlint to enforce the js extension going forward so this doesn't become a regression! i have a branch locally for that but would like your thoughts on this @simonklee @kommander |
|
oxlint (and oxfmt) seem to work well in the projects i've tried them in. |
Summary
This PR fixes TypeScript module resolution for consumers using
moduleResolution: "NodeNext"..jsextensions to all relative imports/exports in TypeScript source files./libto./lib/index.jsfrom "."imports tofrom "./index.js"Problem
When TypeScript processes the package with
moduleResolution: "NodeNext", it cannot resolve re-exports likeexport * from "./renderer"because NodeNext requires explicit file extensions. This causes TypeScript to report errors like:Solution
Add explicit
.jsextensions to all relative imports/exports. TypeScript understands that./renderer.jsrefers to./renderer.tsduring compilation, and the generated.d.tsfiles will have the correct extensions for NodeNext resolution.Test plan
Fixes #504
Generated with Claude Code