HTMLRewriter is pretty cool and avoids to embedded such logic in our workers: Thanks to Clouflare worker team for this!
But using this new API broke our local test suite: We were relying on dollarshaveclub to locally test our workers but the support of HTMLRewriter is not planned - and will not be (see https://github.com/dollarshaveclub/cloudworker/issues/138).
Any way Cloudflare could provide it? Any recommandation to mock or emulate it? Anyone working on it in the community?
Seeing its exposition in the worker environment; I suppose it is based on native bindings which implementation cannot be shared with the community but still, I’m asking the question :).
Thanks in advance for any advice!
Cloudflare recently implemented a development mode into Wrangler which might solve your use case. Be aware though that this feature is still pretty new and is not recommend for use in integration testing just yet
HTMLRewriter use https://github.com/cloudflare/lol-html under the hood. Read more here: https://blog.cloudflare.com/html-parsing-1/ , https://blog.cloudflare.com/html-parsing-2/ .
JS bindings are work in progress: https://github.com/cloudflare/lol-html/issues/38 .
Possibility to add support for HTMLRewrite in wrangler local dev functionality is discussed here: https://github.com/cloudflare/wrangler/issues/1026 .
To wrap up - things do tend to look promising, but nothing seem to be guaranteed yet.
Hope that helps.