Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

broadcast-channel error with SvelteKit #82

Closed
finnstrand opened this issue Apr 14, 2022 · 3 comments
Closed

broadcast-channel error with SvelteKit #82

finnstrand opened this issue Apr 14, 2022 · 3 comments

Comments

@finnstrand
Copy link

finnstrand commented Apr 14, 2022

I get broadcast-channel error with 1.6 and SvelteKit .311

[plugin:vite:import-analysis] Failed to resolve import "broadcast-channel" from "node_modules/@sveltestack/svelte-query/svelte/queryCore/broadcastQueryClient-experimental/index.js". Does the file exist?
[/Users/finn/Documents/Projects/wip/node_modules/@sveltestack/svelte-query/svelte/queryCore/broadcastQueryClient-experimental/index.js:3:47]()
1  |  import '../core';
2  |  export async function broadcastQueryClient({ queryClient, broadcastChannel = 'svelte-query', }) {
3  |      const { BroadcastChannel } = await import('broadcast-channel');
   |                                                ^
4  |      let transaction = false;
5  |      const tx = (cb) => {

Hello,

A new version (v1.5.0) of this library has been published today.
This version makes broadcast-channel an optional dependency.
This should fix all problems with svelte-kit.

If you need to use the experimental broadcastQueryClient, you now need to install it manually (see: broadcastQueryClient).

If you still encounter issues with v1.5.0. Please open a new issue.

Originally posted by @SomaticIT in #39 (comment)

@SomaticIT
Copy link
Collaborator

Hello,

This is a duplicate of #63.
The issue comes from vite: vitejs/vite#6007.

I'm closing this issue to avoid duplication.

Thanks for your report.

@SomaticIT
Copy link
Collaborator

FYI, you just have to install broadcast-channel as a dev dependency to allow vite to parse the package in development.
It will not be included in production.

@SomaticIT
Copy link
Collaborator

FYI, with the latest version of vite (v3.1.0-beta.1) that is included in the latest version of sveltekit, this issue should be 100% resolved.

Indeed, vite is now able to detect optional dependencies and should not try to analyze them when it's not needed.

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

No branches or pull requests

2 participants