halfmoon icon indicating copy to clipboard operation
halfmoon copied to clipboard

require problem while using with sveltekit.

Open xeroticikot opened this issue 3 years ago • 1 comments

How can npm installation can be used in sveltekit? Tried different ways, but nothing's working for me. Any reference would've been helpful & much appreciated.

xeroticikot avatar Jun 06 '22 04:06 xeroticikot

Svelte doesn't support require so you have to use import instead, and since import creates a promise you need to use await on the import before initialising inside the DOM.

    import { onMount } from "svelte";
    import("halfmoon/css/halfmoon-variables.min.css");

    onMount(async () => {
    const halfmoon = await import("halfmoon");
    halfmoon.default.onDOMContentLoaded();
    });

EPD24 avatar Feb 11 '23 16:02 EPD24