cloudworker-proxy icon indicating copy to clipboard operation
cloudworker-proxy copied to clipboard

ESM module support

Open tomlarkworthy opened this issue 9 months ago • 0 comments

One thing I have noticed is the main export is a commonJS module, hence the examples "require", but this is not idomatic cloudflare worker. Cloudflare workers can support commonJS via their internal workaround https://blog.cloudflare.com/workers-javascript-modules/ but it is not its primary module mechanism, that is ESM.

As I hate breaking backwards compatibility, we can support both by exporting two different packages https://www.sensedeep.com/blog/posts/2021/how-to-create-single-source-npm-module.html but I would suggest changing examples to ESM going forward. Of coure, both should be supported in integration tests so we never accidentally regress (see https://github.com/markusahlstrand/cloudworker-proxy/pull/130)

tomlarkworthy avatar Sep 10 '23 19:09 tomlarkworthy