developit / developit/microbundle

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

未關閉
#814 4 則留言 2 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
JavaScript
星號
8.1k
分支
358
PR 合併指標
30 天內沒有已合併 PR

描述

👋🏼

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

貢獻指南

這個儲存庫沒有索引到貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。