svelteuidev / svelteui

SvelteUI Monorepo
https://svelteui.dev
MIT License
1.27k stars 63 forks source link

Warning about dependencies in different chunks #438

Closed alinex closed 1 year ago

alinex commented 1 year ago

What package has an issue

@svelteuidev/core

A clear and concise description of what the bug is

After adding the UI to my layout in a new Sveltekit application I got some errors while building the server:

[WebServer] Export "theme" of module "node_modules/@svelteuidev/core/dist/stitches.config.js" was reexported through module "node_modules/@svelteuidev/core/dist/styles/index.js" while both modules are dependencies of each other and will end up in different chunks by current Rollup settings. This scenario is not well supported at the moment as it will produce a circular dependency between chunks and will likely lead to broken execution order.
Either change the import in "node_modules/@svelteuidev/core/dist/styles/theme/SvelteUIProvider/default-theme.js" to point directly to the exporting module or reconfigure "output.manualChunks" to ensure these modules end up in the same chunk.

My layout looks like +layout.svelte:

<script>
    import { colorScheme, SvelteUIProvider, Stack, Switch, Text } from '@svelteuidev/core';

    if (typeof window !== 'undefined')
        colorScheme.update(() =>
            window.matchMedia('(prefers-color-scheme: light)').matches ? 'light' : 'dark'
        );
    function toggleTheme() {
        colorScheme.update((v) => (v === 'light' ? 'dark' : 'light'));
    }
</script>

<SvelteUIProvider withGlobalStyles themeObserver={$colorScheme}>
    <Stack align="center">
        <Text>Press to change the theme</Text>
        <Switch on:change={toggleTheme} />
    </Stack>
    <slot />
</SvelteUIProvider>

In which browser(s) did the problem occur?

Other - list in description

Steps To Reproduce

npm run build # will produce 8 such warnings

Do you know how to fix the issue

No

Are you willing to participate in fixing this issue and create a pull request with the fix

Yes

Relevant Assets

No response

BeeMargarida commented 1 year ago

I made a commit yesterday to fix this, but I'll double check today that this specific error is also fixed. Thank you for reporting!

BeeMargarida commented 1 year ago

Yap, it's fixed already in main, should be fixed in the next release.