来自UglifyJs的bundle.js中的Webpack错误ERROR SyntaxError:意外的令牌:name(prop)[./~/connect-mongo/src/index.js:10,0]

时间:2016-11-03 20:43:31

标签: javascript node.js reactjs webpack babeljs

我尝试使用webpack准备我的Express / ReactJS应用程序,并在运行时NODE_ENV=production webpack -p --config webpack.production.config.js

我收到错误:

  

来自UglifyJs的bundle.js中的错误   SyntaxError:意外的标记:name(prop)[./~/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 / connect-mongo / src / index中第10行的结果:

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

0 个答案:

没有答案