kt3k / packup

📦 Zero-config web application packager for Deno
https://packup.deno.dev/
MIT License
327 stars 18 forks source link

Support for workers and service workers #17

Open austincummings opened 2 years ago

austincummings commented 2 years ago
// Web worker
new Worker("./worker.ts");
// Service worker
navigator.serviceWorker.register("./sw.ts");

These types of dependencies may end up being something that comes for free if esbuild adds support for these syntaxes, but I figured I would create an issue to propose this here too for consideration.

evanw/esbuild#312 evanw/esbuild#1602

Edit: Could maybe even pull in this plugin that looks to add support for new Worker, and then add a similar plugin for service workers

kt3k commented 2 years ago

parcel seems supporting service worker https://github.com/parcel-bundler/parcel/pull/398

This looks something we should support in the future. Thank you for raising the issue

okikio commented 2 years ago

You can setup a temporary solutions using a plugin https://github.com/okikio/bundle/blob/main/plugins/worker.js

To use workers you would then,

import FILE_WORKER_URL from "worker:./workers/file.ts";
// ...
new Worker(FILE_WORKER_URL, { /* Any other options you need... */ })
okikio commented 2 years ago

@Blue-Skyer I would assume that by looking at the URL it would be rather clear where the solution came from.