There are many questions on StackOverflow, related to this but none answers with logic.
If Index.html runs first.
Main.ts or better say Main.js (after transpilation) can't run by itself as it is a javascript file at the end, and Index.html file is the one that contains the reference of main.js at the bottom before the closing body tag, obviously, the webpack does all this.
Now, let's say from the configuration that is Angular.json file, the angular knows that Index is the main HTML file that should be served first.
Then again, as Main.js is unknown at this point, so there is no way that the angular would know about the root component. And it must throw an error while parsing but it doesn't throw the error. This means, it already knows about app-root, which means Main.js is the entry point. But how is this possible, how a javascript file can be triggered without Html page?
first way:- Angular.json ---> Main.js--->Index.html (but how is this possible? who triggers Main.js?)
second way:- Angular.json--->Index.html---->Main.js (but then how do angular know about ??)
also,
My question is, If I write huge "ts" code inside the App-Component itself, then also it will not be executed even after the flow reaches the <app-root> as angular has no idea about what <app-root> actually is until it finds the Main.js in the body tag and executes it and then only it could know about it.