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

Docs Warning "Angular plugin is NOT ECMAScript 3 (ES3) compatible." #102

Open
OzBob opened this issue May 12, 2023 · 4 comments
Open

Docs Warning "Angular plugin is NOT ECMAScript 3 (ES3) compatible." #102

OzBob opened this issue May 12, 2023 · 4 comments
Labels
documentation Improvements or additions to documentation

Comments

@OzBob
Copy link

OzBob commented May 12, 2023

https://learn.microsoft.com/en-us/azure/azure-monitor/app/javascript-framework-extensions?tabs=angular#angular-plugin-for-application-insights-javascript-sdk
says
"Warning: Angular plugin is NOT ECMAScript 3 (ES3) compatible."

What needs to be done to make this project "ECMAScript 3 (ES3) compatible"?

or do the Docs need updating?

@MSNev
Copy link
Contributor

MSNev commented May 12, 2023

The biggest issue is that Angular itself is not ES3 compatible, which is why we have this statement

@OzBob
Copy link
Author

OzBob commented May 15, 2023

Really? Could you point to me to some source data on that?

As of Mar 3 2023:
Angular build uses TypeScript 5 angular/angular-cli#24803
and
On the Microsoft Typescript blog Daniel Rosenwasser says they are targeting ECMAScript 2018
https://devblogs.microsoft.com/typescript/announcing-typescript-5-0/#runtime-requirements

@MSNev
Copy link
Contributor

MSNev commented May 16, 2023

Sorry for the delay responding I was unexpectedly away yesterday.

This is based on the basic browser support of Angular which is not supporting older browser (such as IE8) which only support ES3, that support features that came into existence after ES3.

And ES3 pre-dates ES2018, so when you target ES2018 you are allowed (and TypeScript will emit) to use basic JavaScript API's that did not exist in ES3.

There are several standard API's which are just not supported by ES3 and cannot be polyfilled (completely) such as getters and setters. In Application Insights we use the rollup-es3 (v2.x), rollup-es5 (v3.x) to detect and stop us from publishing any Application Insights builds with API's that are just not supported in (all) runtimes at our targeted level (these are because some of them TypeScript will still allow).

With v3.x (recently released) since we are targeting ES5 TypeScript allows us to use a bunch of API's that it blocked during compilation when targeting ES3 so we use this to block us and ensure that we use polyfills
https://github.com/microsoft/ApplicationInsights-JS/blob/main/tools/rollup-es5/src/es5/Es5Tokens.ts

And for ES3 here are the tokens https://github.com/microsoft/ApplicationInsights-JS/blob/master/tools/rollup-es3/src/es3/Es3Tokens.ts, the ES3 is a little more complete in that it has the ability to rewrite some unsupported usages into basic inline polyfill implementations

So as we are not using these fail-safes and Angular does not state that it supports ES3 we explicitly state that this component does not support ES3 and we are not intending to try and keep ES3 compatibility for components beyond our control.

If you are using a v2.x version of ApplicationInsights as the base that DOES support es3, so it would only be this plugin and angular in general (with it's dependencies) that would be a blocker from using in an environment that only supports ES3.

Note: event ES5 pre-dates ES2018 https://en.wikipedia.org/wiki/ECMAScript_version_history

@OzBob
Copy link
Author

OzBob commented Jun 11, 2023

Thank you for an excellent explanation. My impression from the statement 'does not support ES3' was that this module was stuck in a undesirable pre-ES3 compatibility mode. Maybe just after the ES3 warning in the docs it would be helpful to say that these modules/libraries work with modern projects.

@MSNev MSNev added the documentation Improvements or additions to documentation label Jun 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants