You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have already a branch which implements @Kovensky commit, I didn't niclude it in #7020 to avoid introducing too many changes in one pr. nicolo-ribaudo@cbb31c3
Since Babel now supports JavaScript configuration files, the plugin could accept a function which tells which part of the extend clause needs to be wrapped.
e.g.
module.exports={plugins: [["@babel/transform-classes",{wrapBuiltin(node){if(node===somethingThatNeedsToBeWrapped)returntrue;// class extends mixin(HTMLElement)if(t.isCallExpression(node)&&t.isIdentifier(node.callee,{name: "mixin"})&&t.isIdentifier(node.arguments[0],{name: "HTMLElement"}){return"arguments.0";}}}]]};
All extendable built-ins are globals, so this should work fine.
cc @treshugart who ran into this issue with SkateJS. Since mixins are popular in the web components world, where we also need to extend native classes, it'd be really nice to have this fixed soon.
Activity
nicolo-ribaudo commentedon Dec 20, 2017
I have already a branch which implements @Kovensky commit, I didn't niclude it in #7020 to avoid introducing too many changes in one pr. nicolo-ribaudo@cbb31c3
I can think of two possible implementations:
Since Babel now supports JavaScript configuration files, the plugin could accept a function which tells which part of the
extendclause needs to be wrapped.e.g.
Use a special comment:
justinfagnani commentedon Feb 5, 2018
I think a simpler solution is to just allow a list of constructors that need to be wrapped in the configuration:
All extendable built-ins are globals, so this should work fine.
cc @treshugart who ran into this issue with SkateJS. Since mixins are popular in the web components world, where we also need to extend native classes, it'd be really nice to have this fixed soon.