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

[plugin-legacy]-配置@vitejs/plugin-legacy的renderModernChunks选项为false时,无法打包出workers相关的文件 #16639

Open
7 tasks done
winteroo opened this issue May 9, 2024 · 1 comment

Comments

@winteroo
Copy link

winteroo commented May 9, 2024

Describe the bug

我在vite工程中使用workers做复杂计算,在开发环境下是可以正常运行的,但是当我执行打包后,workers无法运行,经过查看打包后的文件,发现缺少了workers打包文件。

打包的文件中,可以找到引入workers的代码:(此时@vitejs/plugin-legacy插件的renderModernChunks为false)

image

但是在dist文件夹下却没有该文件:

image

我尝试将@vitejs/plugin-legacy插件中的renderModernChunks设置为true,生成支持现代浏览器的文件,发现打包后是可以正常运行的,且存在该workers文件。

image

故我猜测是@vitejs/plugin-legacy插件的renderModernChunks配置项影响了workers的打包

Reproduction

https://stackblitz.com/edit/vitejs-vite-fzyjtb?file=worker.js

Steps to reproduce

  1. npm install
  2. npm run dev ,项目正常启动,并可以在控制台中打印出worker接受到的信息,说明worker正常运行了
  3. npm run build 打包后的文件中并没有worker相关文件

System Info

System:
    OS: macOS 14.0
    CPU: (8) arm64 Apple M1 Pro
    Memory: 93.75 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.14.2 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 9.5.0 - /usr/local/bin/npm
    pnpm: 7.33.0 - /usr/local/bin/pnpm
  Browsers:
    Chrome: 124.0.6367.119
    Safari: 17.0
  npmPackages:
    @vitejs/plugin-legacy: ^5.4.0 => 5.4.0 
    @vitejs/plugin-vue: ^4.2.3 => 4.2.3 
    vite: ^5.2.11 => 5.2.11

Used Package Manager

pnpm

Logs

No response

Validations

Copy link

stackblitz bot commented May 9, 2024

Fix this issue in StackBlitz Codeflow Start a new pull request in StackBlitz Codeflow.

@winteroo winteroo changed the title 配置@vitejs/plugin-legacy的renderModernChunks选项为false时,无法打包出workers相关的文件 [plugin-legacy]-配置@vitejs/plugin-legacy的renderModernChunks选项为false时,无法打包出workers相关的文件 May 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant