-
Notifications
You must be signed in to change notification settings - Fork 63
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
[FEATURE REQUEST] Import external dependencies in Service Worker #63
Comments
FWIW I was able to get this working by using the |
Is there any problem with @dadleyy approach? I used his exact code an am finally able to import external dependencies. Would be nice to get his changes into master. |
Looks valid and intriguing. Could you pull together a PR that can be tested in some various scenarios? |
As a workaround you can manually import your dependency file in app.import('node_modules/some-dependency/dist/umd/index.js', {
outputFile: 'workers/some-dependency.js'
}); and in your service worker file have importScripts('./workers/some-dependency.js'); Not the best experience, but gets the job done. |
It seems you cannot import anything that is not local to the
service-worker
folder, and that is not an ES6 module. The config forrollup
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 caseidb-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.The text was updated successfully, but these errors were encountered: