aleclarson / vite-tsconfig-paths

Support for TypeScript's path mapping in Vite
MIT License
1.28k stars 44 forks source link

File paths correct for barrel file imports, but not changed for 'nested' path imports (after build) #154

Open Carnageous opened 3 weeks ago

Carnageous commented 3 weeks ago

Hey! We've been using this plugin happily for quite some time and never had any issues, so first of all thanks a lot!

Now, we are migrating away from using barrel files for imports, so converting things like import type { Foo } from "$types" to import type { Foo } from "$types/someStuff".

Now, in the IDE that works well and paths are resolved correctly, but after building in library mode and emitting .d.ts files with vite-plugin-dts, some paths are not resolved at all. As shown in this reproduction repo on stackblitz, importing from a barrel file (that just re-exports) works, but importing directly does not - the path alias is not changed.

So

import type { Foo } from "$types"
// becomes
import type { Foo } from "../types";

but

import type { Foo } from "$types"
// stays the same
import type { Foo } from '$types/someStuff';

The reproduction builds a react library in rollup lib mode, but it's the same for non-react apps, I tested.

Now, I am a bit unsure if this is an issue of this plugin, vite-plugin-dts or just my config, but after some research I think I'm at the right place here.

Please let me know if you need more details!

Carnageous commented 3 weeks ago

I don't think (hope) this is related to https://github.com/aleclarson/vite-tsconfig-paths/issues/101/, as there is no leading / in this case, it's just nested folders, and that is supposed to work, right?