Should be fixed with #1205 and #1206 but still does not work. I've updated parcel to the latest commits (git clone, npm install, npm run build inside the parcel-bundler folder)
Parcel should find calls to navigator.serviceWorker.register and resolve the given path correctly to a public http url accessible by the browser.
Parcel finds the register() call, but resolves the path wrong. The browser can not load the serviceworker file, therefore the registration fails.
The URL produced by parcel in the example repository is https://localhost:1234/srcserviceworkersw.js
The working URL is https://localhost:1234/src/serviceworker/sw.js (but not preferred)
src/index.js
navigator.serviceWorker.register('./serviceworker/sw.js')
compiled to
/build/src/serviceworker/sw.js
| Software | Version(s) |
| ---------------- | ---------- |
| Parcel | latest commits
| Node | v8.11.2
| npm/Yarn | 5.6.0/1.7.0
| Operating System | Win 10 64Bit
Parcel does not treat serviceworkers in any special way. See parcel-plugin-workbox and parcel-plugin-swprecache
@KeineLimonade actually it does, if I understood #398 right ... the produced URL to the service worker is just wrong (but should be fixed, see #1205 and #1206)
as far as I understand parcel-plugin-workbox and parcel-plugin-swprecache, they always generate a serviceworker-file. I want my own existing serviceworker-file to be detected correctly
this is the problem, in the compiled src.XXXX.js it is
navigator.serviceWorker.register('/src\sw.js');
but should be
navigator.serviceWorker.register('/src/sw.js');
Oh. Ok, thanks for the clarification
I experienced this problem as well, but my mistake was putting the call to navigator.serviceWorker.register() in a
Most helpful comment
this is the problem, in the compiled src.XXXX.js it is
navigator.serviceWorker.register('/src\sw.js');but should be
navigator.serviceWorker.register('/src/sw.js');