Skip to content
Advertisement

Import alias svelte component in typescript svelte

I want to import a svelte component in a typescript svelte component, it works for typescript file and other type of files, but in this case of svelte component, it resulted in a path error, here’s my code :

JavaScript

It only works if i use ../../components/LoadingIcon.svelte instead of src/components/LoadingIcon.svelte

Here’s the error: Uncaught (in promise) TypeError: Failed to resolve module specifier "src/forms/groups/GroupFilterForm.svelte". Relative references must start with either "/", "./", or "../".

error

Here’s my tsconfig.json:

JavaScript

and here’s my rollup.config.js:

JavaScript

Anyone knows how to fix this issue? thank you for your help

Advertisement

Answer

You are using baseUrl, which means some kind of path aliasing is introduced in the code. @rollup/plugin-typescript does not resolve these, so you need an extra step afterwards. You can use @rollup/plugin-alias for that.

Updated rollup.config.js:

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement