You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<scriptlang="ts">
import*asmfrom"./messages"
</script>
<p>{m.$loginButton}</p> // 💥 -> undefined
<p>{$m.loginButton}</p> // 💥 -> `m` is not a store with a subscribe method
Tree-shaking while retaining access to "many imports".
We are evaluating if we build the inlang i18n library for SvelteKit tree-shakable to solve one major complexity of i18n libs: don't ship unused translations. Using namespace syntax would resemble current i18n libraries which use t("key", { name: "inlang"} ). A namespace import would result in t.key({ name: "inlang" }) which provides autocomplete and familiarity.
This is the expected behavior. There's no way to automatically subscribe to a store unless it's a top-level variable in your component (#4079) and if you do a * as foo import, it's no longer a top-level variable.
Describe the bug
Problem
ESM namespace imports
import * as foo from "x"
wherex.foo
is a store seems to break the Svelte compiler.messages.ts
App.svelte
The following works
App.svelte
Why namespace support is of interest
Tree-shaking while retaining access to "many imports".
We are evaluating if we build the inlang i18n library for SvelteKit tree-shakable to solve one major complexity of i18n libs: don't ship unused translations. Using namespace syntax would resemble current i18n libraries which use
t("key", { name: "inlang"} )
. A namespace import would result int.key({ name: "inlang" })
which provides autocomplete and familiarity.Reproduction
https://stackblitz.com/edit/vitejs-vite-gvzxkv?file=src%2FApp.svelte
Logs
No response
System Info
See stackblitz reproduction svelte: ^4.1.2 => 4.2.0
Severity
blocking an upgrade
The text was updated successfully, but these errors were encountered: