[beta.2] ngDoCheck is not a function when using minified bundles
When using minified bundles with SystemJS, and a simple snippet like this
<template ngFor #item [ngForOf]="items" #i="index">
<li>{{i}}</li>
<li *ngIf="i % 2 == 0">number is even</li>
</template>
Will throw
TypeError: this.directive_0_0.ngDoCheck is not a function
This is only reproducible with minified bundles, non-minified work correctly.
As an example check this plnkr (took it from https://github.com/angular/angular/issues/6304#issuecomment-170200989). To reproduce switch between minified and unminified bundles.
This is also reproducible with Webpack using this line in the config
plugins : [
new webpack.optimize.UglifyJsPlugin()
],
Am I missing something?
I have a similar error on my ng2-webpack starter: ocombe/ng2-webpack#7
The message is No provider for t! (t -> t) and adding mangle: false to the UglifyJS plugin fixes the problem (but the files are much bigger, so that's only temporary).
Hey @ocombe thanks for the tip. Lets wait then, thanks :+1:
Beta.2 still have these issues with minifications, here's the plnkr updated http://plnkr.co/edit/24fjnjNdAvpbfY8a85B2?p=preview . Reproducible in the same way as in the first comment.
Marked P1 as lots of users are running into this
It is still present in beta 5.
Does P1 mean it will be fixed in the next beta?
@ffMathy It means that it has a very high priority to be fixed. Doesn't guarantee that'll land in next beta release.
Still, it is a low effort one-hour task wih a P1 tag. I'm hoping for the best. I am stuck on my project until this is complete.
Still present in beta 6 as well.
@ffMathy +1
I should also add that this most likely also blocks all browserify users. For me, it picks the minified versions from NPM node_modules first.
ran into this too

with mangle disabled, it worked well, also happening since beta.1 (no problem with beta.0)
reproduce:
repo, set mangle to true in here, then gulp serve-build, inspect element when the browser popup
It is still present in beta 7 as well.
Still doesn't work in beta 8.
here's the current workaround
new UglifyJsPlugin({
mangle: {
except: ['RouterLink', 'NgFor', 'NgModel']
}
}),
Ahh thanks !
Thanks for the workaround Patrick!
Edit
I spoke too soon. The workaround works, but I'm getting No Directive annotation found on e and I can't find what to add in except to make it work.
@ericmartinezr AsyncPipe did it for me but then it fails on something else. I don't know if it's worth following the trail - who knows how long it is!
@CaptainCodeman thanks, I tried right now but I didn't succeed. It failed with a EXCEPTION: RangeError: Maximum call stack size exceeded on Chrome and EXCEPTION: InternalError: too much recursion in FF. This is getting weirder, lol. I'll just keep with unminified version, thanks :+1:
I get a different error so it probably depends heavily on which pieces are used and it could extend to app code as well. Not worth bothering with until it's fixed properly. This is the best i got for now:
new LoaderOptionsPlugin({
minimize: true,
debug: false
}),
new UglifyJsPlugin({
beautify: false,
mangle: false,
compress : { screw_ie8 : true },
comments: false
}),
(webpack 2 BTW)