You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have encountered a bug in Vite when using a worker that calls import, even if the import isn't directly called, and there is a globally defined window variable.
Expected Behavior
The application should run without any errors.
Actual Behavior
An error occurs when the worker is instantiated, even though the import function is not directly called.
Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to vuejs/core instead.
Describe the bug
I have encountered a bug in Vite when using a worker that calls
import
, even if theimport
isn't directly called, and there is a globally definedwindow
variable.Expected Behavior
The application should run without any errors.
Actual Behavior
An error occurs when the worker is instantiated, even though the
import
function is not directly called.Steps to Reproduce
Create a new Svelte app using Vite:
pnpm create vite@latest my-app -- --template svelte cd my-app pnpm install
Create a worker file (
worker.js
) that defines a function callingimport
:In the main application file (
App.svelte
), import the worker and create a new instance of it:In the Vite configuration file (
vite.config.js
), define a globalwindow
variable:Run the application using
pnpm run dev
and observe the error.Reproduction
You can find a minimal reproduction of the bug in the following repository:
https://github.com/mustafa0x/vite-worker-bug
You can also find a live reproduction on StackBlitz:
https://stackblitz.com/edit/vitejs-vite-zyhbeh
System Info
Used Package Manager
pnpm
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: