developit / developit/microbundle

scriptURL of serviceWorker.register isn't considered part of bundle

Đang mở
#814 4 bình luận 2 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
JavaScript
Star
8.1k
Fork
358
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

👋🏼

I'm currently working with microbundle to package a service worker library. I have a file [`index.mjs`](https://github.com/TimDaub/web3-service-worker-cache/blob/demo/src/index.mjs) that takes care of initializing and handling the SW in the main thread. And I have a file [`worker.mjs`](https://github.com/TimDaub/web3-service-worker-cache/blob/demo/src/worker.mjs) that separates the service worker code.

After browser compatability, I register the worker like this:

```js
await navigator.serviceWorker.register('./worker.mjs');
```

I use `microbundle` in a standard way by configuring it in [package.json](https://github.com/TimDaub/web3-service-worker-cache/blob/demo/package.json).

I'm aware that no bundler would take the input of `register(scriptURI)` and make it somehow part of the output. Usually, a developer has to care for this separately e.g. in rollup by adding a secondary input and output. But today while doing that I found it annoying and I asked myself why?

Couldn't microbundle just take care of transpiling the worker.mjs file and include it somehow? E.g. it could be bundled as a base64 data URI...

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Hướng nghiên cứu

Review the package.json configuration and the index.mjs and worker.mjs entry files linked in the issue, then inspect how microbundle handles additional Rollup inputs. Determine the expected behavior for a serviceWorker.register('./worker.mjs') reference, including whether transpiling or embedding it is feasible. Done should be a decided, documented implementation scope with a reproducible example or test.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
javascript, rollup
Lĩnh vực
build-system
Loại issue
Tính năng
Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
25/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.