Skip to content

Instantly share code, notes, and snippets.

@dotproto
Created July 23, 2021 18:14
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dotproto/418ba29bbeafb5b2a0e1665f4cd3de2a to your computer and use it in GitHub Desktop.
Save dotproto/418ba29bbeafb5b2a0e1665f4cd3de2a to your computer and use it in GitHub Desktop.
Manifest V3 module service worker demo
// Copyright 2021 Google LLC
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd
// Use importScripts to load other JS files
import { demo } from './lib.js';
console.log(demo.greeting);
/*
* Uncomment this block and reload the extension to see how errors are handled.
* When enabled in Canary (as of 2021-07-23), the extension's error page will
* contain two entries:
*
* - A warning stating "Service worker registration failed"
* - An error stating "Uncaught Error: Testing error handling"
*/
// throw new Error('Testing error handling');
// Copyright 2021 Google LLC
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd
export const demo = {
greeting: 'Hello, world!'
}
{
"name": "Module service worker demo",
"version": "1.0",
"manifest_version": 3,
"background": {
"service_worker": "background.js",
"type": "module"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment