cloudflare / worker-typescript-template

ʕ •́؈•̀) TypeScript template for Cloudflare Workers
Apache License 2.0
424 stars 93 forks source link

Dependency issue : service-worker-mock 'no longer maintained' #48

Open grempe opened 2 years ago

grempe commented 2 years ago

This template depends on service-worker-mock:

https://github.com/cloudflare/worker-typescript-template/blob/master/package.json#L32

The NPM package for this is found here:

https://www.npmjs.com/package/service-worker-mock

The Github repository link at NPM points here:

https://github.com/pinterest/service-workers

However, Github redirects requests to this repo to a new location:

https://github.com/zackargyle/service-workers

And this repo has had no changes since April 2020 and its README header now says:

*** THIS PROJECT IS NO LONGER MAINTAINED ***

This project should replace this abandoned dependency with one that is maintained.

grempe commented 2 years ago

Additionally, it seems that the version of @types/service-worker-mock being included is out of sync with the service-worker-mock package. The function signature for makeServiceWorkerEnv() doesn't seem to match (accepts no args).

https://github.com/DefinitelyTyped/DefinitelyTyped/blob/f7ec78508c6797e42f87a4390735bc2c650a1bfd/types/service-worker-mock/index.d.ts#L8

Doesn't match:

https://github.com/zackargyle/service-workers/blob/master/packages/service-worker-mock/index.js#L150

The out of date, and mismatched types, are another reason not to use this package, or to perhaps take over maintenance and upgrades.

nelsonjchen commented 2 years ago

https://blog.cloudflare.com/miniflare/ has been a good replacement for this mock. For my purposes, it is the only reasonable replacement as it can mock Requests that accept a ReadableStream which are pretty darn important in CloudFlare workers for proxying purposes.

nelsonjchen commented 2 years ago

https://github.com/nelsonjchen/gtr-proxy/tree/snapshot-miniflare-replacement

I have a WIP project using this at the moment and I haven't had time to extract it. Perhaps a PR can be pondered from this.

nelsonjchen commented 2 years ago

https://github.com/cloudflare/worker-typescript-template/pull/58

Oh someone beat me to it by 5 days.