-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Comments
You will need a transformation for decorators if you use decorators. I
doubt babel 7 supports it OOTB but didn't verify
Op wo 7 feb. 2018 om 10:39 schreef Stian Håklev <notifications@github.com>:
… Has anyone gotten MobX to work with Babel 7 yet? I switched from
babel-plugin-transform-decorators-legacy to , and I get no errors, but
also no reactivity (actions happen, but React components are not redrawn
unless I force a redraw)...
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#1345>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABvGhBbqzhGxsUDGCJ_eQ8ZQVW_aaKdnks5tSW9SgaJpZM4R8Z2I>
.
|
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! |
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 |
We need to investigate further, but for now please use the legacy plugin
instead of the proposal plugin. That should afaik also work with babel 7.
Op wo 7 feb. 2018 16:28 schreef Stian Håklev <notifications@github.com>:
… 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
<https://github.com/computed> decorator.
If you look at this example repo
<https://github.com/houshuang/meteor-crash-babel-repro> (you need Meteor
to run it), I have a very simple Mobx store/component in imports/ajs
<https://github.com/houshuang/meteor-crash-babel-repro/blob/master/imports/ajs>
.
I then compiled this with Babel manually, twice - once with Babel 6 (this
file
<https://github.com/houshuang/meteor-crash-babel-repro/blob/master/imports/b.js>)
and once with Babel 7 (this file
<https://github.com/houshuang/meteor-crash-babel-repro/blob/master/imports/a.js>).
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
<https://github.com/mweststrate>
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1345 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ABvGhJcgi7WmvskonWt3D7dHpeDk-K4Aks5tScEFgaJpZM4R8Z2I>
.
|
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 |
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. |
...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. |
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. |
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)...
The text was updated successfully, but these errors were encountered: