Angular: Support for es2015 compilation for CustomElements
See original GitHub issueAngular projects are compiled to es5. but window.customElements.define
takes only native ES2015 Class.
So I’d like to set TypeScript compilation target to es2015
.
repro: https://stackblitz.com/edit/angular-x6gyei
Error: Failed to construct 'HTMLElement': Please use the 'new' operator, this DOM object constructor cannot be called as a function.
Issue Analytics
- State:
- Created 5 years ago
- Comments:10
Top Results From Across the Web
Your options for building Angular Elements
If you only compile to es2015 +, you can omit the first script. ... need to include the above shown custom-elements-es5-adapter.js script.
Read more >Creating a Custom Element in Angular | by lavanya k - Medium
Angular elements are Angular components that carry the minified version of the whole framework. They allow you to create custom elements ...
Read more >Angular elements overview
Supported natively. In browsers that support Custom Elements natively, the specification requires developers use ES2015 classes to define Custom Elements - ...
Read more >Transform an Angular Component into a native Custom Element
Compile an Angular Component as standalone Custom Elements ... '@webcomponents/webcomponentsjs/custom-elements-es5-adapter.js'; at the end of polyfills.ts .
Read more >Angular 6 Custom Elements - Stack 24/7 - WordPress.com
Configurations Add '@angular/elements' with this command 'ng add ... Angular 6 Custom Elements ... import 'core-js/es6/parse-float';.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
As a workaround, you can add this shim to the external resources list: https://unpkg.com/@webcomponents/webcomponentsjs/custom-elements-es5-adapter.js
This isn’t just an Angular issue. The TypeScript project compiles to ES5 also. We should be able to configure the compiler for this and other settings (like presumably which decorators spec to use in the near future).