Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IE11 support doesn't work in dev mode, even after adding all polyfills and enabling ie11 support #8197

Open
ttaranov opened this issue Dec 17, 2019 · 26 comments

Comments

@ttaranov
Copy link

ttaranov commented Dec 17, 2019

Describe the bug

IE11 support doesn't work even after adding react-app-polyfill, enabling "ie 11" in browserslist in package.js and adding import 'react-app-polyfill/ie11' and import 'react-app-polyfill/stable' into src/index.js

Did you try recovering your dependencies?

yes

Which terms did you search for in User Guide?

followed instructions on
https://create-react-app.dev/docs/supported-browsers-features/
and
https://github.com/facebook/create-react-app/blob/master/packages/react-app-polyfill/README.md

Environment

MacOS
node 11.15.0
npm 6.7.0
latest create-react-app
Virtual Box with Microsoft's test Window10 and IE11 image VM

Steps to reproduce

  1. npx create-react-app test
  2. cd test
  3. npm i react-app-polyfill
  4. edit package.json and add "ie 11" into "browserslist->development" section:
"browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "ie 11",
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
  1. edit src/index.js and add 2 lines at the top:
import 'react-app-polyfill/ie11';
import 'react-app-polyfill/stable';
  1. rm -rf node_modules/.cache
  2. npm run start
  3. launch IE11 VM and open http://<ip>:3000 in IE11

Expected behavior

test create react page is supposed to show up

Actual behavior

SCRIPT5022: SyntaxError
0.chunk.js (19856,1)

@J-theGit
Copy link

J-theGit commented Dec 17, 2019

@ttaranov Can you please be more specific about the error in IE? when the SyntaxError is thrown you should be able to see exactly what has failed. For Example 'xxx is undefined' or 'cannot read xxx of undefined' etc. This will help everyone to understand exactly what you're missing from the polyfills.

I had the same issue in dev and prod with TextEncoder.
I've resolved this issue by manually installing the TextEncoder polyfill (without ejecting):

npm i fast-text-encoding
// polyfills for IE
import 'react-app-polyfill/ie11';
import 'react-app-polyfill/stable';
import 'fast-text-encoding/text';

However we wouldn't know what exactly is missing in your case. You will need to be more specific about the error

@heyimalex
Copy link
Contributor

heyimalex commented Dec 17, 2019

I'm able to reproduce. It looks like the syntax errors are from arrow functions, which ie11 doesn't support. Babel's preset-env and that browserslist configuration should handle transforming arrow functions to regular functions, but that apparently isn't working right.

IE11 has sourcemap support, so this is from actually checking the network tab for the location of the syntax error.

@ghost
Copy link

ghost commented Dec 18, 2019

IE11浏览器控制台报错:
image
项目中依赖包全部都引入了:
import "react-app-polyfill/ie11";
import "react-app-polyfill/stable";
import 'fast-text-encoding/text';

@eyerean
Copy link

eyerean commented Dec 18, 2019

