deno: `deno compile` does not have web worker support
This is a tracking issue to investigate how we can support web workers in deno compile.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 69
- Comments: 16 (4 by maintainers)
Just want to bump this, I’ve been working on an project that doesn’t use just one, but two workers 😅 It’s the foundation for working on a desktop app using webview_deno, and using a worker to serve the page, assets, and a websocket connection from an oak-based web server. The second worker runs a long-running subprocess. I compile the static web assets into binaries using denobundle so they can be bundled with the binary. This is the best way so far I’ve found to build a GUI with deno. Just need the final step of wrapping it all together!
Definitely not ready for widespread use yet, but it’s a simple GUI for managing Docker containers.
https://github.com/jcs224/dockersaurus
This feature would be a great addition and allow us to use the standalone binary since web workers is one of our requirements. Encoding the worker modules as
data:URLs would work great if possible.+1 to this. could base64 be a first step?
Just tried this with 1.32, works now! I think this can be closed now, per https://github.com/denoland/deno/pull/17657
With
deno compile, all module fetching and Typescript compilation happens at compile time, so you can be sure that remote imports haven’t changed under the hood, for example. With regular imports, the whole module graph can be tracked, fetched and transpiled at compile time. However, with workers, the worker’s main module is given as a string which might be built up at runtime, and combined with other factors it means it’s not easy to statically analyze a worker’s main module at compile time.Starting in 1.32,
deno compilehas an--includeflag which lets you specify additional modules which will be fetched and transpiled at compile time, along with their imports, recursively. You can use it asdeno compile --include ./worker1.ts --include ./worker2.ts --output compile main.tsAs for
data:URLs, Deno doesn’t support Typescript with them, so they can work without being in the module map at compile time. But if thedata:URL imports another (non-data:) module, that module will need to be in the module graph.