SvelteStack / svelte-query

Performant and powerful remote data synchronization for Svelte
https://sveltequery.vercel.app
MIT License
822 stars 30 forks source link

broadcast-channel required in sapper/webpack build #73

Open vboulaye opened 2 years ago

vboulaye commented 2 years ago

Hi,

I have a project using sapper + webpack and svelte-query in version 1.4.1 which works fine.

I tried to upgrade svelte-query to 1.6.0 but it does not build anymore.

I reproduced the issue by starting a new project from the sapper template and just adding the QueryClient in _layout.svelte

When I npm run build I get:

ERROR in ./node_modules/@sveltestack/svelte-query/svelte/queryCore/broadcastQueryClient-experimental/index.js
Module not found: Error: Can't resolve 'broadcast-channel' in '/home/uvba7442/dev/misc/svelte-query-test/node_modules/@sveltestack/svelte-query/svelte/queryCore/broadcastQueryClient-experimental'
 @ ./node_modules/@sveltestack/svelte-query/svelte/queryCore/broadcastQueryClient-experimental/index.js 3:39-66
 @ ./node_modules/@sveltestack/svelte-query/svelte/queryCore/index.js
 @ ./node_modules/@sveltestack/svelte-query/svelte/index.js
 @ ./src/routes/_layout.svelte
 @ ./src/node_modules/@sapper/internal/manifest-client.mjs
 @ ./src/node_modules/@sapper/app.mjs
 @ ./src/client.js
> Encountered errors while building app

if I npm add broadcast-channel I get errors like Error: Can't resolve 'fs' in '/.../node_modules/broadcast-channel/dist/esnode/methods' instead.

I suppose that I am missing something in the webpack config, but maybe I should rather migrate to svelte-kit instead ?

Is there something to do in the build config to make it ignore the BroadcastQueryClient when it is not used ?