question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Gulp babel not transpiling to es5

See original GitHub issue

I installed gulp babel (and dependencies) and when running gulp, same es6 code is being output in dist. I tried adding .babelrc to specify preset as well as specifying preset in gulp.

Is there anything I am missing?

gulpfile

var gulp         = require('gulp');
var babel        = require('gulp-babel');

gulp.task( 'customJS', function() {
    gulp.src( [ jsCustomSRC ] )
        .pipe( concat( jsCustomFile + '.js' ) )
        .pipe(babel({
            presets: ['@babel/env']
        }))
        .pipe( gulp.dest( jsDestination ) )
});

.babelrc

{
  "presets": ["@babel/env"]
}

package.json

  "devDependencies": {
    "@babel/core": "^7.1.5",
    "@babel/preset-env": "^7.1.5",
    "gulp": "^4.0.0",
    "gulp-babel": "^8.0.0",
    "gulp-concat": "^2.5.2"
  }

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:21
  • Comments:22 (1 by maintainers)

github_iconTop GitHub Comments

5reactions
ArnoMandersTfecommented, Dec 20, 2018

I also had this probleem but wrapping it in a second array will fix it,

.pipe($.babel({
    presets: [['@babel/preset-env']]
}))
4reactions
Extaryscommented, Nov 13, 2018

I have the same issue I got no files being created nor do I get any error by the task where babel runs.

For completeness I’ve include my code below.

packages.js

  "@babel/cli": "^7.1.5",
    "@babel/core": "^7.1.6",
    "@babel/preset-env": "^7.1.6",
    "@babel/preset-stage-1": "^7.0.0", // Deprecated?
    "@babel/traverse": "^7.1.4",
    "gulp": "^3.9.1",
    "gulp-babel": "^8.0.0",
    "gulp-nodemon": "^2.4.1",
    "gulp-sass": "^4.0.2",
    "nodemon": "^1.11.0",

Task:

var DEST = 'build/'

gulp.task('build', () => {
  return gulp
    .src(['./src/**/*.js'])
    .pipe(
      babel({
        presets: ['@babel/preset-env']
      })
    )
    .pipe(gulp.dest(DEST))
})
Read more comments on GitHub >

github_iconTop Results From Across the Web

gulp-babel transpile from >=ES6 to ES5 - Stack Overflow
So it turns out, that is is expected. Babel would only transpile ES6 and above to ES5. Module like browserify or webpack needs...
Read more >
How to convert ES6 to ES5 using Babel with Gulp - Hydroid
To use ES6 Code in your application, we need to transpile the ES6 code into ES5 code using babel so that it can...
Read more >
How to Use ES2015 Today with Babel and Gulp
It performs transpilation from ES2015 to ES5 on the fly. However, babel-node is not recommended for production use due to the overhead of ......
Read more >
Working with BabelJS and Gulp - Tutorialspoint
js as a platform. Gulp will run the tasks that will transpile JavaScript files from es6 to es5 and once done will start...
Read more >
[Solved]-gulp-babel transpile from >=ES6 to ES5-babel.js
If you are using babel version 7, you need to gulp-babel version 8 which you can get npm run i --save-dev gulp-babel for...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found