-
Notifications
You must be signed in to change notification settings - Fork 57
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extract decorated functions as top level variables #69
Comments
I'm not sure I fully follow the details, but this seems like the type of thing that could be implemented as a separate plugin that would run before this one, if you wanted that behavior. I'm not sure it is something that this plugin would do on its own? |
I believe this is exactly what I'm attempting here :), https://www.npmjs.com/package/babel-plugin-undecorate I'm assuming the reason you'd want this is for testability of the underlying class/method (that's why I wanted it). |
Closing as this is probably solved by babel-plugin-undecorate! |
@danbovey Woah woah hey, it's not actually solved yet, it was only raised as a hypothetical solution |
@vdh As @loganfsmyth said, this issue doesn't have to be solved in this plugin, it's a little bit out of scope. I no longer need this so I haven't tested @sirrodgepodge's plugin but I assume that's the repo we can open an issue on if that doesn't solve this feature request. |
@danbovey The problematic code is directly created by this babel plugin. Relying on yet another plugin to make further changes over the top of how it already behaves is an unstable attempt at solving the code generation issue. |
OK, reopening to be looked at by @loganfsmyth |
Could we get an option in
.babelrc
to extract each decorated function individually as it's own variable. Reason being is that react-hot-loader requires the OG decorated function (react component) to be its own top level variable. See their docs for the full explanation.Currently this plugin transforms decorators to something like this:
But with a
"topLevel": true
plugin option in.babelrc
(just in development env section in my case), this plugin could transform decorators like this:Would this be possible?
The text was updated successfully, but these errors were encountered: