bublejs / buble

https://buble.surge.sh
MIT License
869 stars 67 forks source link

Bug in class mixin compilation. #243

Open snuggs opened 4 years ago

snuggs commented 4 years ago

I could have sworn this was addressed last year. Actually have been waiting for this to sort out for a couple years now. Am patient as the acorn library is still a mystery to me or I would submit a PR (not an issue).

We need to create a thunk and assign to a constant. This is used later with the Class Mixin pattern.

const Foo = Bar => class extends Bar {}

// ... a few moments later ...

class Baz extends Foo(x)

with 0.19.6 we could bypass by wrapping class in parenthesis (class extends Bar {})

However, upgrading to 0.19.8 issued the following malformed code Capture d’écran 2020-02-14 à 14 03 56

Attempted on https://buble.surge.sh site but gives yet another permutation of broken code.

repro: https://buble.surge.sh/#const%20Foo%20%3D%20Bar%20%3D%3E%20class%20extends%20Bar%20%7B%7D Capture d’écran 2020-02-14 à 14 07 31

Please let me know if I am doing something wrong. Or where I can help. My only caveat is a lack of knowledge on the innards of acorn.

Thanks in advance!

snuggs commented 4 years ago

Anybody? /cc @mourner

snuggs commented 4 years ago

@Rich-Harris what's good homie! Long time! I know you recently stepped down from project. But I swear I remember us working on this almost a couple years ago. I would try to fix it myself if I had clear direction of acorn etc. But now have people bugging me about this issue in a library I maintain that depends upon this package. Just let me know next step. Would hate to have to switch to babel. I'm loyal and would rather fix this. 💪

Thank you and PEACE! 🙏