babel-polyfill和webpack 1v错误。我该怎么办?反应

时间:2018-09-07 12:22:07

标签: webpack react-redux babel babel-loader babel-polyfill

我尝试在父母中添加应用程序(bundle.js)。 babel版本有所不同。而且我在每个应用程序中使用幂等-babel-polyfill。 我的package.json:

1)parentApp:

"dependencies": {
    "@material-ui/core": "^1.2.0",
    "@material-ui/icons": "^1.1.0",
    "axios": "^0.18.0",
    "classnames": "2.2.5",
    "co": "^4.6.0",
    "history": "^4.7.2",
    "idempotent-babel-polyfill": "^6.26.0-1",
    "jwt-decode": "^2.2.0",
    "react-dom": "^16.3.2",
    "react-redux": "^5.0.7",
    "react-router-dom": "^4.2.2",
    "react-router-redux": "^5.0.0-alpha.9",
    "redux": "^4.0.0",
    "redux-saga": "^0.16.0",
    "tachyons": "^4.9.1"
 }

2)childApp:

"dependencies": {
    "@babel/runtime": "7.0.0-beta.55",
    "@material-ui/core": "^1.4.1",
    "@material-ui/icons": "^1.0.0",
    "babel-runtime": "^6.26.0",
    "css-loader": "^0.25.0",
    "file-loader": "^0.9.0",
    "font-awesome": "^4.7.0",
    "font-awesome-webpack": "0.0.4",
    "history": "3.0.0",
    "idempotent-babel-polyfill": "^6.26.0-1",
    "isomorphic-fetch": "^2.2.1",
    "material-ui": "^1.0.0-beta.47",
    "material-ui-icons": "^1.0.0-beta.36",
    "ramda": "^0.25.0",
    "react": "^16.4.1",
    "react-bootstrap-sweetalert": "^4.4.1",
    "react-datetime": "^2.14.0",
    "react-day-picker": "^3.1.1",
    "react-dom": "^16.4.1",
    "react-nouislider": "^2.0.1",
    "react-redux": "^4.4.5",
    "react-router": "^3.0.0",
    "react-router-dom": "^4.1.1",
    "react-router-redux": "^4.0.8",
    "react-scrollbar": "^0.5.1",
    "react-select": "^1.3.0",
    "react-show-more": "^2.0.0",
    "react-show-more-text": "^1.0.3",
    "react-styled-select": "^1.0.0",
    "react-swipeable-views": "^0.12.15",
    "react-table": "6.8.0",
    "react-tagsinput": "^3.19.0",
    "react-textarea-autosize": "^7.0.4",
    "redux": "^3.6.0",
    "redux-thunk": "^2.1.0",
    "style-loader": "^0.13.1",
    "throttle-debounce": "^1.0.1",
    "url-loader": "^0.5.7",
    "webpack-hot-middleware": "^2.22.3"
  }

如您所见,我也不使用babel-polyfill。

我的webpack.js:

1)parentApp:

require("idempotent-babel-polyfill");
const path = require("path");

const BUILD_DIR = path.join(__dirname, "public");
const APP_DIR = path.join(__dirname, "src");

const common = {
  entry: ["idempotent-babel-polyfill", path.join(APP_DIR, "/index.js")],
  output: {
    path: BUILD_DIR,
    filename: "bundle.js"
  },
  module: {
    rules: [
      {
        test: /\.jsx?$/,
        include: APP_DIR,
        loader: "babel-loader"
      },
      {
        test: /\.css$/,
        use: ["style-loader", "css-loader"]
      },
      {
        test: /\.json$/,
        use: "json-loader"
      }
    ]
  }, ...

2)childApp:

    require("idempotent-babel-polyfill");
var path = require('path');
var webpack = require('webpack');

module.exports = {
    entry: [
        "idempotent-babel-polyfill",
        './src/index'
    ],
    output: {
        filename: 'app.bundle_cc.js',
        path: path.resolve(__dirname + '/js/'),
        publicPath: 'js/'
    },
    devtool: 'cheap-module-source-map',
    module: {
        loaders: [
            {
                test: /\.(js|jsx)$/,
                loaders: ['babel'],
                exclude: /node_modules/
            },
            {
                test: /\.less$/,
                loader: "style!css!less"

            },
            {
                test: /\.css$/,
                loader: "style!css"
            },
            {
                test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/,
                loader: "url-loader?limit=10000&mimetype=application/font-woff"
            },
            {
                test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
                loader: "file-loader"
            },
            {
                test: /\.(png|jpg|svg)$/,
                loader: 'url?limit=25000'
            }
        ]
    },

在应用程序集成过程中出现了一个问题:未捕获的错误:仅允许一个babel-polyfill实例无法读取未定义的属性“默认”     在runScript 在HTMLScriptElement.onLoad

我该怎么办?请帮我:)

0 个答案:

没有答案