Search code examples
javascriptangularbundling-and-minificationsystemjses6-module-loader

Angular 2 SFX production build


I have an Angular 2 Beta 8 (cannot update now) app that I need to bundle and minify for production deployment. With the following configs I can generate a SFX bundle but a minified version of the bundle does not work. It keeps on executing something and overflows the tab. I have component in it that has a console.log in in its constructor. That keeps running like more than 1000 times before the tab crashes. But the unminified version of the bundle runs as expected which is totally weird to me.

system.config.js

System.config({
    defaultJSExtensions: true,
  map: {
    app: 'wwwroot/app/core',
    angular2: 'node_modules/angular2',
    rxjs: 'node_modules/rxjs',
    dragula: 'wwwroot/lib/dragula/dragula.min',
    'ng2-dragula/ng2-dragula': 'wwwroot/lib/dragula/ng2-dragula',
    'ng2-cookies/ng2-cookies': 'wwwroot/lib/ng2-cookies/ng2-cookies'
  },
  packages: {
    app: {
      defaultExtension: 'js',
      main: 'main.js'
    },
    angular2: {
      defaultExtension: 'js'
    },
    rxjs: {
      defaultExtension: 'js'
    }
  }
});

gulpfile.js

function getBuilder(configPath) {
    var builder = new SystemBuilder();
    return builder.loadConfig(configPath)
      .then(function () {
          return builder;
      });
}

gulp.task('bundle', function () {   
    return getBuilder('./system.config.js')
      .then(function (builder) {
          return builder.buildStatic('app', './bundledapp.js', { minify: true });
      });
});

Any help is really appreciated.


Solution

  • Due to some bug in Angular 2 Beta versions a prod build was not possible