Company
Date Published
June 25, 2018
Author
John Fawcett
Word count
1116
Language
English
Hacker News points
None

Summary

This article provides an introduction to bundling Service Worker scripts using Webpack. It explains that while a simple Service Worker script can be written as a single file, larger scripts may require JavaScript's module system. However, Cloudflare only accepts a single JS file for Service Workers. The author demonstrates how to bundle your Service Worker with TypeScript and Webpack using an example weather-fetching worker. They also explain how to use off-the-shelf solutions on npm to handle routing logic in the worker script. Finally, they emphasize that Webpack is a powerful tool for bundling Cloudflare Service Workers.