question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

PWA Plugin: Transpile Service Worker

See original GitHub issue

What problem does this feature solve?

There is an ever-growing list of things that need to be handled in service workers, which can’t be handled in normal web workers (like caching, push notifications, background sync, …) and it would be great to split the code into different files and use typescript, babel, and other loaders to improve the developer experience and type safety.

I can use worker-loader for web workers, but this loader doesn’t work for service workers.

What does the proposed API look like?

Add a transpile option to the pwa config section. When enabled, the service worker is transpiled instead of just copied (similar to worker-loader). The workbox script and the precache manifest and can be imported in sw.js via a dummy module (to support typescript).

// vue.config.js
module.exports = {
  pwa: {
    workboxPluginMode: "InjectManifest",
    transpile: true,
    workboxOptions: {
      swSrc: "src/sw.js",
    }
  }
};

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:10
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
LinusBorgcommented, Mar 21, 2020

We will upgrade to workbox’s new major in our next major upgrade, yes.

1reaction
LinusBorgcommented, Jan 14, 2019

There’s still an open issue about this in the workbox repo: https://github.com/GoogleChrome/workbox/issues/1513

Do we want to work around that in some way, and if so, is there an idea how to achieve that?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Building a Service Worker with Workbox 5, TypeScript ...
The “build:pwa:web” script: Removes the service-worker.js file in the dist/apps/web folder (just in case); Uses production Webpack configuration ...
Read more >
plugin-pwa | Docusaurus
This plugin generates a Service Worker in production build only, and allows you to create fully PWA-compliant documentation site with offline ...
Read more >
Ultimate Guide to PWAs with Workbox
This post is a complete guide to building a Progressive Web App (PWA) from the beginning using Google's Workbox. By the end of...
Read more >
Service worker - Adobe Developer
Service worker. A webpack plugin for configuring a ServiceWorker for different PWA development scenarios. This plugin is a wrapper around the Google Workbox ......
Read more >
Custom Service Worker Logic in Typescript on Vite
Do the Service Worker Transpilation & Bundling as a Vite Plugin. Transpiling and bundling Typescript code as a single Javascript file can easily ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found