nx: React application not running in IE11
Expected Behavior
The App to load polyfills and run in IE11, possibly in both development and prod mode.
Current Behavior
Dev mode: IE11 raises syntax errors (related to ES6 arrow functions) and stops Prod mode: blank screen, scripts are loaded but nothing seems to be evaluated, judging from performance timeline.
Steps to Reproduce
Dev mode scenario
npx --ignore-existing create-nx-workspace nx-ie11-test --preset=reactnpm serve(or yarn, for what is worth)
Scripts are loaded and evaluated:

But the resulting outcome is a syntax error pointing to the first evaluated function presenting ES6 arrow notation:

I’ve tried to tackle the issue from a few different angles:
- “downgrading” the
targetparameter value to"es5"intsconfig.json; - adding a
"browserslist"section inpackage.jsonand make sure IE11 is explicitly listed; - addding
react-app-polyfilland cleaningnode-modules/.cachebefore rebuilding as suggested here;
Same result 🤕
Build mode scenario
npx --ignore-existing create-nx-workspace nx-ie11-test --preset=reactnpm build(or yarn, for what is worth)
Rendered page is empty and console is clean:

This time scripts are loaded but not evaluated, from what I can see.:

Any suggestions?
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 1
- Comments: 51 (14 by maintainers)
Commits related to this issue
- fix(react): change default browserslist so IE11 is support (via "not dead" query) Closes #2209 — committed to jaysoo/nx by jaysoo 4 years ago
- fix(react): change default browserslist so IE11 is support (via "not dead" query) (#2718) Closes #2209 — committed to nrwl/nx by jaysoo 4 years ago
@ramHruday Upgrading to nx 10 acually broke my projects on IE11. It would probably help to add documentation on what all IE11 configs were removed as per the announcement blog post, and how we can customize and enable them in our projects if we needed.
Sure, there are workarounds for this but my request is to have a consistent set of rules we can follow for IE11 support.
Edit: Mainly when we adjust browserslistrc, we should be able to see a working version of our project in IE11. That is not happening as of v10.
Hi, i get some problems with transpilling to
es5in ie11.Steps for reproduce:
npx create-nx-workspace@latest, create app from react preset;tsconfig.base.json:target: "es5";tsconfig.base.json
.browserslist.browserslist
react-app-polyfilland add them inpolyfills.tspolyfills.ts
app.tsx
npx nx serve ie11-app --configuration=production;Screenshots
.babelrc
class extendsnot transpiled to function. How to fix this?nx report
I got my application running in IE11 after much googling and trial and error. I came across something that sounded similar. I think the problem is not everyone publishes their modules in NPM as es5 modules.
By default babel-loader is configured to exclude everything in node_modules. This article shared the tool
are-you-es5with me.I was able to solve this in nx by replacing the webpackConfig path in workspace.json with a custom one that extends the default one by nx. It replaces the exclude rule for babel-loader with a regex provided by are-your-es5.
npm install are-you-es5create
webpack.config.jsat project rootI obviously don’t think this is a good long term solution, but I think it provides a good workaround. Also I hope it provides some clarity on how to properly resolve the issue for the more enlightened.
Taking a look at this for the next release.
@krizic Everything seems to have taken a step back for me as well 😦 While I can run “almost” every bit of my monorepo in dev/debug mode, production build is back to producing a white page with JS code pretty much ignored. Same code, moved into a standalone CRA project, builds just fine (Immer included). @vsavkin & team, here’s a reference repo, just in case you don’t want to spend too long recreating the issue: https://github.com/alfonsobravi/nx-ie11-test
Hi @kirjai
I have opened a PR purely for diff purposes against your repo: https://github.com/kirjai/nx-react-ie11/pull/1
The only changes I’ve made are those necessary to get this running on IE11 in a Parallels Windows 10 VM on my Mac.
On
yarn serveIE11 gives a white screen with a syntax error, caused by an arrow function which survived transpilation:Below are my nx report, yarn.lock, IE11 version. Note my own project is on the latest Nx versions as it was bootstrapped last week, and has the same issues.
yarn.lock.txt
I just had an attempt at narrowing down the issue, and as far as I can tell, IE 11 support works fine with the simplest use case. Here’s a repo, where I can successfully run
yarn nx serve --prod, open it in IE 11 (running in a VM, mind you), and see the UI working as expected. This is using latest version of Nx (11.5.2), and a fresh workspace. All it takes is addingIE 11to.browserslistfor the simplest use case.Can someone who’s still experiencing this issue on latest Nx help narrow down what breaks IE 11 support for you specifically? A repro repo would be helpful. Repros that have been posted in this thread earlier are a few major versions behind by now, unfortunately. Without it, i’m afraid there’s nothing actionable for us here at the moment
Has anyone made it working with latest dev. This really deal breaker when we are trying to move towards monorepo and nx dev. It would be great if someone can share the solution if they have made it working.
For me it is not working at all. Even after trying most of the above solutions. Prod version just go blank on me in IE. While things are good for Chrome and other latest browser.
I want to share that this issue haunted me for at least two weeks. @countravioli, gave me the biggest hint by sharing information about the package: are-you-es5
I was not able to use his code snippets in their entirety, but using this package I was able to zero in on the offender and exclude it from my code base. FYI, my inherited project is tiny - so I was lucky to only have to remove one offender. Thank you very much!
@vaunus that may be better in multiple ways.
core-jsshould polyfill stuff like URLSearchParams and URL class. Making that switch could be good.@sushruth I can confirm on my side that your fix from the PR above is causing
*.es5.jsartefacts to be generated correctly in the build. 👍🏻 Without your fix and on NX10.2.0I am not seeing these files there at all, only the*.esm.jsfiles are present.On an unrelated note, I was still seeing arrow functions in my
vendor.*.es5.jsfile until thequery-stringpackage was removed.the autoprefixer is not working either
BTW, we won’t support development mode in IE11 since we target only evergreen browsers for development.
@footyapps27 I’ll talk to @jaysoo, who is in charge of our react story.
I managed to get React, Redux, Sagas, Immer, Axios working just fine on IE11 after swapping the schematics generated content for
polyfills.tswith:These are wrappers for
core-js, nothing more (stable is actually just like the default polyfills) with just enough extra smartness attached to push it through the finish line! I am not sure how actively maintained they are in order to be considered a reliable, long term solution for the issue… I guess the other option is to extract the logic and bake it into the schematics. @vsavkin ?Thanks for the hint @vsh13, it definitely did the job for me with a simple, standalone app. In a real world scenario though, where you might have other libraries in your monorepo your app relies on, you’d still bump in the same transpiling issues (arrow func, spread operators, …).
Now, if I move the suggested
.babelrcin the root folder (or create one in each library) IE11 is happy again, but modern browsers (Chrome, Edge, FF) are all falling apart becauseReferenceError: regeneratorRuntime is not defined… Even if I extend thetargetsproperty in the babelrc to provide versions for the other browsers…i have encountered the same issue. Was able to get around it by putting a .babelrc inside my _frontend f_older wit this
I guess nx has a bug with Babel config. @alfonsobravi @vsavkin.