Starter create-react-app with IE11 polyfill import still aborts in IE11

删除回忆录丶 提交于 2019-12-17 10:04:31

问题


Using: react 16.8.6. Working in: Dev Mode.

1) Do: npm create-react-app my-app

2) cd my-app

3) add: import "react-app-polyfill/ie11"; as the new first line in index.js

4) do: npm start

5) In IE11 on Windows 10 it aborts with these in the console:

SCRIPT1002: Syntax error 1.chunk.js (10735,34)

SCRIPT1002: Syntax error main.chunk.js (154,1)

I have tried other polyfills:

import "react-app-polyfill/ie9";

and

import 'react-app-polyfill/stable';

and

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

and

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

The location of the Syntax error changes, but it still happens.

Works fine in all other browsers.

import "react-app-polyfill/ie11";
import React from "react";
import ReactDOM from "react-dom";
import "./index.css";
import App from "./App";
import * as serviceWorker from "./serviceWorker";
import "bootstrap/dist/css/bootstrap.css";

ReactDOM.render(<App />, document.getElementById("root"));

The abort happens immediately before the generated code ever loads. It gives the old 'White screen of death' in IE11.

Can anyone share the magic to get the 16.8.6 starter app to work in IE11?


回答1:


You can refer to the following steps to support IE11:

First, install the package: npm install react-app-polyfill.

Second, add import 'react-app-polyfill/ie11'; import 'react-app-polyfill/stable'; at the first line in src/index.js.

Third, add ie 11 in packge.json like this:

Finally, you can restart your app and it will work in IE11. If it still doesn't work, delete the app and create it again according to the above steps.



来源:https://stackoverflow.com/questions/56435589/starter-create-react-app-with-ie11-polyfill-import-still-aborts-in-ie11

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