React, WebPack and Babel for Internet Explorer 10 and below produces SCRIPT1002: Syntax error

心不动则不痛 提交于 2019-12-01 19:23:21

In your package.json file

change the version of webpack-dev-server to version "2.7.1" (or earlier).

"webpack-dev-server": "2.7.1"

Then do a npm install et voilà.

That solved the problem for me.

All versions after 2.7.1 gives me an error similar to yours.

Simply add devtools : "source-map" to your Webpack config like this:

const path = require('path');
module.exports = {
  devtool: "source-map",
  entry: ['babel-polyfill', path.resolve(__dirname, './js/main.js')],
  mode: 'production',
  output: {
    path: __dirname+'/js/',
    filename: 'main-webpack.js'
  }
};

This will remove eval and change your source map to be supported by IE.

UPDATE I've changed devtool to inline-cheap-module-source-map and got error point to overlay.js -> const ansiHTML = require('ansi-html');

And to support ES6 syntax you have to compile your JavaScript code with Babel.

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