0

I am trying to get my asset bundling to work with es6 and it wont work. My package.json is:

"devDependencies": {
"babel-preset-es2015": "^6.6.0",
"del": "^2.2.0",
"gulp": "^3.9.1",
"gulp-babel": "^6.1.2"

}

My bundle.config.json conatins:

options: {
    uglify: ['production'], // uglify the resulting bundle in prod
    rev: ['production'], // rev the resulting bundle in prod
    transforms: {
      scripts: lazypipe().pipe(babel, {
        presets: ['es2015']
      }
      )
    }
  }

My bundle task is:

var gulp = require('gulp');
var sourcemaps = require('gulp-sourcemaps');
var sass = require('gulp-sass');
var bundle = require('gulp-bundle-assets');
var del = require('del');
[...]
gulp.task('bundle', function() {
del([
    './atlas3src/public/assets/bundles/**/*',
]);
return gulp.src('./bundle.config.js')
    .pipe(bundle())
    .pipe(bundle.results({
        dest: './atlas3src/public/assets/',
        pathPrefix: '/assets/bundles/'
    }))
    .pipe(gulp.dest('./atlas3src/public/assets/bundles/'));
});

And when i try to bundle it throws following error:

[20:30:33] Error in plugin "gulp-babel"
Message:
Plugin/Preset files are not allowed to export objects, only functions. In /home/ubuntu/workspace/node_modules/babel-preset-es2015/lib/index.js
user3241778
  • 294
  • 2
  • 4
  • 20
  • 1
    Are you sure you actually have `gulp-babel` version `^6.1.2` installed? That error implies you are running a newer version. – loganfsmyth Jan 12 '19 at 22:08
  • How can I verify my version. This is my actual package. Json at the top so I believe I have the right version. – user3241778 Jan 12 '19 at 22:53
  • 1
    You'd have to look in `node_modules/gulp-babel/package.json` to see what version is installed. I should clarify here that I'm also assuming the `babel` in `lazypipe().pipe(babel, {` is `gulp-babel`, but now I'm second-guessing that? You'll want to make sure that is actually running Babel 6. The error is because you're running a Babel 6 plugin with Babel 7 currently. – loganfsmyth Jan 13 '19 at 03:45
  • Gulp-babel package.json says: [...]"dependencies": { "babel-core": "^6.23.1", "object-assign": "^4.0.1", "plugin-error": "^1.0.1", "replace-ext": "0.0.1", "through2": "^2.0.0", "vinyl-sourcemaps-apply": "^0.2.0" }, "description": "Use next generation JavaScript, today", "devDependencies": { "babel-plugin-transform-es2015-arrow-functions": "^6.0.2", "babel-plugin-transform-es2015-block-scoping": "^6.0.9", "babel-plugin-transform-es2015-classes": "^6.0.8",[...] – user3241778 Jan 13 '19 at 08:05
  • and babel package.json says: [...] "version": "6.26.3" [...] – user3241778 Jan 13 '19 at 08:06
  • My node version is v6.11.2 – user3241778 Jan 13 '19 at 08:18

1 Answers1

0

I solved it myself. The problem was that I had multuple node_modules folders and gulp used the one with the false babel version.

user3241778
  • 294
  • 2
  • 4
  • 20