You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A dynamically imported component, with a variable in the path, breaks if using the $lib alias. Example below:
<scriptlang='ts'>import{ onMount }from"svelte";letTestComponent: any;constcomponentName='TestComponent.svelte';onMount(async()=>{TestComponent=(awaitimport(`../lib/${componentName}`)).default;// THIS WORKS// TestComponent = (await import(`$lib/${componentName}`)).default; // THIS DOES NOT WORK});</script><svelte:componentthis={TestComponent}/>
Reproduction
Create a new SvelteKit app. Create a TestComponent.svelte file with something in it. Try to dynamically import the component using string interpolation in the path.
Logs
importTest.svelte? [sm]:8 Uncaught (in promise) TypeError: Failed to resolve module specifier '$lib/TestComponent.svelte'
at importTest.svelte? [sm]:8:47
at run (index.mjs:18:12)
at Array.map (<anonymous>)
at index.mjs:1816:45
at flush (index.mjs:1075:17)
at init (index.mjs:1908:9)
at new Root (root.svelte? [sm]:16:25)
at createProxiedComponent (svelte-hooks.js:341:9)
at new ProxyComponent (proxy.js:242:7)
at new Proxy<Root> (proxy.js:349:11)
The text was updated successfully, but these errors were encountered:
jhubbardsf
changed the title
$lib alias does not work while dynamically importing a component when there is a variable used in the name
$lib alias does not work while dynamically importing a component when using string interpolation
May 18, 2022
Describe the bug
A dynamically imported component, with a variable in the path, breaks if using the $lib alias. Example below:
Reproduction
Create a new SvelteKit app. Create a TestComponent.svelte file with something in it. Try to dynamically import the component using string interpolation in the path.
Logs
System Info
Severity
serious, but I can work around it
Additional Information
No response
The text was updated successfully, but these errors were encountered: