Reputation: 2999
I have a svelte component library with a structure like this
lib
└ index.js [1]
└ components
└ index.js [2]
└ Badge.svelte
[1]
export * as component from "./component";
[2]
export { default as Badge } from "./Badge.svelte";
this sort of works. But when trying to use the Badge
component I have to import it in a rather funky way that I would like to get rid of
<script>
import { component } from 'style';
const Badge = component.Badge;
</script>
<Badge count="4" color="green">new words</Badge>
And I wonder, is it possible to do the same, but without the const Badge = component.Badge;
line?
Upvotes: 0
Views: 50
Reputation: 74126
If in [1] you export like this:
[1]
export * from "./component";
You'll be able to import like this:
import { Badge } from './lib';
Upvotes: 1