I'm trying to integrate babel
through gulp
.
var babel = require('gulp-babel');
var es6 = require('babel-preset-es2015');
...
return gulp.src('path/to/my/source/file/js')
.pipe(babel({presets:es6}))
...
When I run the compile task, my linter (JSHint
) says that the line is too long and that I'm missing a line end.
Let's say that my source file is as following (please note the last empty line) :
(function(){
var myApp = angular.module('first-dependence',[
'another-dependence',
'and-another-dependence']
}();
// Empty line here
Babel outputs it like this:
(function(){
var myApp = angular.module('first-dependence',['another-dependence','and-another-dependence']
}();
For me, he is ignoring the line returns inside the instructions and removes the last empty line.
Is it possible to tell babel
to keep the formatting as it's and to only transcompile ?
Regards
You can't. But you can try
the retainLines option
.pipe(babel({presets:es6, retainLines:true}))
or to rely on source maps (see gulp-babel).
But neither will preserve your white-space exactly as it is right now.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With