Skip to content

Warning about dependencies in different chunks #438

@alinex

Description

@alinex

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions