Git Product home page Git Product logo

Comments (6)

gengns avatar gengns commented on June 4, 2024 1

Awesome, it works like a charm. Great job @yuanchuan, thank you so much!

from sveltekit-autoimport.

yuanchuan avatar yuanchuan commented on June 4, 2024

I can't reproduce it. Have you tried restarting the server?

from sveltekit-autoimport.

gengns avatar gengns commented on June 4, 2024

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

  1. clone repo
  2. npm i && npm run dev
  3. [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.

yuanchuan avatar yuanchuan commented on June 4, 2024

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.

gengns avatar gengns commented on June 4, 2024

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.

yuanchuan avatar yuanchuan commented on June 4, 2024

Just released 1.7.0, should fix the undefined fly identifier.

from sveltekit-autoimport.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.