React polyfills for ie >= 9

回眸只為那壹抹淺笑 提交于 2021-02-11 13:56:51

问题


I'm trying to set up React App for IE 9+ browsers. Here is my current src.

package.json

{
  "name": "react-ts-template",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@testing-library/jest-dom": "^4.2.4",
    "@testing-library/react": "^9.3.2",
    "@testing-library/user-event": "^7.1.2",
    "@types/jest": "^24.0.0",
    "@types/node": "^12.0.0",
    "@types/react": "^16.9.0",
    "@types/react-dom": "^16.9.0",
    "@types/crypto-js": "3.1.44",
    "react": "^16.13.1",
    "react-dom": "^16.13.1",
    "react-scripts": "3.4.1",
    "typescript": "~3.7.2",
    "crypto-js": "^4.0.0",
    "react-app-polyfill": "1.0.6",
    "core-js": "3.6.4",
    "regenerator-runtime": "0.13.5",
    "raf": "3.4.1"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all",
      "ie >= 9"
    ],
    "development": [
      "ie >= 9",
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}

index.ts

//polyfills
import 'core-js/stable';
import 'regenerator-runtime/runtime'
import 'react-app-polyfill/ie9';
import 'react-app-polyfill/stable';
import 'raf/polyfill';

import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import * as serviceWorker from './serviceWorker';
ReactDOM.render(
  <React.StrictMode>
    <App />
  </React.StrictMode>,
  document.getElementById('root')
);

But I get it work only in dev mode in IE 11. In IE 10-9 it works only in production build. In dev it shows error in console:

Map is not defined

What am I making wrong? Maybe i've missed something in configuration?

来源:https://stackoverflow.com/questions/61208416/react-polyfills-for-ie-9

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!