-1

I have an angular application which I recently upgraded to angular 15. I have a requirement to support it in Chrome 69 browser. When I run in Chrome 69, I get 2 errors which are related to the optional-chaining and nullish-coalescing-operator.

Could someone tell me what I need to add to my polyfills.ts file to support these operators in Chrome 69. I know babel has some plugins to support this and we can polyfill using it, but I don't want to use Babel unless it is the only option. Can I do it using core-js?

I tried the adding following lines in my polyfills.ts file:

import 'core-js/features/nullish-coalescing-operator';
import 'core-js/features/optional-chaining';

But, my code doesn't compile. I get the below error:

 Error: Module not found: Error: Can't resolve 'core-js/features/nullish-coalescing-operator'
 Error: Module not found: Error: Can't resolve 'core-js/features/optional-chaining'

Any help would be appreciated. Thanks in Advance!!

Edit: As per the core-js official documentation https://github.com/zloirock/core-js#babelpolyfill I can use core-js for polyfills instead of @babel/polyfill. I already have the below 2 lines in my polyfills.ts file

import 'core-js/stable';
import 'regenerator-runtime/runtime';

Please let me know what else I need to add support for nullish-coalescing-operator and optional-chaining?

Nitin Avula
  • 333
  • 2
  • 7
  • 21

1 Answers1

1

These patches don't exist in core-js.

More over, this can't be polyfiled as both are syntactic sugar. Babel isn't polyfilling but transpiling.

Matthieu Riegler
  • 31,918
  • 20
  • 95
  • 134