Fix PathHoister error attaching after export declarations.
Fixes #5369.
See also 4ee385e96c/packages/babel-plugin-transform-class-properties/src/index.js (L167)
This commit is contained in:
parent
60adcd68a0
commit
3570ba7c28
@ -0,0 +1,7 @@
|
||||
class A {
|
||||
render() {
|
||||
return <B />
|
||||
}
|
||||
}
|
||||
|
||||
export default class B {}
|
||||
@ -0,0 +1,9 @@
|
||||
class A {
|
||||
render() {
|
||||
return _ref;
|
||||
}
|
||||
}
|
||||
|
||||
export default class B {}
|
||||
|
||||
var _ref = React.createElement(B, null);
|
||||
@ -0,0 +1,6 @@
|
||||
{
|
||||
"plugins": [
|
||||
"transform-react-jsx",
|
||||
"transform-react-constant-elements"
|
||||
]
|
||||
}
|
||||
@ -0,0 +1,7 @@
|
||||
class A {
|
||||
render() {
|
||||
return <B />
|
||||
}
|
||||
}
|
||||
|
||||
export class B {}
|
||||
@ -0,0 +1,9 @@
|
||||
class A {
|
||||
render() {
|
||||
return _ref;
|
||||
}
|
||||
}
|
||||
|
||||
export class B {}
|
||||
|
||||
var _ref = React.createElement(B, null);
|
||||
@ -0,0 +1,6 @@
|
||||
{
|
||||
"plugins": [
|
||||
"transform-react-jsx",
|
||||
"transform-react-constant-elements"
|
||||
]
|
||||
}
|
||||
@ -117,6 +117,12 @@ export default class PathHoister {
|
||||
}
|
||||
}
|
||||
|
||||
// We can't insert before/after a child of an export declaration, so move up
|
||||
// to the declaration itself.
|
||||
if (path.parentPath.isExportDeclaration()) {
|
||||
path = path.parentPath;
|
||||
}
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user