Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for workers and service workers #17

Open
austincummings opened this issue Sep 14, 2021 · 3 comments
Open

Support for workers and service workers #17

austincummings opened this issue Sep 14, 2021 · 3 comments

Comments

@austincummings
Copy link
Contributor

austincummings commented Sep 14, 2021

// 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
Copy link
Owner

kt3k commented Sep 14, 2021

parcel seems supporting service worker parcel-bundler/parcel#398

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

@okikio
Copy link

okikio commented Sep 17, 2021

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
Copy link

okikio commented May 16, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants
@kt3k @austincummings @okikio and others