Comments (6)
Awesome, it works like a charm. Great job @yuanchuan, thank you so much!
from sveltekit-autoimport.
I can't reproduce it. Have you tried restarting the server?
from sveltekit-autoimport.
Yes, @yuanchuan. Maybe I'm missing some configuration. I have created a Minimal Reproducible Example.
Quick checklist
- I am using the latest version of sveltekit-autoimport
What package manager are you using?
npm
What operating system are you using?
Linux
Steps to reproduce
- clone repo
- npm i && npm run dev
- [vite-plugin-svelte] /src/App.svelte:29:4 'fly' is not defined
It works with components, onMount, etc.
Link to minimal reproducible example
https://github.com/gengns/sveltekit-autoimport_1.6.10_missing_modules
from sveltekit-autoimport.
Hi @gengns,
fly
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.
vaadin-button
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
from sveltekit-autoimport.
Hello @yuanchuan,
fly
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 <script> tag when using module. There are plenty of circumstances where you add code directly on the html
without using the <script>
tag.
from sveltekit-autoimport.
Just released 1.7.0
, should fix the undefined fly
identifier.
from sveltekit-autoimport.
Related Issues (20)
- How to auto-import from component library in node_modules? HOT 10
- Should it better be called "sveltekit-autoimport"?
- Possible support for .js-files by wildcard? HOT 6
- Import Fails with SCSS nesting HOT 6
- TS let statement breaking import HOT 3
- Broken for sveltekit version >= 1.0.0-next.346
- Doesn't auto-import for svelte auto-subscriptions
- Doesn't auto-import for Object indented Components
- Support for auto-import inside <script context="module">
- Error: Failed to parse source for import analysis because the content contains invalid JS syntax. HOT 5
- Make it compatible with SK version >= 1.0.0-next.359 HOT 2
- Sveltekit: missing-declaration HOT 6
- VSCode support HOT 8
- Typescript Support
- Error with auto-import and mdsvex Layout component.
- How can I make this work with MDsveX? HOT 34
- Nested Components HOT 2
- Import Broken When lang="ts HOT 9
- Importing '$app/stores' : ['page'] brings about crbug HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sveltekit-autoimport.