0

I wrote a separate API library that I'm keeping as pure ES6 (with generators, etc) but it relies on the isomorphic-fetch library (so it can be used in both node and browser contexts).

When importing it with webpack 2 in another project, everything goes fine until I try to go through the minification/optimization process. UglifyJS won't process it due to the generator syntax which isn't supported. So I tried running that library through babel as a webpack loader, but now when attempting to run the code in the browser, I get the following error:

Uncaught (in promise) TypeError: Failed to construct 'Request': Please use the 'new' operator, this DOM object constructor cannot be called as a function.

It seems like I'm caught in a catch-22 here, and I'm not sure why Babel is preserving certain native classes but not the Request class.

Any help is much appreciated, been banging my head on my desk over this one.

1 Answers1

1

I figured out the issue, it turns out I needed the babel-plugin-transform-builtin-extend plugin because in the API library, I was extending the base Request object.