-
-
Notifications
You must be signed in to change notification settings - Fork 7.2k
Open
Labels
feat: web workersp2-edge-caseBug, but has workaround or limited in scope (priority)Bug, but has workaround or limited in scope (priority)plugin: legacy
Description
Describe the bug
After running vite build
, Worker is built in legacy mode with the {type: "module"}
option, which is undesirable in this case and results in the application breaking in older browser versions.
vite.config.ts
import vue from '@vitejs/plugin-vue';
import legacy from '@vitejs/plugin-legacy';
import { resolve } from 'path';
import { defineConfig } from 'vite';
export default defineConfig({
plugins: [vue(), legacy()],
build: {
reportCompressedSize: false,
},
worker: {
format: 'iife', // 'es' produces the same output
},
resolve: {
alias: {
'@': resolve(__dirname, './src'),
},
},
});
index-legacy.057ce815.js
return new Worker("/assets/tv.worker.b73a6f8e.js", {type: "module"})
Reproduction
https://stackblitz.com/edit/node-kfimtt
System Info
System:
OS: macOS 12.2
CPU: (8) x64 Intel(R) Core(TM) i5-1038NG7 CPU @ 2.00GHz
Memory: 1.82 GB / 16.00 GB
Shell: 5.8 - /bin/zsh
Binaries:
Node: 17.4.0 - /usr/local/bin/node
Yarn: 1.22.17 - /usr/local/bin/yarn
npm: 8.4.0 - /usr/local/bin/npm
Browsers:
Brave Browser: 98.1.35.100
Chrome: 60.0.3112.113
Safari: 15.3
npmPackages:
@vitejs/plugin-legacy: ^1.6.4 => 1.6.4
@vitejs/plugin-vue: ^2.1.0 => 2.1.0
vite: ^2.8.0-beta.5 => 2.8.0-beta.5
Used Package Manager
npm
Logs
No response
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- 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 https://github.com/vuejs/core instead.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
Menci, edumudu, SenseiHiraku, nulladdict, robertveloso and 1 more
Metadata
Metadata
Assignees
Labels
feat: web workersp2-edge-caseBug, but has workaround or limited in scope (priority)Bug, but has workaround or limited in scope (priority)plugin: legacy