在从UglifyJs的SyntaxError bundle.js的WebPack误差ERROR:意外

2019-09-27 13:24发布

我想我准备快递/ ReactJS应用生产用的WebPack和运行时NODE_ENV=production webpack -p --config webpack.production.config.js

我得到的错误:

ERROR从UglifyJs的SyntaxError bundle.js:意外的令牌:名称(丙)[./~/connect-mongo/src/index.js:10,0]

这是我的webpack.production.config文件:

var path = require('path');

var config = {
  entry: path.resolve(__dirname, './server.js'),
  output: {
    path: path.resolve(__dirname, 'dist'),
    filename: 'bundle.js'
  },
  module: {
    preLoaders: [
      { test: /\.json$/, loader: 'json'},
    ],
    loaders: [
      { test: /\.js$/, exclude: /node_modules/, loader: 'babel'},
      { test: /\.jsx$/, exclude: /node_modules/, loader: 'babel'},
      { test: /\.es6$/, exclude: /node_modules/, loader: 'babel'}
    ],
  },
  node: {
      fs: 'empty',
      net: 'empty',
      tls: 'empty',
      module: 'empty'
    }
};

module.exports = config;

编辑

误差在node_modules线10的结果/连接-蒙戈/ SRC /索引:

'use strict';
/* eslint indent: [error, 4] */

const Promise = require('bluebird');
const MongoClient = require('mongodb');

function defaultSerializeFunction(session) {
    // Copy each property of the session to a new object
    const obj = {};
    let prop;

    for (prop in session) {
        if (prop === 'cookie') {
            // Convert the cookie instance to an object, if possible
            // This gets rid of the duplicate object under session.cookie.data property
            obj.cookie = session.cookie.toJSON ? session.cookie.toJSON() : session.cookie;
        } else {
            obj[prop] = session[prop];
        }
    }

    return obj;
}
文章来源: Webpack error ERROR in bundle.js from UglifyJs SyntaxError: Unexpected token: name (prop) [./~/connect-mongo/src/index.js:10,0]