Hi
I’m trying to create Cloudflare Workers code which is using npm module “canvas”.
And I try to use wrangler tool.
But once I try
$ wrangler dev
webpack under wrangler creates compiled code with browser-side setting by default, so browser side implementation of canvas is compiled.
So the running result says
GET gsi-rainbow-tile.rekishikokudo.workers.dev/cdn-cgi/styles/cf.errors.css HTTP/1.1 200 OK
ReferenceError: document is not defined
at worker.js:32:33
at new Promise ()
at Object.exports.loadImage (worker.js:31:10)
at Object.handleRequest (worker.js:182:34)
at worker.js:307:33 at line 31, col 31
This “document” is included in canvas npm module for browser side.
Is this a bug? Or, are there any workaround?