Skip to content

Conversation

benmccann
Copy link
Contributor

Fixes #45. I hope. Note that I've never used svelte-query and haven't tested this. That being said, I got some changes into broadcast-channel that I believe should make it compatible with SvelteKit. You might have to define process.browser if Vite doesn't, but besides that I hope it should just work

@dimfeld
Copy link

dimfeld commented Jul 26, 2021

Thanks for working on this Ben! I'm still seeing problems during Vite SSR phase here, where it tries to load node.js which uses require.

More details below, but I've also created a minimal reproduction here: https://github.com/dimfeld/sveltekit-with-svelte-query. This repo is set up with pnpm and so you can override the version of broadcast-channel used in the pnpm.overrides section of package.json. Hope it helps!

So first I see this error:

ReferenceError: require is not defined
    at /node_modules/.pnpm/broadcast-channel@4.0.0/node_modules/broadcast-channel/src/methods/node.js:6:14
    at instantiateModule (/home/dimfeld/projects/vite/packages/vite/dist/node/chunks/dep-ea6d097e.js:73433:166)

Notably, this is the version in the src directory. I see a comment in the source that it's faster to run the non-transpiled version here, but it does seem to cause issues. If I change the import to the transpiled version (./methods/node.js) then it gets past that, but actually runs into issues with in babel runtime's async transformation code.

ReferenceError: module is not defined
    at /node_modules/.pnpm/@babel+runtime@7.14.8/node_modules/@babel/runtime/helpers/asyncToGenerator.js?v=710ddb8b:35:1
    at instantiateModule (/home/dimfeld/projects/vite/packages/vite/dist/node/chunks/dep-ea6d097e.js:73433:166)

@benmccann
Copy link
Contributor Author

Thanks for the reproduction. That does help. I'll close this for now

@benmccann benmccann closed this Jul 26, 2021
@frederikhors
Copy link
Collaborator

I've never used svelte-query

@benmccann why? Can I ask you what are you using right now? Will you ever use it in the future?

@benmccann
Copy link
Contributor Author

It's nothing against svelte-query. There's just more libraries out there than I've had a chance to use 😄 I may use it in the future

@frederikhors
Copy link
Collaborator

Yes, that's what I meant. I just don't know them. Can you tell me what they are?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Still issues with broadcast-channel dependency and svelte-kit
3 participants