Test and fix export statement sourcemap

This commit is contained in:
Amjad Masad 2016-03-08 13:47:02 -08:00
parent 108838c66c
commit 46ebd90acb
2 changed files with 14 additions and 3 deletions

View File

@ -184,7 +184,9 @@ export default function () {
// Copy location from the original import statement for sourcemap // Copy location from the original import statement for sourcemap
// generation. // generation.
if (imports[source]) {
varDecl.loc = imports[source].loc; varDecl.loc = imports[source].loc;
}
if (typeof blockHoist === "number" && blockHoist > 0) { if (typeof blockHoist === "number" && blockHoist > 0) {
varDecl._blockHoist = blockHoist; varDecl._blockHoist = blockHoist;
@ -338,9 +340,11 @@ export default function () {
path.replaceWithMultiple(nodes); path.replaceWithMultiple(nodes);
} }
} else if (path.isExportAllDeclaration()) { } else if (path.isExportAllDeclaration()) {
topNodes.push(buildExportAll({ let exportNode = buildExportAll({
OBJECT: addRequire(path.node.source.value, path.node._blockHoist) OBJECT: addRequire(path.node.source.value, path.node._blockHoist)
})); });
exportNode.loc = path.node.loc;
topNodes.push(exportNode);
path.remove(); path.remove();
} }
} }

View File

@ -7,6 +7,13 @@ var tests = [
'import {bar2, baz} from "foo";', 'import {bar2, baz} from "foo";',
'import {bar as baz2} from "foo";', 'import {bar as baz2} from "foo";',
'import {bar as baz3, xyz} from "foo";', 'import {bar as baz3, xyz} from "foo";',
'export default 42;',
'export {foo};',
'export { foo as default };',
'export * from "foo";',
'export {foo} from "foo";',
'export {default as foo} from "foo";',
]; ];
tests.forEach(function (code) { tests.forEach(function (code) {