Skip to content

Can't import other script/lib in worker #1909

@ahaoboy

Description

@ahaoboy

⚠️ IMPORTANT ⚠️ Please check the following list before proceeding. If you ignore this issue template, your issue will be directly closed.

  • Read the docs.
  • Use Vite >=2.0. (1.x is no longer supported)
  • If the issue is related to 1.x -> 2.0 upgrade, read the Migration Guide first.

Describe the bug

1, I can't import other script/lib in worker, when Import other script, worker init failed and not error msg.

2, How can I use sharedworker in vite? I use import url, but it also can't import other script
I try this way, but failed. chrome inspect can see error log:
import SW_URL from "./sharedworker.js?url";
const sw = new SharedWorker(SW_URL);
image

Reproduction

github/vite2-worker-bug

System Info

  • vite version: ^2.0.0-beta.65
  • Operating System: windows10
  • Node version: 14
  • Package manager (npm/yarn/pnpm) and version: yarn 1.22.4

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions