Модуль NPM приводит к тому, что веб-приложение не отображается на IE11 - PullRequest
0 голосов
/ 19 сентября 2018

Поэтому я использую компонент реагирования, который мой коллега опубликовал на npm.Он отлично работает во всех браузерах, кроме 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?

1 Ответ

0 голосов
/ 19 сентября 2018

Возможно, вам нужно сослаться на 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 install core-js

См. Также Лучший способ заполнить функции ES6 в приложении React, использующем create-реагировать-приложение

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...