fix esModule error for realsies now
This commit is contained in:
parent
f1d42e7beb
commit
2c197a508d
@ -438,10 +438,10 @@ export default class File {
|
||||
|
||||
errorWithNode(node, msg, Error = SyntaxError) {
|
||||
var err;
|
||||
if (node && node.loc) {
|
||||
var loc = node.loc.start;
|
||||
err = new Error(`Line ${loc.line}: ${msg}`);
|
||||
err.loc = loc;
|
||||
var loc = node && (node.loc || node._loc);
|
||||
if (loc) {
|
||||
err = new Error(`Line ${loc.start.line}: ${msg}`);
|
||||
err.loc = loc.start;
|
||||
} else {
|
||||
// todo: find errors with nodes inside to at least point to something
|
||||
err = new Error("There's been an error on a dynamic node. This is almost certainly an internal error. Please report it.");
|
||||
|
||||
@ -23,7 +23,13 @@ function getDeclar(node) {
|
||||
*/
|
||||
|
||||
function buildExportSpecifier(id) {
|
||||
return t.exportSpecifier(t.identifier(id.name), t.identifier(id.name));
|
||||
return t.exportSpecifier(cloneIdentifier(id), cloneIdentifier(id));
|
||||
}
|
||||
|
||||
function cloneIdentifier({ name, loc }) {
|
||||
var id = t.identifier(name);
|
||||
id._loc = loc;
|
||||
return id;
|
||||
}
|
||||
|
||||
export var metadata = {
|
||||
@ -84,13 +90,9 @@ export var visitor = {
|
||||
return nodes;
|
||||
} else if (t.isFunctionDeclaration(declar)) {
|
||||
// export function Foo() {}
|
||||
|
||||
let nodes = [
|
||||
getDeclar(node),
|
||||
t.exportNamedDeclaration(null, [buildExportSpecifier(declar.id)])
|
||||
];
|
||||
nodes[1]._blockHoist = 2; // ensure it's hoisted
|
||||
return nodes;
|
||||
var newExport = t.exportNamedDeclaration(null, [buildExportSpecifier(declar.id)]);
|
||||
newExport._blockHoist = 2;
|
||||
return [getDeclar(node), newExport];
|
||||
} else if (t.isVariableDeclaration(declar)) {
|
||||
// export var foo = "bar";
|
||||
var specifiers = [];
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user