Web component not working for old Chrome versions after update to Angular 15

854 Views Asked by At

After updating Angular to version 15, where the target of compilerOptions is automatically set to ES2022, my angular web component is not working anymore for Chrome 53.

This error is showing in console: Uncaught SyntaxError: Unexpected token {

I am importing the following polyfills:

  • custom-elements-es5-adapter.js
  • webcomponents-bundle.js

I tried to lower the Chrome version in browserlist, but this has no affect. Changing the target doesn't help either, because Angular CLI sets it back to es2022 and shows this message: TypeScript compiler options "target" and "useDefineForClassFields" are set to "ES2022" and "false" respectively by the Angular CLI.

Does somebody know how to let angular web components work again on old Chrome browsers for Angular 15?

1

There are 1 best solutions below

5
On

it is possible that for Angular 15 the Typescript version is also to upgrade to (4.2) it has new features and improvements and your code is possibly not fully compatible, maybe you have to adjust the code a bit