Target node environment when building with wrangler
I'm trying to use
@mapbox/mapbox-sdk
in my worker, however they have a browser entry point defined in their package.json which relies on window.XMLHttpRequest
object being present, which causes the following error
Is it possible to either polyfill window.XMLHttpRequest
, or target a node environment when bundling via wrangler?1 Reply
Not sure the mapbox prodive any server-side sdk. So this version is not compatible with cloudeflare workers. Nodejs and Cloudeflare Workers architecture is quit different that's why many npm dependency doesn't work on cloudeflare workers. So my suggestion to use alternative of mapbox or you can reach out to mapbox support if they maintain any discord channel or through github.