Closed gengns closed 1 year ago
I can't reproduce it. Have you tried restarting the server?
Yes, @yuanchuan. Maybe I'm missing some configuration. I have created a Minimal Reproducible Example.
npm
Linux
It works with components, onMount, etc.
https://github.com/gengns/sveltekit-autoimport_1.6.10_missing_modules
Hi @gengns,
You can ignore the error [vite-plugin-svelte] /src/App.svelte:29:4 'fly' is not defined
in the console. The fly
function is imported correctly on my machine. Double check it by adding console.log(fly)
you may see the console outputs that function. I'll look into further if that's not the case.
The '@vaadin/button': ['vaadin-button']
won't work because the package @vaadin/button
doesn't have any exported module named vaadin-button
. It does have a export named Button
in its source file node_modules/@vaadin/button/src/vaadin-button.js
but It's not written in Svelte
so you can't use it directly in a Svelte file.
@vaadin/button
defines a web component <vaadin-button>
, which cannot be recognized by the svelte compiler
Hello @yuanchuan,
I'm running the issue example independently of our machines on Code Sandbox: https://codesandbox.io/p/github/gengns/sveltekit-autoimport_1.6.10_missing_modules/
As you can see on the link above, if you click on the checkbox visible it doesn't do anything, however if you call fly
inside the <script>
tag first, for example, adding a console.log(fly)
, it works.
It works:
<script>
let visible = true
console.log(fly)
</script>
<label>
<input type="checkbox" bind:checked={visible}>
visible
</label>
{#if visible}
<p in:fly={{ y: 200 }} out:fly={{ y: 200 }}>
Fly in and out
</p>
{/if}
It doesn't:
<script>
let visible = true
</script>
<label>
<input type="checkbox" bind:checked={visible}>
visible
</label>
{#if visible}
<p in:fly={{ y: 200 }} out:fly={{ y: 200 }}>
Fly in and out
</p>
{/if}
I think sveltekit-autoimport is not checking outside the tag when using module. There are plenty of circumstances where you add code directly on the html
without using the <script>
tag.
Just released 1.7.0
, should fix the undefined fly
identifier.
Awesome, it works like a charm. Great job @yuanchuan, thank you so much!
I'm trying to use
sveltekit-autoimport
to auto importsvelte/transition
module. Probably this is not an issue and just my wrong use or a setting that I'm missing.Inside
vite.config.js
Everything is working fine, except:
'svelte/transition': ['fly']
I also tried using different combinations and mapping instead of module but couldn't make it work. The same happens with Vaadin web components.