[FEATURE REQUEST] Import external dependencies in Service Worker
See original GitHub issueIt seems you cannot import anything that is not local to the service-worker
folder, and that is not an ES6 module. The config for rollup
does not include any plugins to allow importing of CJS or AMD modules, and there is no way to change that config from the outside.
Use case: would want to use libs like localForage
or in this case idb-keyval
inside a service worker to queue requests while offline, as using IDB directly is a bit cumbersome and localStorage is not available. But for sure there will be other use cases as well.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:3
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Import a dependency to a service worker - Stack Overflow
1 Answer 1 · Use ES module imports as a build-time signal to a bundler, like Rollup/webpack/esbuild, to include code in a final...
Read more >workbox-window - Chrome Developers
A module that helps with registering a service worker, managing updates, and responding to lifecycle events.
Read more >Using Web Workers - Web APIs - MDN Web Docs
This makes it easier for workers to keep track of where their dependencies are. Importing scripts and libraries. Worker threads have access to...
Read more >Service worker configuration - Angular
When the ServiceWorker handles a request, it checks asset groups in the order in which they appear in ngsw-config.json . The first asset...
Read more >Angular 5 Service Worker - Medium
The Angular Service Worker functionality is provided by the module ... @angular/service-worker is installed as part of the dependencies.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
FWIW I was able to get this working by using the
rollup-plugin-node-resolve
package like this.Looks valid and intriguing. Could you pull together a PR that can be tested in some various scenarios?