Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
ericmartinezr opened this issue Jan 10, 2016 · 62 comments
Closed

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

ericmartinezr opened this issue Jan 10, 2016 · 62 comments
Labels
area: packaging Issues related to Angular's creation of npm packages effort1: hours type: bug/fix

Comments

@ericmartinezr
Copy link
Contributor

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 #6304 (comment)). 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?

@ocombe
Copy link
Contributor

ocombe commented Jan 10, 2016

I have a similar error on my ng2-webpack starter: preboot/angular-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).

@ericmartinezr
Copy link
Contributor Author

Hey @ocombe thanks for the tip. Lets wait then, thanks 👍

@ericmartinezr
Copy link
Contributor Author

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.

@alexeagle
Copy link
Contributor

Marked P1 as lots of users are running into this

@ffMathy
Copy link

ffMathy commented Feb 12, 2016

It is still present in beta 5.

@ffMathy
Copy link

ffMathy commented Feb 12, 2016

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

@0x-r4bbit
Copy link
Contributor

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

@ffMathy
Copy link

ffMathy commented Feb 12, 2016

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
Copy link

ffMathy commented Feb 15, 2016

Still present in beta 6 as well.

@weupagency
Copy link

@ffMathy +1

@zuozuo
Copy link

zuozuo commented Mar 31, 2016

@pxwise thanks!. @hongbo-miao @pxwise has given a much better solution.

@tbosch
Copy link
Contributor

tbosch commented Apr 1, 2016

Might take a little while to land my PR...
On Wed, Mar 30, 2016 at 8:04 PM 左永辉 notifications@github.com wrote:

@pxwise https://github.com/pxwise thanks!. @hongbo-miao
https://github.com/Hongbo-Miao @pxwise https://github.com/pxwise has
given a much better solution.


You are receiving this because you were mentioned.

Reply to this email directly or view it on GitHub
#6380 (comment)

@ericmartinezr
Copy link
Contributor Author

@tbosch thanks for taking a look at this.

In the meantime this workaround from @gdi2290 (see #6695 (comment)) works perfectly with minification.

Copy & pasting

mangle: {
  screw_ie8 : true,
  keep_fnames: true
}

@ericmartinezr
Copy link
Contributor Author

For those following this issue, this is already fixed in latest master, here's the plnkr updated with the minified bundle from latest master http://plnkr.co/edit/3Bcdnef5C45tzOPSw5DE?p=preview

Can't wait to this to land 😄 👏

@ericmartinezr
Copy link
Contributor Author

Ok people, to everyone following it's time to test this. The plnkr using b.16 works perfectly http://plnkr.co/edit/7TdYjVkbbvsy2AoLQcpf?p=preview , but there was a PR to disable mangle for bundles. So we should test in our local envs to see if minification actually works

This is my current config for UglifyJS plugin with webpack

        new webpack.optimize.UglifyJsPlugin({
            compress : {
                warnings : false
            }
        })

Can you guys try if it works for you with minification and without mangle? It works for me :D !

@micaelmbagira
Copy link

I did and it works for me as well.

@brechtbilliet
Copy link
Contributor

Works like a charm!

@antonybudianto
Copy link

Finally it works!

@HerringtonDarkholme
Copy link

Tested locally.
Every thing works like a charm with both compress and mangle options turned on for uglifyjs. Further more keep-fname is turned off as well.
Both angular source and my application source are compression-safe.

Great works! @tbosch !

I wonder when we can turn the mangle and keep-fname off? @gdi2290 ?

@ericmartinezr
Copy link
Contributor Author

This was fixed already, closing.

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: packaging Issues related to Angular's creation of npm packages effort1: hours type: bug/fix
Projects
None yet
Development

Successfully merging a pull request may close this issue.