yiliansource / party-js

A JavaScript library to brighten up your user's site experience with visual effects!
https://party.js.org
MIT License
986 stars 45 forks source link

Dynamic importing of party-js #69

Closed Bandit closed 3 years ago

Bandit commented 3 years ago

Guess I'm doing something wrong here, but why do I need to do this module.default.default thing to get a dynamic import to work? (This is Sveltekit code)

    onMount(async () => {
        if (confetti && browser) {
            const module = await import("party-js");
            const party = module.default.default;

            party.confetti(el, {
                count: party.variation.range(20, 40),
            });
        }
    });
yiliansource commented 3 years ago

Hey there, sorry for the very late response, have been dealing with some health issues recently.

What version of the library are you on? I remember moving some stuff around, might have accidentally broke something with imports.

Bandit commented 3 years ago

2.0.1

yiliansource commented 3 years ago

Weird issue. I'm not familiar with how exactly async importing in Svelte works, but this minimal example works without the defaults. Can you maybe check what the return type of the import statement is?

Bandit commented 3 years ago

Thanks for looking into this - just a heads up that I'm really busy on some other things. Will come back to this and re-open it with more detail / example repo 👍