benyap / resolve-tspaths

Transform path mappings in your compiled Typescript code
https://www.npmjs.com/package/resolve-tspaths
MIT License
132 stars 12 forks source link

Dynamic imports with options/assertions are not being transformed #359

Open zaalbarxx opened 1 week ago

zaalbarxx commented 1 week ago

Considering this example

const test = {
    timezones: () => import('@/timezones.json', { assert: { type: 'json' } }).then((module) => module.default),
    test: () => import('../../timezones.json')
};

the timezones won't be properly resolved while test will. I guess it has something to do with some kind of regex performed ? Or does this lib use AST for finding imports ?

Cheers

benyap commented 1 week ago

Hi @zaalbarxx, this library uses regexes to find matches for replacement. See generateChanges.ts.

Unfortunately, this means the use case you provided isn't currently supported. I'm not sure if/when I will be able to add support for that use case. But if you want, you are welcome to open up a PR!