Javascript NPM模块导致web应用程序无法在IE11上呈现

Javascript NPM模块导致web应用程序无法在IE11上呈现,javascript,reactjs,webpack,internet-explorer-11,babeljs,Javascript,Reactjs,Webpack,Internet Explorer 11,Babeljs,所以我使用的是我同事在npm上发布的react组件。它在除IE11之外的所有浏览器上都可以正常工作。我怀疑网页包配置中有我们忽略的东西导致整个应用程序无法呈现。没有错误消息,只有一个空白网页 src/index.js文件如下所示: Class MuiTable extends Component { ... } export default compose(withStyles(styles, { withTheme: true }(MuiTable); 以下是webpack.config.j

所以我使用的是我同事在npm上发布的react组件。它在除IE11之外的所有浏览器上都可以正常工作。我怀疑网页包配置中有我们忽略的东西导致整个应用程序无法呈现。没有错误消息,只有一个空白网页

src/index.js文件如下所示:

Class MuiTable extends Component {
...
}
export default compose(withStyles(styles, { withTheme: true }(MuiTable);
以下是webpack.config.js文件:

var path = require('path');
module.exports = {
  entry: './src/index.js',
  output: {
    path: path.resolve(__dirname, 'build'),
    filename: 'index.js',
    libraryTarget: 'commonjs2'
  },
  module: {
    rules: [
      {
        test: /\.js$/,
        include: path.resolve(__dirname, 'src'),
        exclude: /(node_modules|bower_components|build)/,
        use: {
          loader: 'babel-loader',
          options: {
            presets: ['env']
          }
        }
      }
    ]
  },
  externals: {
    'react': 'commonjs react'
  }
};
以下是.bablerc:

{
  "presets": ["env"],
  "plugins": [
    "transform-object-rest-spread",
    "transform-react-jsx"
  ]
}
下面是package.json:

{
  "name": "ez-mui-table",
  "version": "1.1.4",
  "description": "Component for simple and fast integration of Material UI tables.",
  "main": "build/index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "webpack --watch",
    "build": "webpack"
  },
  "author": "Daniel Kinsbursky",
  "license": "MIT",
  "peerDependencies": {
    "react": "^16.4.2",
    "react-dom": "^16.4.2"
  },
  "devDependencies": {
    "eslint-config-prettier": "^2.9.0",
    "babel-cli": "^6.26.0",
    "babel-core": "^6.26.3",
    "babel-loader": "^7.1.4",
    "babel-plugin-transform-object-rest-spread": "^6.26.0",
    "babel-plugin-transform-react-jsx": "^6.24.1",
    "babel-preset-env": "^1.7.0",
    "babel-runtime": "^6.26.0",
    "prettier": "1.14.2"
  },
  "dependencies": {
    "@material-ui/core": "^3.0.2",
    "@material-ui/icons": "^3.0.1",
    "lodash.get": "^4.4.2",
    "lodash.sortby": "^4.7.0",
    "prop-types": "^15.6.2",
    "react-scripts": "1.1.5",
    "recompose": "^0.30.0"
  }
}

为什么这不适用于IE11?

您可能需要引用polyfills.js以使其适用于IE

您可以使用这些导入引用polyfills.js:

/* polyfills.js */

import 'core-js/fn/array/find';
import 'core-js/fn/array/includes';
import 'core-js/fn/number/is-nan';
确保您执行了
npm安装core js


另请参见

我们发现了问题所在。包括@materialui。。。依赖项导致项目依赖项的名称空间冲突。