Strip location information from import remaps
Fixes https://phabricator.babeljs.io/T6851
This commit is contained in:
parent
94e7e4da8e
commit
3791491b79
@ -330,7 +330,7 @@ export default function () {
|
||||
]));
|
||||
}
|
||||
}
|
||||
remaps[specifier.local.name] = t.memberExpression(target, specifier.imported);
|
||||
remaps[specifier.local.name] = t.memberExpression(target, t.cloneWithoutLoc(specifier.imported));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
@ -26,8 +26,8 @@ var _foo5 = require("foo5");
|
||||
exports. /*after*/test = test;
|
||||
var test = /*before*/exports. /*after*/test = 5;
|
||||
|
||||
/*before*/(0, _foo4. /*after*/bar)( /*before*/_foo2.default) /*after*/;
|
||||
/*before*/(0, _foo4.bar)(_foo2.default) /*after*/;
|
||||
|
||||
/* my comment */
|
||||
/*before*/_foo5. /*after*/foo;
|
||||
/*before*/_foo5.foo; /*after*/
|
||||
/*before*/_foo2.default; /*after*/
|
||||
|
||||
@ -6,3 +6,4 @@ import * as foo4 from "foo";
|
||||
foo;
|
||||
foo2;
|
||||
foo3;
|
||||
foo3();
|
||||
|
||||
@ -4,4 +4,5 @@ var _foo = require("foo");
|
||||
|
||||
_foo.default;
|
||||
_foo.default;
|
||||
_foo.foo3;
|
||||
_foo.foo3;
|
||||
(0, _foo.foo3)();
|
||||
|
||||
@ -0,0 +1,43 @@
|
||||
[{
|
||||
"original": {
|
||||
"line": 6, "column": 0
|
||||
},
|
||||
"generated": {
|
||||
"line": 5, "column": 0
|
||||
}
|
||||
},{
|
||||
"original": {
|
||||
"line": 6, "column": 0
|
||||
},
|
||||
"generated": {
|
||||
"line": 5, "column": 12
|
||||
}
|
||||
},{
|
||||
"original": {
|
||||
"line": 8, "column": 0
|
||||
},
|
||||
"generated": {
|
||||
"line": 7, "column": 0
|
||||
}
|
||||
},{
|
||||
"original": {
|
||||
"line": 8, "column": 0
|
||||
},
|
||||
"generated": {
|
||||
"line": 7, "column": 9
|
||||
}
|
||||
},{
|
||||
"original": {
|
||||
"line": 9, "column": 0
|
||||
},
|
||||
"generated": {
|
||||
"line": 8, "column": 0
|
||||
}
|
||||
},{
|
||||
"original": {
|
||||
"line": 9, "column": 0
|
||||
},
|
||||
"generated": {
|
||||
"line": 8, "column": 9
|
||||
}
|
||||
}]
|
||||
@ -239,6 +239,16 @@ export function clone(node: Object): Object {
|
||||
return newNode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a shallow clone of a `node` excluding `_private` and location properties.
|
||||
*/
|
||||
|
||||
export function cloneWithoutLoc(node: Object): Object {
|
||||
let newNode = clone(node);
|
||||
delete newNode.loc;
|
||||
return newNode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a deep clone of a `node` and all of it's child nodes
|
||||
* exluding `_private` properties.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user