angular / angular-cli

CLI tool for Angular
https://cli.angular.dev
MIT License
26.78k stars 11.98k forks source link

some elements don't load to page after upgrading to angular9, (Ivy enable, prod mode only) #17510

Closed alireza267 closed 4 years ago

alireza267 commented 4 years ago

🐞 bug report

Affected Package

The issue is caused by package @angular/core 9.x.x ### Is this a regression? Yes, the previous version in which this bug was not present was: @angular/core 8.x.x although when I disable Ivy compiler I won't see the bug in @angular/core9.x.x ### Description We have an Enterprise application was written by angular. everything was ok until we upgraded to angular9. then some components stop being shown in application. when I deep through the problem I found that angular9 Ivy component have some different mechanisms such as tree shaking, and that might cause some of my code considered as dead code. this is my assumption that Ivy engine wrongly eliminate some of our elements in the html. Or maybe sometimes angular binding don't work perfect ! In develop mode by running the `ng serve` and when we **disable Ivy engine** in production mode `ng build --prod` then every thing is Ok. When Ivy is enable in production mode I see this when I inspect element that is eliminated. ![image](https://user-images.githubusercontent.com/15701921/79715603-6a432e80-82e9-11ea-8033-3bc9e048aa89.png) and this is the html code of this part : ![image](https://user-images.githubusercontent.com/15701921/79716244-5c8ea880-82eb-11ea-9061-d473a7ffc719.png) Note that searchResult is a list with some elements and is not empty! I see some other bugs in this page as well, I have another component in this page called **market-depth** which is defined in costume library. when I comment this component then above list works perfect!!! ## πŸ”₯ Exception or Error noting is shown as exception of error in developer console. ## 🌍 Your Environment **Angular Version:**


 angular 9.1.2
**Anything else relevant?**
ericmartinezr commented 4 years ago

Sounds like https://github.com/angular/angular-cli/issues/17494

petebacondarwin commented 4 years ago

I think so... transferring to CLI repo.

alan-agius4 commented 4 years ago

This seems like a bug but we'll need to look at a reproduction to find and fix the problem. Can you setup a minimal repro please?

You can read here why this is needed. A good way to make a minimal repro is to create a new app via ng new repro-app and adding the minimum possible code to show the problem. Then you can push this repository to github and link it here.

This might be related to your directory structure so its really important to get an accurate repro to diagnose this.

alireza267 commented 4 years ago

@alan-agius4 At this moment unfortunately I can't. As I mentioned this is an enterprise application and contains a lot of components and costume libraries and making a minimal reproduction is not easy.

alan-agius4 commented 4 years ago

@alireza267, unfortunately without a minimal reproduction we'll have to close this issue as we cannot investigate this.

alireza267 commented 4 years ago

After updating ng-packagr of my library to version 9.1.1 , I get this error in developer console (in ng serve mode) and whole page doesn't load! Error: Uncaught (in promise): TypeError: Cannot read property 'Ι΅cmp' of undefined I don't know this error is a progress to find the solution but i hope this could help.

alan-agius4 commented 4 years ago

@alireza267, the error might be related to https://github.com/angular/angular/issues/36279

alireza267 commented 4 years ago

I finally solve the problem, however I can't deny that Ivy is weird and is not stable yet. the problem was that somewhere in a component in a library we import a class like this: import { class1 } from '../public-api'; and this causes this error: Error: Uncaught (in promise): TypeError: Cannot read property 'Ι΅cmp' of undefined so after importing class1 from correct address the problem solved

angular-automatic-lock-bot[bot] commented 4 years ago

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.