Skip to content Skip to sidebar Skip to footer

Simple Es7 Decorator With Babel

I can not run this code: https://www.npmjs.com/package/core-decorators#readonly I use gulp and babel. I have package.json { 'name': 'my-first-decorator', 'version': '0.0.1',

Solution 1:

You need to add the stage-1 preset, since decorators are non-standardised yet (so they are not and will not be included into the es2015 preset).

https://babeljs.io/docs/plugins/preset-stage-1/

Solution 2:

I installed packages:

$ npm install core-decorators
$ npm install gulp browserify vinyl-source-stream
$ npm install babelify@6.4.0

!!!!! babelify - 6.4.0 seventh version was not able to run

gulpfile:

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

gulp.task('default', function () {
    returnbrowserify({entries: 'app.js', extensions: ['.js'], debug: true})
        .transform(babelify, {
            stage: 0
        })
        .bundle()
        .pipe(source('bundle.js'))
        .pipe(gulp.dest('app'));
});

and last command :)

$ gulp

Post a Comment for "Simple Es7 Decorator With Babel"