vite-plugin / vite-plugin-dynamic-import

Enhance Vite builtin dynamic import
https://www.npmjs.com/package/vite-plugin-dynamic-import
MIT License
193 stars 11 forks source link

How can I import from some package? #47

Closed harryqt closed 1 year ago

harryqt commented 1 year ago

How can I do this?

<script>
  let country = "Us";
</script>

<button on:click={() => (country = "Uk")}>Click</button>

{#await import(`/node_modules/svelte-flag-icons/dist/${country}.svelte`) then Icon} // works only for first render
{#await import(`svelte-flag-icons/${country}.svelte`) then Icon} // does not work
  <Icon.default />
{/await}

Repo: https://github.com/Dibbyo456/dynamic-import-help-wanted