refactor(esm): migrate package to ES modules - #3
Open
NedcloarBR wants to merge 1 commit into
Open
NedcloarBR wants to merge 1 commit into
NedcloarBR wants to merge 1 commit into
Conversation
The package.json already declared "type": "module" while tsconfig emitted
CommonJS, so the published .d.ts re-exported paths without extensions
("./entities") that nodenext consumers could not resolve — every named
export silently disappeared.
- tsconfig: module/moduleResolution CommonJS -> nodenext
- add explicit .js and /index.js extensions to relative imports
- datasource: __dirname -> import.meta.dirname for migration/seed globs
- scripts/help.js: require -> import with { type: "json" }
- replace ts-node with tsx: the TypeORM cli-ts-node-esm.js wrapper relies on
--loader ts-node/esm, deprecated on Node 22
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The package already declared
"type": "module"while tsconfig emitted CommonJS. The resulting.d.tsre-exported paths without extensions:nodenextconsumers cannot resolve that, so every named export silently disappeared — the N-D-B project failed with 36TS2305: Module "@ndb/database" has no exported membererrors.Changes
tsconfig:module/moduleResolutionfromCommonJStonodenext.js//index.jsextensions on relative imports (68 across 21 files)datasource.ts:__dirname→import.meta.dirnamefor the migration and seed globsscripts/help.js:require→import ... with { type: "json" }ts-node→tsx: the TypeORMcli-ts-node-esm.jswrapper relies on--loader ts-node/esm, deprecated on Node 22. Scripts now use--import tsxagainsttypeorm/cli.jsdirectly, dropping the wrapper subprocess.Validation
yarn buildclean; emitted.d.tsnow carries extensionsmigration:showreaches the database (fails only on connection refused, no local Postgres)Migrations were not exercised against a live database — no Docker available in this environment.
Paired with the ESM migration in the N-D-B repository.