New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Babel-transpiled class can't extend from native class #6299
Comments
Hey @fatcerberus! We really appreciate you taking the time to report an issue. The collaborators If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack |
Gonna dup this with #4480. Unfortunately fixing this is not at all easy, and it's impossible to do in an entirely spec-compliant way. We've had a few suggested solutions, but none that are particularly nice implementation-wise. Usually the expectation is that if a library publishes code with ES6-native classes, users using that library should also have Babel set up to not compile classes. If you're trying to upgrade an existing library, I'd say changing from ES5-style classes to ES6-style classes is 100% a breaking change that requires a major-version upgrade. Seems like that is what you're saying you are doing with "my standard library has been refactored to export true ES6 classes". |
馃憤 Yes, my current work is already planned as a major version bump (4.8 -> 5.0) and I've even already made breaking API changes. I just figured if I could allow people to keep the |
No problem. Yeah, we've been trying to push everyone in the community to use https://github.com/babel/babel-preset-env because that way it's super easy to say "compile for Node" and get native classes to solve this problem. |
I definitely agree there. Unfortunately babel-standalone doesn't yet support |
I'm not sure if this is even possible to fix, but I figured I'd report it just in case. 馃槄
Supposing one is running under an ES6-supporting engine and there is a class which is not subject to transpilation:
If the class below is transpiled with Babel and then executed:
The result is a TypeError, constructor cannot be called without new. For example, I saw this when I tried to transpile my game with Babel before running it:
Background: My game engine, miniSphere, was previously based on Duktape, which mainly supports ES5.1. In order to support ES6 in my toolchain, I integrated Babel into the default build process. As I'm now in the process of switching over to ChakraCore, my standard library has been refactored to export true ES6 classes; however there is still Babelized code in the wild that I would like to maintain backward compatibility with, assuming that's possible.
The text was updated successfully, but these errors were encountered: