angular icon indicating copy to clipboard operation
angular copied to clipboard

[beta.2] ngDoCheck is not a function when using minified bundles

Open ericmartinezr opened this issue 10 years ago • 62 comments

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?

ericmartinezr avatar Jan 10 '16 02:01 ericmartinezr

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).

ocombe avatar Jan 10 '16 06:01 ocombe

Hey @ocombe thanks for the tip. Lets wait then, thanks :+1:

ericmartinezr avatar Jan 10 '16 09:01 ericmartinezr

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.

ericmartinezr avatar Jan 28 '16 20:01 ericmartinezr

Marked P1 as lots of users are running into this

alexeagle avatar Feb 12 '16 03:02 alexeagle

It is still present in beta 5.

ffMathy avatar Feb 12 '16 05:02 ffMathy

Does P1 mean it will be fixed in the next beta?

ffMathy avatar Feb 12 '16 06:02 ffMathy

@ffMathy It means that it has a very high priority to be fixed. Doesn't guarantee that'll land in next beta release.

0x-r4bbit avatar Feb 12 '16 12:02 0x-r4bbit

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.

ffMathy avatar Feb 12 '16 17:02 ffMathy

Still present in beta 6 as well.

ffMathy avatar Feb 15 '16 05:02 ffMathy

@ffMathy +1

weupagency avatar Feb 15 '16 15:02 weupagency

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.

ffMathy avatar Feb 15 '16 16:02 ffMathy

ran into this too screen shot 2016-01-10 at 3 14 34 pm

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

antonybudianto avatar Feb 24 '16 00:02 antonybudianto

It is still present in beta 7 as well.

ffMathy avatar Feb 24 '16 05:02 ffMathy

Still doesn't work in beta 8.

ffMathy avatar Mar 05 '16 18:03 ffMathy

here's the current workaround

new UglifyJsPlugin({
  mangle: {
    except: ['RouterLink', 'NgFor', 'NgModel']
  }
}),

PatrickJS avatar Mar 07 '16 09:03 PatrickJS

Ahh thanks !

ocombe avatar Mar 07 '16 09:03 ocombe

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 avatar Mar 07 '16 11:03 ericmartinezr

@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 avatar Mar 07 '16 20:03 CaptainCodeman

@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:

ericmartinezr avatar Mar 07 '16 20:03 ericmartinezr

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)

CaptainCodeman avatar Mar 07 '16 20:03 CaptainCodeman