WebReflection / hyperHTML-Element

An extensible class to define hyperHTML based Custom Elements.
ISC License
202 stars 25 forks source link

Uncaught TypeError: Class constructor HyperHTMLElement cannot be invoked without 'new' #38

Closed dios-david closed 6 years ago

dios-david commented 6 years ago

Hi everyone,

First of all, I would like to thank you for creating hyperHTML, it's amazing! I want to play with it, especially with the HyperHTMLElement, but I have an error:

Uncaught TypeError: Class constructor HyperHTMLElement cannot be invoked without 'new'

I use Parcel with Babel 7.

Can you please help me on resolving this? I uploaded the project here: https://github.com/dios-david/hyperhtml-test

Thanks in advance, David

Nevraeka commented 6 years ago

@dios-david Have you tried Parcel 1.10.0?

WebReflection commented 6 years ago

This is not HyperHTMLHElement related issue, it's a transpiler one.

Be sure you are using latest Babel, be sure you are targeting the right browsers, be sure your bundler understand classes properly 'cause you gonna have problems with every other native extend otherwise.

dios-david commented 6 years ago

Yes I know it's not related to HyperHTMLElement directly, it was intended as a question rather than a bug report :) Btw for anyone else who has the same problem, the issue can be solved by adding some browser target to the Babel config, eg.:

"browserslist": [
    "last 1 chrome versions"
]

(related issue in Parcel project: https://github.com/parcel-bundler/parcel/issues/839)

Thanks guys!

WebReflection commented 6 years ago

the issue can be solved by adding some browser target to the Babel config ...

watch out, you haven't fixed the issue, you have avoided the transpilation of classes. I think that is safe these days https://caniuse.com/#feat=es6-class but if you target IE11 or older browsers, you better follow my instructions ;-)

https://itnext.io/a-universal-bundle-loader-6d7f3e628f93