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

Vite not transpiling imports in TypeScript worker imported using new Worker. #14535

Closed
7 tasks done
segevfiner opened this issue Oct 4, 2023 · 1 comment
Closed
7 tasks done
Labels
duplicate This issue or pull request already exists

Comments

@segevfiner
Copy link
Contributor

Describe the bug

When importing a TypeScript worker using new Worker without {type: 'module'}, Vite will not transpile imports in the TypeScript module (Although it does inject importScripts("/@vite/env"), instead of an ESM import) which results in:

Uncaught SyntaxError: Cannot use import statement outside a module (at worker.ts?type=classic&worker_file:2:1)

Reproduction

https://stackblitz.com/edit/vitejs-vite-bthmfa?file=src%2Fmain.ts

Steps to reproduce

Open the reproduction and look at the console.

System Info

System:
    OS: Linux 5.0 undefined
    CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 0 Bytes / 0 Bytes
    Shell: 1.0 - /bin/jsh
  Binaries:
    Node: 18.18.0 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 9.4.2 - /usr/local/bin/npm
    pnpm: 8.6.12 - /usr/local/bin/pnpm
  npmPackages:
    @vitejs/plugin-vue: ^4.4.0 => 4.4.0 
    vite: ^5.0.0-beta.4 => 5.0.0-beta.4

Used Package Manager

npm

Logs

No response

Validations

@sapphi-red
Copy link
Member

Duplicate of #8470

@sapphi-red sapphi-red marked this as a duplicate of #8470 Oct 5, 2023
@sapphi-red sapphi-red closed this as not planned Won't fix, can't repro, duplicate, stale Oct 5, 2023
@sapphi-red sapphi-red added duplicate This issue or pull request already exists and removed pending triage labels Oct 5, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Oct 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants