Closed balupton closed 2 years ago
For basic examples, you can follow the instructions here https://blog.cloudflare.com/using-webpack-to-bundle-workers/
Cloudflare Workers are a superset of Service Workers, so you can use TypeScript's built-in definitions for webworkers by specifying it in your tsconfig.json:
"lib": ["es2015", "webworker"],
I've published complete types and mock: https://github.com/udacity/cloudflare-typescript-workers
would be nice to update that blog post to use babel-loader (the defacto standard for typescript + webpack now), instead of awesome-typescript-loader
This is in parceljs https://github.com/leoiii12/cloudflare-workers-forum/tree/master/api/
I know this is old, but this is now available in the /worker-typescript
subdirectory.
You can create a project with it by visiting https://workers.new/typescript or locally via:
$ npm init cloudflare my-project worker-typescript
# or
$ yarn create cloudflare my-project worker-typescript
# or
$ pnpm create cloudflare my-project worker-typescript
It would be nice for a typescript example of workers. As right now, I can't seem to find any type definitions for the most basic example:
https://github.com/zeit/ncc could probably be used for generating the compiled bundle, as it supports typescript