Skip to content
This repository has been archived by the owner on Sep 9, 2021. It is now read-only.

Commit

Permalink
feat: add support for ServiceWorker (options.mode)
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-ciniawsky committed Oct 14, 2017
1 parent 261f7f2 commit f826ddf
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/get.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@ const getWorker = (file, content, options) => {
if (options.mode === 'shared') {
return `new SharedWorker(${publicWorkerPath}, options)`;
}

if (options.mode === 'service') {
return `('serviceWorker' in navigator)
? navigator.serviceWorker.register(${publicWorkerPath}, options)
: Promise.reject(
new Error('navigator.serviceWorker is not supported in this browser')
)
`;
}
}

if (options.inline) {
Expand Down

0 comments on commit f826ddf

Please sign in to comment.