Skip to content

Latest commit

 

History

History
 
 

worker-emscripten

Template: worker-emscripten

Deploy to Cloudflare Workers

A template for kick starting a Cloudflare worker project with emscripten

index.js is the content of the Workers script. main.c is the c source code that calls into the stb image resizer library. build.js holds the command we use to call emscripten. webpack.config.js holds the webpack config we use to bundle the emscripten output together with your script.

This template requires Docker for providing the emscripten build environment. While we believe this provides the best developer experience, if you wish to not use Docker you can delete the check for docker and the docker parts of the build command in build.js. Note this means you must have emscripten installed on your machine.

Setup

To create a my-project directory using this template, run:

$ npm init cloudflare my-project worker-emscripten
# or
$ yarn create cloudflare my-project worker-emscripten
# or
$ pnpm create cloudflare my-project worker-emscripten

Note: Each command invokes create-cloudflare for project creation.

Credits

Shoutout to Surma for his webpack-emscripten-wasm gist that was instrumental in getting this working!