gulp-regexpu is a Gulp plugin to transpile ES6 Unicode regular expressions to ES5 with regexpu.
Issues with the output should be reported on the regexpu issue tracker.
Note: You may want to use a full-blown transpiler such as gulp-traceur or gulp-babel instead, as those support regexpu transpilation as well as many other ES6/ES7 features.
$ npm install gulp-regexpu --save-dev
var gulp = require('gulp');
var regexpu = require('gulp-regexpu');
gulp.task('default', function() {
return gulp.src('src/app.js')
.pipe(regexpu())
.pipe(gulp.dest('dist'));
});
Use gulp-sourcemaps like this:
var gulp = require('gulp');
var concat = require('gulp-concat');
var regexpu = require('gulp-regexpu');
var sourcemaps = require('gulp-sourcemaps');
gulp.task('default', function() {
return gulp.src('src/**/*.js')
.pipe(sourcemaps.init())
.pipe(regexpu())
.pipe(concat('all.js'))
.pipe(sourcemaps.write())
.pipe(gulp.dest('dist'));
});
Thanks to Sindre Sorhus, whose many great examples of Gulp plugins made it very easy to create this one. 🍺
Mathias Bynens |
gulp-regexpu is available under the MIT license.