I confirm the bug, just a small note that version react-scripts@3.2.0 still works, so for a quick fix you can revert back (and delete node_modules/.cache and the browsers' cache).

@willhoney7

This comment has been minimized.

@stale
Copy link

stale bot commented Feb 6, 2020

This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs.

@fgeorgsson
Copy link

Just ran into this issue as well. Even 3.2.0 does not work for me. Have added polyfill, have added ie11 to browserlist in package.json. Syntax error is thrown at first fat arrow function.

@alfechner
Copy link

Same problem here, related to #8546?

@lisdey
Copy link

lisdey commented Mar 16, 2020

Same problem, any updates about this? Thanks

@iansu iansu modified the milestones: 3.4.1, 3.4.2 Mar 20, 2020
@Ciaran0
Copy link

Ciaran0 commented Mar 24, 2020

Same here with react-scripts@3.4.1

The production build works but the dev build is not.

@jbberinger
Copy link

Running into the same issue. Prod is fine but dev is completely broken.

@HiramYong
Copy link

seam issue, 3.2.0 doesnt work for me, Could someone help me?

@SteenMolberg
Copy link

Same here. Tried 3.2.0 as suggested but no luck.

@TENsaga
Copy link

TENsaga commented Mar 30, 2020

Same issue, react-scripts-3.3.1, dev build doesn't load production build does.

@SteenMolberg
Copy link

SteenMolberg commented Mar 31, 2020

After trying a lot of things I go back to 3.4,1 again and cleared my node_modules and reinstalled. Finally got it working in dev with workaround from @J-theGit

npm i fast-text-encoding
// polyfills for IE
import 'react-app-polyfill/ie11';
import 'react-app-polyfill/stable';
import 'fast-text-encoding/text';

"react-app-polyfill" version installed is 1.0.5 and the fast-text-encoding is 1.0.1

@jbberinger
Copy link

After trying a lot of things I go back to 3.4,1 again and cleared my node_modules and reinstalled. Finally got it working in dev with workaround from @J-theGit

"react-app-polyfill" version installed is 1.0.5 and the fast-text-encoding is 1.0.1

Can you outline the workaround?

@haagOS
Copy link

haagOS commented Apr 2, 2020

I have a working solution (development) with react-scripts v. 3.4.1.

this my package.json:

...
"dependencies": {
    "@types/node": "^12.12.34",
    "@types/react": "^16.9.31",
    "@types/react-dom": "^16.9.6",
    "react": "^16.13.1",
    "react-app-polyfill": "^1.0.6",
    "react-dom": "^16.13.1",
    "react-scripts": "3.4.1",
    "typescript": "^3.7.5"
  },
...,
"browserslist": [
    ">0.2%",
    "not dead",
    "ie 11",
    "not op_mini all"
  ]

this is my index.tsx (note that the polyfills are at the very beginning):

import "react-app-polyfill/ie11";
import "react-app-polyfill/stable";

import React from "react";
import ReactDOM from "react-dom";
...

@ArturBaybulatov
Copy link

ArturBaybulatov commented Apr 26, 2020

Clearing the cache and then starting the app worked for me:

rm -rf node_modules/.cache/
npm start

@ianschmitz ianschmitz modified the milestones: 3.5, 4.0 May 3, 2020
@ChiaJune
Copy link

Clearing the cache and then starting the app worked for me:

rm -rf node_modules/.cache/
npm start

still

@simonprice33
Copy link

I am having a similar issue but with bundle.js and arrow functions in IE11. I have asked the question here https://stackoverflow.com/questions/62130921/react-app-bable-polyfill-not-working-correctly-ie11 too to see if anyone has a resolution to this.

@simonprice33
Copy link

When I had this issue; there was an external library that needed to be transpiled.

I worked it out by transpiling that specific package that was throwing the issue (when I clicked the SCRIPT error)

Though this was for gatsby (so transpile plugin may differ):

But I needed the following in plugins:

{
  "resolve": "gatsby-plugin-compile-es6-packages",
  "options": {
	"modules": ["@company-custom-package"],
  },
},

Hope maybe someone can get a little bit closer to resolving their issues.

I have IE11 issues even after creating a new project so I dont think its down to an external library in my case

@paulrrdiaz
Copy link

After adding react-app-polyfill in your index.js, it will work for PROD env but you need to update your browserslist inside package.json for DEV env

index.js

import 'react-app-polyfill/ie9';
import 'react-app-polyfill/stable';

import React from 'react';
import ReactDOM from 'react-dom';
.
.

package.json

.
.
"browserslist": {
  "production": [
    ">0.2%",
    "not dead",
    "not op_mini all"
  ],
  "development": [
    "last 1 chrome version",
    "last 1 firefox version",
    "last 1 safari version",
    "not dead" // new line
  ]
},
.
.

@iansu iansu removed this from the 4.0 milestone Jul 22, 2020
toolness added a commit to JustFixNYC/who-owns-what that referenced this issue Jul 24, 2020
Looking at Rollbar errors for the latest front-end version made me realize that there were arrow functions in our JS bundles.  Upon further inspection, I realized our `browserslist` specifies `not ie <= 11`, yet our `index.js` imports both `react-app-polyfill/ie11` and `babel-polyfill`.  These contradictory lines were actually all introduced in the same PR, #99, which is very odd.

I think the reason we might not have seen this strange behavior when writing that PR is because apparently [changing `browserslist` requires deleting `node_modules/.cache`][1].  So it's possible that during development, we never truly saw the results of our actions!  (Needless to say, I spent a lot of time in confusion after making this PR's simple code change, until I discovered the root cause.)

This means that even Netlify won't reflect changes to `browserslist` by default (it caches all of `node_modules` between builds), so I've modified its configuration to clear `node_modules/.cache` before building the site too.

[1]: facebook/create-react-app#8197 (comment)
@nightspirit
Copy link

From https://stackoverflow.com/questions/62130921/react-app-bable-polyfill-not-working-correctly-ie11 I got the solution to fix my problem.

react-scripts: 3.4.3
react-app-polyfill: 1.0.6

Attach

import 'react-app-polyfill/ie11';
import 'react-app-polyfill/stable';

to the first line of src/index.js file

package.json

"browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all",
      "not ie < 11",
      "ie 11"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version",
      "ie 11"
    ]
  },

Once I added ie 11 to browserslist everything just work again.

@Emiya0306
Copy link

Emiya0306 commented Oct 22, 2020

My problem resolved.

  • Add "ie 11" to browserslist.development.
  • And clear the cache rm -rf node_modules/.cache/.

It works! 👍

@Lija-Jose
Copy link

Deprecated in package.json file, ran npm install, for React-scripts to "3.4.3" from "4.0.1" on which version the above issue was occurring. Along with polyfill/ie11 and polyfill/stable, .cache folder deletion and browserlists.development changes. Site showed up on IE.

@InSuperposition
Copy link

IE 10/11 was failing on my project because FAST_REFRESH=true in .env, setting this to false fixed the issue. Setting DISABLE_NEW_JSX_TRANSFORM did not seem to have an affect, polyfills worked in both cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests