feat: support generating multiple difference versions of worker files e.g. iife and esm
See original GitHub issueClear and concise description of the problem
Due to size of my project, I generate multiple large worker files, but vite currently only supports generating worker files in either iife mode or esm mode.
The problem is that using esm from just a treeshake perspective, drastically improves perfs. but using esm means I can’t support Firefox, and using iife means a noticeable delay in load times.
Suggested solution
- Support generating multiple different worker files, giving the user the ability to customize these files, not too different from vite’s current build.lib option. The user could then on their own determine when to use which worker file in their own code.
Alternative
- Support treeshaking iife workers, I don’t know if that is possible?
Additional context
I am building an online bundler using esbuild-wasm
, monaco
, a bunch of fairly large plugin logic for esbuild, a couple instances of typescript, an instance of rollup
, etc… All these files mean the worker file can ballon quite a bit very quickly.
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn’t already an issue that request the same feature to avoid creating a duplicate.
Issue Analytics
- State:
- Created a year ago
- Comments:13 (7 by maintainers)
Top Results From Across the Web
What Are CJS, AMD, UMD, ESM, System, and IIFE?
SystemJS is a universal module loader that supports CJS, AMD, and ESM modules. Rollup can bundle the code into SystemJS's native format. The ......
Read more >Understanding (all) JavaScript module formats and tools
After all the module mess, in 2015, JavaScript's spec version 6 introduces one more different module syntax. This spec is called ECMAScript ...
Read more >ServiceDesk Plus readme, release notes, and version history
View the readme release notes of ServiceDesk Plus, an ITIL-ready help desk software with integrated asset management and project management functionalities.
Read more >Modules: Packages | Node.js v19.3.0 Documentation
The "exports" provides a modern alternative to "main" allowing multiple entry points to be defined, conditional entry resolution support between environments, ...
Read more >Build A Library With esbuild - Medium
You can use esbuild to bundle libraries from vanilla JavaScript source files but, at least in this tutorial, we are going to use...
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
@sapphi-red @patak-dev Is there any progress?
Also, @sapphi-red SSR mode doesn’t support
new URL(url, import.meta.url)
and from what I can tellimport Worker from "./worker.ts?worker";
never produces an esm output no matter what you change the worker format to, leaving me and I’d better others kinda stuck.@sapphi-red That isn’t the problem. I want to bundle the worker as both esm and iife