Seeking advice on JS target output for compiled Angular when utilizing differential loading.
By default, Angular compiles TypeScript down to ES5 and ES2015, with browsers using either depending on their capabilities.
In order to stay current, I've been researching different ES versions and browser support.
Unfortunately, I've reached a roadblock and can't find more information on this topic.
To ensure compatibility with modern browsers, I decided to upgrade the target output from es2015 to es2016.
I achieved this by adjusting the target value in tsconfig.json
"compilerOptions": {
"target": "es2016"
}
However, I encountered an issue.
During compilation, I received the following warning:
Warning: Using differential loading with targets ES5 and ES2016 or higher may cause problems. Browsers with ES2015 support will load ES2016+ scripts but they might not support ES2016+ syntax.
Essentially, I'm curious about how Typescript/Angular/the browser determines which file to serve based on the browser being used (how does targeting work).
Is it possible to configure this on a per-browser basis? For example, having some browsers use es5, others use es2015, and certain ones use es2016. I'm struggling to grasp how differential loading caters to specific browsers.
Additionally, are there any advantages to using a version later than es2015 (such as fewer polyfills, more native code, faster performance, smaller compiled files)?
Thank you in advance for your help.