Vite build doesn‘t work with virtual modules imported from WebWorker
See original GitHub issueDescribe the bug
Only by adding this plugin to rollup as well will it pass compilation.
import plugin from './plugin.js';
export default {
plugins: [plugin()],
build: {
rollupOptions: {
// plugins: [plugin()],
},
},
};
More details can be found in the reproduction. trust me, it is a minimal and will not waste too much of your time.
Reproduction
https://stackblitz.com/edit/vitejs-vite-mojc3s?file=vite.config.js
System Info
n/a
Used Package Manager
pnpm
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.
Issue Analytics
- State:
- Created a year ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Features | Vite (main branch)
Vite will detect such bare module imports in all served source files and perform the following: Pre-bundle them to improve page loading speed...
Read more >A deep-dive on Vite featuring Evan You (JS Party #212)
Amal and Nick load up on coffee for a not-so-vite (lame joke!) ... for example when you import Lodash - so Lodash has...
Read more >Bundling Extensions - Visual Studio Code
When VS Code is running in the browser, it can only load one file for your ... look for `browser` entry point in...
Read more >Output - webpack
The format of chunks (formats included by default are 'array-push' (web/WebWorker), 'commonjs' (node.js), 'module' (ESM), but others might be added by plugins).
Read more >Recommended - SlideShare
Virtual Modules Convention Virtual. ted char in import URLs so we have to replace them during import analysis. A. Modify Vite config before ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
For consistency, we should also keep the root-level plugin from taking effect on worker during the dev phase. Or print a warning message.
Changing the config like below will fix this.
I’m not sure why
worker.plugins
exists separately.