sveltejs / svelte

web development for the rest of us
https://svelte.dev
MIT License
80.14k stars 4.26k forks source link

import "with" attribute crashs #12551

Open Inqnuam opened 4 months ago

Inqnuam commented 4 months ago

Describe the bug

using with or assert in import attributes (import statement or dynamic import) crashs

Reproduction

<script lang="ts">
 import Miaou from "./cat.svelte" with { type: "animal" };
</script>

Logs

Unexpected token
import Miaou from "./cat.svelte" with { type: "json" };
                                    ^

System Info

svelte@4.2.18

Severity

annoyance

dummdidumm commented 4 months ago

We're using Acorn, which needs to implement the new syntax (which will likely only happen once it is Stage 4): https://github.com/acornjs/acorn/issues/1289

Until then you could

Inqnuam commented 4 weeks ago

@dummdidumm Acorn 8.14.0 is now released with support for with import attribute Could you please update Svelte 4 and 5 acorn dependencies ?

Conduitry commented 3 weeks ago

Acorn now supports this, and Svelte no longer refuses to compile components with these imports, but the with clause is now silently dropped. I'm not sure where it's going to need to happen to preserve that. https://github.com/Rich-Harris/esrap ?