Babelify分解

时间:2016-04-28 13:49:09

标签: babeljs

我创建了一个Gulpfile.js:

var gulp = require('gulp');
var browserify = require('browserify');
var babelify = require('babelify');
var source = require('vinyl-source-stream');

gulp.task('browserify', function(){
  return browserify('./app/app.js')
        .transform(babelify, { stage: 1})
        .bundle()
        .pipe(source('bundle.js'))
        .pipe(gulp.dest('dest'));
});

我在app文件夹中有app.js并需要在其上应用browserify任务,app.js包含此反应类

var React = require('react');
var PropTypes = React.PropTypes;

var App = React.createClass({

  render: function() {
    return (
      <div />
    );
  }

});

module.exports = App;

当我运行这个

  

gulp browserify

它给了我这个错误:

events.js:72
        throw er; // Unhandled 'error' event
              ^
ReferenceError: [BABEL] E:\learn\react\RMD\public\assets\app\app.js: Using removed Babel 5 option: base.stage - Check ou
t the corresponding stage-x presets http://babeljs.io/docs/plugins/#presets while parsing file: E:\learn\react\RMD\publi
c\assets\app\app.js
    at Logger.error 

1 个答案:

答案 0 :(得分:3)

  

使用已移除的Babel 5选项:base.stage

.transform(babelify, { stage: 1})
                       ^^^^^