Skip to content

AutoImport bug when used, while we have context="module" script in .Svelte file, and already something imported. #660

@Mlocik97

Description

@Mlocik97

Describe the bug
When I use autoImport to import onMount or onDestroy or other things from Svelte, and we already have something imported (for example component, json, or some script, library) and we also have context="module" script in that .Svelte file, AutoImport missplace import in file, so it's out from <script> tag.

To Reproduce

<script context="module">
	export let a;
</script>

<script>
	import * as data from "../data/data.json";

	onM| // | is position of cursor, where I press tab.
</script>

<div>{data}</div>

in result, I get:

<script context="module">
	export let a;
</script>
import { onMount } from 'Svelte'; // THIS IS BUG!!!

<script>
	import * as data from "../data/data.json";

        onMount()
</script>

<div>{data}</div>

Expected behavior

<script context="module">
	export let a;
</script>

<script>
        import { onMount } from 'Svelte';
	import * as data from "../data/data.json";

        onMount()
</script>

<div>{data}</div>

Screenshots
Not Screenshot, just whole video: https://www.youtube.com/watch?v=6Mz-xZq-ffs&feature=youtu.be

System (please complete the following information):

  • OS: Ubuntu 20.04
  • IDE: VS Code
  • Plugin/Package: [Svelte for VS Code]

Additional context
(none)

Metadata

Metadata

Assignees

No one assigned

    Labels

    FixedFixed in master branch. Pending production release.bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions