Repository navigation
Why is importScripts added to the scripts #22256
solodeveloping
started this conversation in
Feedback
Replies: 3 comments
|
In the console, the error is "Uncaught NetworkError: Failed to execute 'importScripts' on 'WorkerGlobalScope': The script at 'http://localhost:3303/@vite/env' failed to load." by the way |
0 replies
|
I found the answer, the fact it's imported as a classic worker and not a module worker seem to be causing the problem (I don't know why though). |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment

Uh oh!
There was an error while loading. Please reload this page.
Hi,
I'm encountering an issue where a script cannot load because "importScripts("/@vite/env");" is added to some scripts, and then they get blocked, stopping the loading of the script, stopping the library from being used.
I think it would be nice to know why it's added and how to stop it.
It's added:
Then it's blocked:
It's in a worker which I import like this:
The worker is working, it's inside the worker that it fails.
Inside the lib, they do this "const W = new Worker(new URL("sqlite3-opfs-async-proxy.js", import.meta.url));"
I've seen a post on reddit recommending to do "type: 'classic'" instead of module, but I can't really modify their import.
In https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Using_web_workers they don't say that importScripts is only for classic, but this page does https://developer.mozilla.org/en-US/docs/Web/API/Worker/Worker and the default is classic.
And the URL is in the screenshot seem to be indicating "classic".
The URL "/@vite/env exists, I can load it separately.
I'm going to test classic for the first Worker after posting this, I'll add an answer if it's useful.
I'm surprised that Vite is modifying the scripts though, since I have @sqlite.org/sqlite-wasm in my optimizeDeps.exclude
It's not Brave blocking the script, because it does not show the little number, I'm not sure why it's blocked, but wouldn't it be nice if the reason was something else than "blocked:other" (it's probably not Vite either).
Is there a way to stop Vite from injecting things in the scripts?
Thank you in advance,
All reactions