我正在尝试使用Webpack将我的节点类型记录应用程序(使用exprees服务器)迁移到ES2015。首先,我想使用属性类型。我创建的,比我需要的巴贝尔-装载机和埃林特。因此,我安装了这个软件包,并将其实现到我的快递应用程序中。
这是我的webpack.config.js
const webpack = require('webpack');
const WebpackErrorNotificationPlugin = require("webpack-error-notification");
module.exports =
{
entry: './src/test/test.js',
target: 'node',
debug: true,
output: {
path: './bin',
filename: 'test.bundle.js',
},
module: {
preLoaders: [{
test: /\.js?$/,
loaders: ['eslint'],
exclude: /node_modules/
}],
loaders: [{
test: /\.js?$/,
exclude: /node_modules/,
loader: 'babel',
}]
},
eslint: {
failOnWarning: false,
failOnError: true
},
plugins: [
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false,
},
output: {
comments: false,
},
}),
new WebpackErrorNotificationPlugin()
]
}.eslintrc
{
"parser": "babel-eslint",
"parserOptions": {
"sourceType": "module",
"allowImportExportEverywhere": false
}
}和错误码之一:
export class CmsUserModel {
/**
* (description)
*
* @type {String}
*/
template: string;
/**
* (description)
*
* @type {string}
*/
pages: string[];
constructor() {
this.template = "";
this.pages = new Array<string>();
}
public static ToModel(model: ICmsUserModel) {
return <CmsUserModel>{
template : model.template,
pages : model.pages
};
}
}有两个问题。第一种是,babal-eslint错误处理不太指定.例如:
ERROR in ./src/models/cmsUserModel.js
/Users/petrtomasek/Projects/cms/src/models/cmsUserModel.js
44:40 error Parsing error: Unexpected token
✖ 1 problem (1 error, 0 warnings)
ERROR in ./src/models/cmsUserModel.js
Module build failed: Error: Module failed because of a eslint error.
/Users/petrtomasek/Projects/cms/src/models/cmsUserModel.js
44:40 error Parsing error: Unexpected token
✖ 1 problem (1 error, 0 warnings)这很好,但我想看到标准错误处理,如默认webpack和巴贝尔装载机打印当前错误行,如果可能的话。
第二个错误是,我仍然不能使用属性类型,例如:template: string
请问出什么事了?谢谢你的时间!
发布于 2016-07-10 17:50:13
我认为你应该尝试以下步骤,
1. npm install --save-dev babel-preset-es2015
2. Add query: { presets: ['es2015'] } to your webpack config with the babel loader.
loaders: [{
test: /\.js?$/,
exclude: /node_modules/,
loader: 'babel',
query: { presets: ['es2015'] }
}]https://stackoverflow.com/questions/38291699
复制相似问题