-
-
Notifications
You must be signed in to change notification settings - Fork 27k
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
Enable loose mode for class-properties
#4248
Conversation
Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need the corporate CLA signed. If you have received this in error or have any questions, please contact us at [email protected]. Thanks! |
My first thought is we want to be closer to the spec, not further from it. |
I agree with @gaearon here, while it's unfortunate that this is now broken, it resulted from the ecosystem becoming closer in-line with the language specification. I'm pretty sure our hands are tied here until mobxjs/mobx#1352 is resolved. Can you point us to the code that broke because of this change? As in what specific file/line(s) that were dependent on the old behavior. |
Ah, running this in a browser with support for class properties (like Chrome Canary) also shows the errant behavior: https://plnkr.co/edit/dXlXUaZ0uDOSk0FUaOqm?p=preview. Yeah, this is a MobX issue. Sadly, projects using |
I'll go ahead and close this. Thanks for the quick responses! 💃 |
Seems like it would be good to report to MobX that the way they're promoting the usage of |
I thought about this more and I’m not so confident now. |
@rgrochowicz Can you please resubmit this PR? |
I've reopened this PR, if that works for you. |
@@ -92,7 +92,14 @@ module.exports = function(api, opts) { | |||
// don't work without it: https://github.com/babel/babel/issues/7215 | |||
require('@babel/plugin-transform-destructuring').default, | |||
// class { handleClick = () => { } } | |||
require('@babel/plugin-proposal-class-properties').default, | |||
// Enable loose mode to use assignment instead of defineProperty, as some | |||
// libraries add getters and setters to prototypes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's change this to
// Enable loose mode to use assignment instead of defineProperty
// See discussion in https://github.com/facebook/create-react-app/issues/4263
We also need something to ensure that the transform will be applied even if people target browsers that ship with it (latest Chrome)? |
Are you referring to a test case? |
Oh I guess it's still explicitly added. Never mind then. |
Enable loose mode for `class-properties` (facebook#4248)
* upstream/next: (35 commits) Update envinfo and issue template (facebook#4375) Update sass-loader to 7.0.1 (facebook#4376) Support package distribution tags (facebook#4350) fix broken css module support in prod (facebook#4361) Bumped jest version to 22.4.1 (facebook#4362) bump babel 7 to beta 46 bump lint-staged to node 10 compatible version documentation: Added License to the README.md (facebook#4294) Bump `fsevents`. (facebook#4331) Fix typo in e2e-simple.sh comment (facebook#4323) Add Sass loader (facebook#4195) Fix some typos in README.md (facebook#4286) Added learnstorybook.com to Storybook links (facebook#4298) Document multiple build environments via `env-cmd` facebook#4071 (facebook#4117) Fixed link to CSS imports blog post Update CSS Modules localIndetName (facebook#4192) Enable loose mode for `class-properties` (facebook#4248) bump babel 7 beta (facebook#4253) Small typo fix facebook#4217 Changelog for 1.1.4 ...
* next: (35 commits) Update envinfo and issue template (facebook#4375) Update sass-loader to 7.0.1 (facebook#4376) Support package distribution tags (facebook#4350) fix broken css module support in prod (facebook#4361) Bumped jest version to 22.4.1 (facebook#4362) bump babel 7 to beta 46 bump lint-staged to node 10 compatible version documentation: Added License to the README.md (facebook#4294) Bump `fsevents`. (facebook#4331) Fix typo in e2e-simple.sh comment (facebook#4323) Add Sass loader (facebook#4195) Fix some typos in README.md (facebook#4286) Added learnstorybook.com to Storybook links (facebook#4298) Document multiple build environments via `env-cmd` facebook#4071 (facebook#4117) Fixed link to CSS imports blog post Update CSS Modules localIndetName (facebook#4192) Enable loose mode for `class-properties` (facebook#4248) bump babel 7 beta (facebook#4253) Small typo fix facebook#4217 Changelog for 1.1.4 ...
Copying the contents of my MobX issue:
After trying out the latest create-react-app and mobx 4's
decorate
, I found that my classes were no longer observable. At first glance, it looks like it's Babel 7's class property transform.Here's a codesandbox: https://codesandbox.io/s/623qwprm8k
I'd expect the updated value of
FooBabel7
to trigger theautorun
.Differences in babel output:
Source:
Babel 6:
Babel 7:
Enabling
loose
mode reverts the transform back to the Babel 6 behavior.Simple before/after:
Current behavior:
With
loose: true
:Original MobX issue: mobxjs/mobx#1471