question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

feat: support generating multiple difference versions of worker files e.g. iife and esm

See original GitHub issue

Clear 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

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:13 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
okikiocommented, Jun 28, 2022

@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 tell import 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.

1reaction
okikiocommented, Jun 4, 2022

@sapphi-red That isn’t the problem. I want to bundle the worker as both esm and iife

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found