4

I am getting the following error in my Angular app after adding gulp babel to my gulp file. I need this to transpile and minify my ES6:

Cannot set property '0' of undefined

I'm thinking angular-file-saver doesn't like to babelfication.

Causing these errors:

angular.js:33 Uncaught Error: [$injector:modulerr] Failed to instantiate module app due to:

Error: [$injector:nomod] Module 'app' is not available!

enter image description here

Yet I can see the module being loaded client side:

enter image description here

Gulp Task: Note: this error only started occuring when I started piping through babel. If I remove babelminify, it produces the same error.

gulp.task('scripts-dev', () => {
  return gulp.src(paths.vendorJavascript.concat(paths.appJavascript, paths.appTemplates))
    .pipe(plugins.if(/html$/, buildTemplates()))
    .pipe(babel({
        presets: [['es2015', {modules: false}]]
    }))
    //.pipe(babelminify())
    .pipe(plugins.sourcemaps.init())
    .pipe(plugins.concat('app.js'))
    .pipe(plugins.sourcemaps.write('.'))
    .pipe(gulp.dest(paths.tmpJavascript))
    .pipe(plugins.connect.reload());
});

This error occurs even without minifying taking place

Community
  • 1
  • 1
user3871
  • 12,432
  • 33
  • 128
  • 268
  • Any comments or help on this? – user3871 Dec 02 '16 at 19:11
  • you can add `ng-strict-di` to your `ng-app` element in the HTML to have angular generate errors relating to any code that is not minification safe. Beyond that, it's possible something isn't right with your gulp task that is causing some of your scripts to not be included.... – Claies Dec 02 '16 at 22:21
  • @Claies see above, I added a picture (red text). I'm thinking angular-file-saver doesn't like to babelfication. – user3871 Dec 02 '16 at 22:40
  • Did you find any solution? – MAG Feb 19 '17 at 22:00

1 Answers1

0

using

.pipe(babel({
            presets: ['es2015']
        }))
//.pipe(uglify({ mangle: false }))  gulp-ugligy is used

should serve your purpose

Sreeragh A R
  • 2,871
  • 3
  • 27
  • 54