question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Angular: Support for es2015 compilation for CustomElements

See original GitHub issue

Angular 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:open
  • Created 5 years ago
  • Comments:10

github_iconTop GitHub Comments

14reactions
robwormaldcommented, May 9, 2018

As a workaround, you can add this shim to the external resources list: https://unpkg.com/@webcomponents/webcomponentsjs/custom-elements-es5-adapter.js

2reactions
justinfagnanicommented, Oct 6, 2018

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).

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found