-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
using passPerPreset breaks class properties with babel 6.7 (T7274) #4230
Comments
I'm not sure there's enough here to go on. Would you be up for trying to reproduce your issue with the Babel CLI commands? From a quick glance, the code seems ok to me. |
So i just took an update to my react-native setup which seems to install babel 6.7.6 now. I cannot reproduce this error anymore. I wish i could reproduce with Babel CLI. I will try something over the weekend. |
Just took one more update and seems like babel 6.7.7 broke it again. |
Without more to go on, I'm not sure there's much more I can add. I don't know why it would have worked temporarily. |
I have a smaller repro here. .babelrc:
test.js
Output:
The really weird thing is that if I use
The relevant versions:
|
The above example is a bit less compelling because it would work correctly if I were to use If I use:
I end up with a
If I use:
I lose the
When using
|
I can confirm taion's repro case. Here's how i could repo this:
turn passPerPreset to false and it logs my name correctly and undefined when passPerPreset is set to true. cc @loganfsmyth |
I have this problem too with the simplest config: .babelrc: {
plugins: [
'babel-plugin-syntax-class-properties'
]
} Input: class Test {
onPress = () => {
console.log(this.id)
}
} Output: var _this = this;
class Test {
onPress = () => {
console.log(_this.id);
};
} |
Ok it's definetely a bug when using |
I have a plugin that adds class-properties, so I just need the syntax transform. I omitted the second and third preset for clarity. |
This does sound the same as #4337 which has a more precise description of the problem. |
BTW, for those of us hitting this issue because of Relay, it's actually not necessary to use |
…ue`) See README.md for documentation. This feature is blocked on the following Babel PRs/issues: * babel/babel#4500 * babel/babylon#121 * babel/babel#4337 * babel/babel#4230 (partially)
The I think I added it in to {
"presets": [
"node6",
"es2015",
{
"plugins": [
"./plugins/babelrelayplugin"
]
},
"react",
"react-hmre",
"stage-0"
]
}` |
when |
@yutin1987 it's just a warning not an error |
@hzoo Thanks. but will be something memory errors (ex. this.props is not defined) on runtime when have that warning. |
Going to close for inactivity, looks like relay doesn't use/recommend it anymore. Were probably going to deprecate it and change it to be a pass option in each preset rather than a global passPerPreset option anyway |
…ue`) See README.md for documentation. This feature is blocked on the following Babel PRs/issues: * babel/babel#4500 * babel/babylon#121 * babel/babel#4337 * babel/babel#4230 (partially)
…ue`) See README.md for documentation. This feature is blocked on the following Babel PRs/issues: * babel/babel#4500 * babel/babylon#121 * babel/babel#4337 * babel/babel#4230 (partially)
…ue`) See README.md for documentation. This feature is blocked on the following Babel PRs/issues: * babel/babel#4500 * babel/babylon#121 * babel/babel#4337 * babel/babel#4230 (partially)
Summary: it's actually not necessary to use passPerPreset for the Relay plugin. when `passPerPreset` is true, will show error as follow on React Native: `Note: The code generator has deoptimised the styling of "/Users/yutin/Develop/bunninn/client/mobile/node_modules/immutable/dist/immutable.js" as it exceeds the max of "100KB"` :) ref. babel/babel#4230 (comment) Closes #1424 Differential Revision: D4964341 Pulled By: leebyron fbshipit-source-id: 7e55253d7608b10a7bca5da855622605e14f0928
Bug information
Input code
Description
Doing a fresh install of react-native and adding .babelrc with passPerPresets breaks class properties. I get error like undefined is not an object evaluating
this.props.name
.I can confirm with works fine with babel 6.6.
PS: This is my first issue on babel repo and i'm not sure what the general guidelines are for posting an issue.
The text was updated successfully, but these errors were encountered: