Fix decorators babel plugin issue#426
Conversation
|
I'm curious why this "Works" then: https://github.com/NullVoxPopuli/babel-transpilation-tests export default {
presets: ['@babel/preset-env'],
plugins: [['@babel/plugin-proposal-decorators', { legacy: true }]]
};babel hurts my head lol |
node-tests/addon-test.js
Outdated
| browsers: ["last 2 chrome versions"], | ||
| }; | ||
|
|
||
| subject = this.addon.transpileTree(input.path(), {}); |
There was a problem hiding this comment.
oh! this confirms my hypothesis from: #422 (comment)
yay!
34b3caa to
688367f
Compare
Mentioned in discord, but I'll also mention it here: that repro actually demonstrates the failure!!! See this assertion: https://github.com/NullVoxPopuli/babel-transpilation-tests/blob/9bbc2c8353e45bebae9ae16defd40830614718e1/output.js#L20 |
I'm sad to see this! lol. |
f138137 to
64e00a6
Compare
This is not particularly optimal: it means consumers end up doing this tranpilation even when they only support targets which already *do* support class fields. However, we currently have to do this to support the ecosystem unless or until we fix (or fork) the Babel decorators legacy transform since it [injects a function which errors at runtime if it ever sees a class field][1] [1]: https://github.com/babel/babel/blob/ad17fe1cceadd4df4bd43d3d13619bb349fc7d8a/packages/babel-plugin-proposal-decorators/src/transformer-legacy.ts#L155
This is bad, I feel bad. There is no way to enable parser support for private methods in this version of eslint, and we can't update eslint versions unless we drop node version support (requiring a major release).
64e00a6 to
3b5bf21
Compare


Starts by introducing a failing test case for #423, #425. Will also introduce more, and hopefully will fix this. Wheeeeeee.
Current working theory, based on reading the code for the Babel decorators plugin: we must actively, manually supply all the class properties (including private class properties and methods) plugins to make sure it works, since we're manually opting ourselves into decorators support.
If that's true, our fix will look like: