fetch-mock: Not working in IE11

When I’m importing fetch-mock (7.3.0) in IE11 I get an error Expected identifier which traces to the line function findStatus(val, { useSTD3ASCIIRules }) which seems to come from ‘tr46’ dependency.

Since this module is imported as a string in the ‘es5/client-bundle.js’, webpack can’t transpile it correctly (and argument destructuring actually is also not an es5 feature at all).

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 9
  • Comments: 18 (5 by maintainers)

Commits related to this issue

Most upvoted comments

The es5 directory name and the website say that the code inside is ES5-compatible. But it’s not (it has at least arrow expressions =>). This is the problem, and it’s not solved.

It seems like github have abandoned the fetch polyfill. I’ve raised an issue which may get looked at https://github.com/github/fetch/issues/777.

Yeah, they never accepted the fetch PR. Would be great if you guys could go ask it gets accepted. Meanwhile I’ve been doing npm installs for fetch directly off the fork.

"whatwg-fetch": "git+https://github.com/sullivanpt/fetch.git#fetchmock-release"

FYI I am running into the same original issue. Downgrading to fetch-mock 6.5.2 seems to fix the issue for me.

The latest version of github/fetch is now in NPM. For me now it works in IE11 using the latest github/fetch, latest fetch-mock and proxy-polyfill. But I still have to transpile fetch-mock in order to make it work.

fetch accepted the PR. Thank you.

My findings with getting fetch-mock work in IE11 - it takes hours of debugging and the results are very disappointing.

tl;dr fetch-mock needs proxy and you can use https://github.com/GoogleChrome/proxy-polyfill but keep in mind it supports only a limited amount of traps -> https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/has plus in combination with immer the universe will explode because immer will eventually call the GoogleChrome/proxy-polyfill which will result into an error https://github.com/immerjs/immer/issues/514#issue-553081558

Proxy polyfill does not support trap ‘has’

referenced here https://github.com/GoogleChrome/proxy-polyfill/issues/49

As of fetch-mock v9.3.1, the issue still persist.

I first came across the problem by updating from v7.4.0 to v9.3.1. I traced back versions and it appears v8.0.0 breaks it.

The error I get on IE11 points to the line 5 of src/lib/request-utils.js the arrow function headersToArrays;

It appears the arrow function is not being transpiled properly to IE 11 supported syntax.

I have been looking into this. On a project we’re running our unit test suite in IE11 (and other browsers) and have not been able to upgrade to fetch-mock@7 for this and a variety of other reasons.

Today I was able to get it to work with these measures:

I would like to submit the patch as a pull request, if there is a chance that it would get merged?