1

So I am using a react component that my colleague published on npm. It works fine on all browsers except IE11. I suspect that there is something in the webpack config that we are neglecting which is causing the entire app to not render. There are no error messages, just a blank webpage.

The src/index.js file looks like this:

Class MuiTable extends Component {
...
}
export default compose(withStyles(styles, { withTheme: true }(MuiTable);

Here is the webpack.config.js file:

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'
  }
};

Here is the .bablerc:

{
  "presets": ["env"],
  "plugins": [
    "transform-object-rest-spread",
    "transform-react-jsx"
  ]
}

And here is the 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"
  }
}

Why might this not be working on IE11?

Chris Voss
  • 708
  • 1
  • 9
  • 22
  • We discovered what the issue was. Including the @material-ui... dependencies was causing a name space violation with the project dependencies. – Chris Voss Sep 21 '18 at 21:41

1 Answers1

2

Probably you need to reference a polyfills.js to make it works with IE.

You can reference a polyfills.js with theses imports:

/* polyfills.js */

import 'core-js/fn/array/find';
import 'core-js/fn/array/includes';
import 'core-js/fn/number/is-nan';

make sure you do npm install core-js

See also Best way to polyfill ES6 features in React app that uses create-react-app

JFPicard
  • 5,029
  • 3
  • 19
  • 43