Skip to content
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

Mobx decorators working with Babel 7 @babel/plugin-proposal-decorators? #1345

Closed
houshuang opened this issue Feb 7, 2018 · 8 comments
Closed

Comments

@houshuang
Copy link

Has anyone gotten MobX to work with Babel 7 yet? I switched from babel-plugin-transform-decorators-legacy to @babel/plugin-proposal-decorators, and I get no errors, but also no reactivity (actions happen, but React components are not redrawn unless I force a redraw)...

@houshuang houshuang changed the title Mobx working with Babel 7? Mobx decorators working with Babel 7 @babel/plugin-proposal-decorators? Feb 7, 2018
@mweststrate
Copy link
Member

mweststrate commented Feb 7, 2018 via email

@houshuang
Copy link
Author

Babel 7 offers @babel/plugin-proposal-decorator, and I get no errors when I compile my code (like I would have gotten if I had not included the plugin), however there might have been small changes in how it's implemented that affects MobX - which is why I was asking if anyone else had gotten this to work.

Thanks!

@houshuang
Copy link
Author

OK, so I've narrowed this down further, and there is no doubt that there is something in Babel 7 which is interfering with @computed decorator.

If you look at this example repo (you need Meteor to run it), I have a very simple Mobx store/component in imports/ajs.

I then compiled this with Babel manually, twice - once with Babel 6 (this file) and once with Babel 7 (this file). I include both of these components on the screen. When I click on the link, the text should change (and I console log the computed value updating). With the Babel 6 compiled code, it works, with the Babel 7 compiled code, it doesn't.

I was trying to look at the compiled code to see if there were any differences, but apart from some formatting, it was very hard to tell the difference. However, hopefully this somewhat minimal example could help others look into this - I would really appreciate your help! @mweststrate

@mweststrate
Copy link
Member

mweststrate commented Feb 7, 2018 via email

@tathagatbanerjee
Copy link

I'm having similar problems - currently have parked move from Meteor 1.6.0.1 -> 1.6.1 where it moves to babel 7.

Link to issue notes in case useful: https://forums.meteor.com/t/error-updating-to-1-6-01-1-6-1-more-upgrade-errors-parked-conflict-babel7-mobx/42304/3

@mweststrate
Copy link
Member

See #1352.

In principle we are stand by to migrate to the new proposal and we follow it closely (it will greatly simplify our code!). But currently it is not usable yet, as support for class field decorators has not yet been added (which is the most relevant use case for mobx)

So for now closing in favor of #1352.

@IngwiePhoenix
Copy link

...doesn't look like this has changed yet. I can't seem to get class-level decorators to work unfortunately. Hopefuly something about this happens soon!

Also, some documentation on the plugin's usage would be great. Reading through generated code made me a little confused.

@lock
Copy link

lock bot commented Jul 21, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs or questions.

@lock lock bot locked as resolved and limited conversation to collaborators Jul 21, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants