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

During Legacy builds worker files are not generated with renderModernChunks set to false #18558

Open
7 tasks done
christowiz opened this issue Nov 2, 2024 · 2 comments
Open
7 tasks done
Labels
feat: web workers p3-minor-bug An edge case that only affects very specific usage (priority) plugin: legacy

Comments

@christowiz
Copy link

Describe the bug

I am trying to create a legacy-only build (no modern chunks) using the Legacy plugin that outputs working code which includes the web worker files.

What is happening is that when renderModernChunks is set to false the worker file is not created during the build but is still referenced inside the bundled code. When renderModernChunks is either set to true or absent from the config the worker files are generated correctly.

This works correctly in dev mode

From a cursory examination I found that if I removed the conditional inside the legacyPostPlugin.configResolved method the worker files are generated correctly and the index.html file is output correctly. I haven't had time to dig any deeper.

image

Note: The reason I need a legacy only build is the HTML that is generated which supports both legacy and modern does not work on older browsers. This is a separate issue.

Reproduction

https://stackblitz.com/edit/vitejs-vite-zsxp4m?file=vite.config.js

Steps to reproduce

  • Run vite build (or npm run build)
  • View /dist/assets, no worker file exists
    • image
  • View /dist/assets/index-legacy-HASH.js file to see reference to worker file

image

Testing

  • Run vite preview or npx serve dist
  • In preview mode console will log errors and serve will display 404 errors for missing worker file

With Modern

  • Change renderModernChunks to true or remove completely from vite.config.js
  • Run vite build
  • View /dist/assets, worker file exists

Difference being the generated index.html file

System Info

## StackBlitz
  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.20.3 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 10.2.3 - /usr/local/bin/npm
    pnpm: 8.15.6 - /usr/local/bin/pnpm
  npmPackages:
    @vitejs/plugin-legacy: ^5.4.3 => 5.4.3 
    vite: ^5.4.10 => 5.4.10 

## Local
  System:
    OS: macOS 14.6.1
    CPU: (10) arm64 Apple M1 Pro
    Memory: 152.56 MB / 16.00 GB
    Shell: 5.9 - /opt/homebrew/bin/zsh
  Binaries:
    Node: 22.9.0 - ~/Library/pnpm/node
    npm: 10.9.0 - ~/Library/pnpm/npm
    pnpm: 9.7.1 - /opt/homebrew/bin/pnpm
    bun: 1.1.30 - ~/.bun/bin/bun
    Watchman: 2024.10.21.00 - /opt/homebrew/bin/watchman
  Browsers:
    Chrome: 130.0.6723.92
    Chrome Canary: 132.0.6813.0
    Safari: 18.0
  npmPackages:
    @vitejs/plugin-legacy: 5.4.3 => 5.4.3 
    vite: 5.4.10 => 5.4.10

Used Package Manager

npm

Logs

No response

Validations

@bluwy
Copy link
Member

bluwy commented Nov 4, 2024

Is this the same as #16639 (but english)?

@christowiz
Copy link
Author

christowiz commented Nov 4, 2024

Is this the same as #16639 (but english)?

I guess it is (after viewing the translation). Looks like that is from May 8th with no comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat: web workers p3-minor-bug An edge case that only affects very specific usage (priority) plugin: legacy
Projects
None yet
Development

No branches or pull requests

3 participants