/plushcap/analysis/cloudflare/using-webpack-to-bundle-workers

Using Webpack to bundle your Workers modules

What's this blog post about?

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.

Company
Cloudflare

Date published
June 25, 2018

Author(s)
John Fawcett

Word count
1116

Hacker News points
None found.

Language
English


By Matt Makai. 2021-2024.