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
- Compatibility for fetch-mock using proxy-pollyfill Fixes wheresrhys/fetch-mock#415 Details: fetch-mock wraps the Response object in an ES6 Proxy to provide useful test harness features such as flush.... — committed to sullivanpt/fetch by sullivanpt 5 years ago
- Compatibility for fetch-mock using proxy-pollyfill (#736) * Compatibility for fetch-mock using proxy-pollyfill Fixes wheresrhys/fetch-mock#415 Details: fetch-mock wraps the Response object in an ... — committed to JakeChampion/fetch by sullivanpt 4 years ago
- Compatibility for fetch-mock using proxy-pollyfill (#736) * Compatibility for fetch-mock using proxy-pollyfill Fixes wheresrhys/fetch-mock#415 Details: fetch-mock wraps the Response object in an ... — committed to cr313/fetch-Js-flow by cr313 4 years ago
The
es5directory 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, latestfetch-mockandproxy-polyfill. But I still have to transpilefetch-mockin order to make it work.fetch accepted the PR. Thank you.
My findings with getting
fetch-mockwork in IE11 - it takes hours of debugging and the results are very disappointing.tl;dr
fetch-mockneeds 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 theGoogleChrome/proxy-polyfillwhich will result into an error https://github.com/immerjs/immer/issues/514#issue-553081558referenced 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:
require('proxy-polyfill')require('unorm')I would like to submit the patch as a pull request, if there is a chance that it would get merged?