schmod / babel-plugin-angularjs-annotate

Add Angular 1.x dependency injection annotations to ES6 code
http://schmod.github.io/babel-plugin-angularjs-annotate
MIT License
241 stars 26 forks source link

"Module 'xxx' is not available!" errors when converting from ngAnnotate #41

Open uberspeck opened 6 years ago

uberspeck commented 6 years ago

I'm updating libraries on a legacy project. Our build system relies on gulp and i've installed gulp-babel, babel-core etc and the scripts run. However the app fails with Module '[module name]' is not available! errors. I assume that babel is doing more under the hood than ngAnnotate was and it's causing some issues. I've tried changing settings in my .babelrc file, but that hasn't helped. Here's my current configuration.

.babelrc...

{
  "presets": [
    ["env", {
      "targets": {
        "browsers": ["ie >= 10"],
        "modules": false,
        "debug": true
      }
    }]
  ],
  "plugins": ["angularjs-annotate"]
}

application coffee script gulp task...

gulp.task('appJs', function(cb) {

  function templates(){
    return gulp
      .src(['./src/**/*.html'])
      .pipe(changed('./dev/js'))
      .pipe(flatten())
      .pipe(
        htmlmin({
          collapseWhitespace: true,
          removeComments: true,
          removeAttributeQuotes: true
        })
      )
      .pipe(
        angularTemplatecache({
          module: 'pvdm.core.templates'
        })
      )
  }

  function coffeescript(){
    return gulp
      .src(['!./src/**/*spec.coffee','./src/**/*module.coffee','./src/**/*.coffee'])
      .pipe(changed('./dev/js'))
      .pipe(coffee())
      .pipe(babel())
  }

  return eventStream
    .merge(templates(), coffeescript())
    .pipe(concat('app.js'))
    .pipe(gulp.dest('./dev/js'))

});

vendor js gulp task

gulp.task('vendorJs', function(cb){
  return gulp.src(config.vendor_js)
    .pipe(changed('./dev/js'))
    .pipe(concat('vendor.js'))
    .pipe(babel())
    .pipe(gulp.dest('./dev/js'));
});
binarykitchen commented 4 years ago

Having this issue too. How to migrate from old gulp-ng-annotate to this?

dv336699 commented 4 years ago

Not a solution for this issue, but I found an updated version of gulp-ng-annotate

https://github.com/olov/ng-annotate/issues/245#issuecomment-373157859