josefaidt / svelte-themer

A theming engine for your Svelte apps using CSS Variables, persisted.
https://svelte-themer.vercel.app/
MIT License
140 stars 14 forks source link

Uncaught TypeError: ThemeWrapper is not a constructor #33

Closed AnicetNgrt closed 3 years ago

AnicetNgrt commented 3 years ago

Hi.

Using sveltejs/template with nothing modified except svelte-themer ^0.4.8 installed as a dev dependency.

// App.svelte
<script>
    import { ThemeWrapper, ThemeToggle } from 'svelte-themer'
</script>

<ThemeWrapper>
    <main>
        <h1>svelte themer</h1>
        <ThemeToggle />
    </main>
</ThemeWrapper>

<style>
    :global(html) {
        background-color: var(--theme-colors-background, initial);
        color: var(--theme-colors-text, initial);
    }
</style>

npm run dev

In the browser console all I get is

Uncaught TypeError: ThemeWrapper is not a constructor
    create_fragment bundle.js:2449
    init index.mjs:1500
    App bundle.js:2518
    app main.js:3
    <anonymous> bundle.js:2536

I'm a Svelte noob, am I missing something?

Thank you for your consideration.

josefaidt commented 3 years ago

Hey :wave: thanks for raising this! I'm seeing this as well in a bare bones codesandbox instance. I think I messed the ES build up when aiming to support SSR in svelte-kit. After reverting that change it seemed to fix things (published to next) https://codesandbox.io/s/hungry-haze-0lvm8?file=/App.svelte

Looking into producing the proper ssr bundle

josefaidt commented 3 years ago

@AnicetNgrt this should be fixed in 0.4.9!

AnicetNgrt commented 3 years ago

Thank you! About to check this out

AnicetNgrt commented 3 years ago

Upgraded to 0.4.9, looks like I still have it...

josefaidt commented 3 years ago

Hmm let me take a deeper look into what's going on.

josefaidt commented 3 years ago

@AnicetNgrt I'm not able to reproduce this with the template you mentioned using

npx degit sveltejs/template my-app

and adding svelte-themer as a devDependency or dependency should work with that setup

AnicetNgrt commented 3 years ago

I'll try to restart from scratch tomorrow @josefaidt

AnicetNgrt commented 3 years ago

@josefaidt It's working after restarting from scratch. Must have been a mistake on my side. Thanks for the fast fix!