Hello, thanks for this library! Before knowing about it, I was giving up migrate my libs to ESM, mainly because of all import had to be upgraded. Now it's possible and doable, and I have successful examples.
However now I'm trying to migrate my app's codebase to ESM, and encountered a problem: import paths that start with aliases (both known to TS config and Node via module-alias package) are ignored on this line:
|
if (name.startsWith('node:') || !name.startsWith('/')) { |
|
// e.g. 'node:fs/promises' or 'fs/promises' |
|
return |
|
} |
I have 1k+ imports using path aliases like
import logger from 'common/logger'; // ../../common/logger.ts -> 'common/logger.js'
import * as utils from 'server/utils; // ./src/server/utils/index.ts -> 'server/utils/index.js'
and some of them are for /index.js files, some are just need to be updated with .js suffix – that's where this library shows its superpowers.
Not sure how it could be possible to let this library:
- to respect
tsconfig's aliases, or be configured somehow to recognize aliases;
- then resolve files correctly according to the alias value;
- do the rest of the magic.
So maybe someone has a workaround?
Hello, thanks for this library! Before knowing about it, I was giving up migrate my libs to ESM, mainly because of all import had to be upgraded. Now it's possible and doable, and I have successful examples.
However now I'm trying to migrate my app's codebase to ESM, and encountered a problem: import paths that start with aliases (both known to TS config and Node via
module-aliaspackage) are ignored on this line:fix-esm-import-path/fix-esm-import-path.js
Lines 85 to 88 in e39f102
I have 1k+ imports using path aliases like
and some of them are for
/index.jsfiles, some are just need to be updated with.jssuffix – that's where this library shows its superpowers.Not sure how it could be possible to let this library:
tsconfig's aliases, or be configured somehow to recognize aliases;So maybe someone has a workaround?