Skip to content

Not working on cloudflare worker #69

@tttp

Description

@tttp

Hi,

Cloudflare worker provides a fetch function, however, when I'm webpacking your lib, it does seem to use XMLHttpRequest

ReferenceError: XMLHttpRequest is not defined

I did try to force webpack to use node

module.exports = {
  target: "webworker",
  entry: "./worker.js", // inferred from "main" in package.json
  resolve: {
    mainFields: ['module', 'main']
  }
};

But it generates another error (global not defined)

Is there a way to force cross-fetch to to use the native fetch function?

as a proof of concept/fugly workaround, I replaced

const Fetch = fetch; //require('cross-fetch');

and it seems to work fine.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions