create new export named declaration when we're splitting it up - fixes #2092
This commit is contained in:
parent
90fb36d3ea
commit
bda0d5cc68
@ -4,7 +4,6 @@
|
||||
// a generator function as a default then regenerator will destroy the export
|
||||
// declaration and leave a variable declaration in it's place... yeah, handy.
|
||||
|
||||
import clone from "lodash/lang/clone";
|
||||
import * as t from "../../../types";
|
||||
|
||||
/**
|
||||
@ -85,11 +84,12 @@ export var visitor = {
|
||||
return nodes;
|
||||
} else if (t.isFunctionDeclaration(declar)) {
|
||||
// export function Foo() {}
|
||||
node.specifiers = [buildExportSpecifier(declar.id)];
|
||||
node._blockHoist = 2;
|
||||
|
||||
let nodes = [getDeclar(node), node];
|
||||
node.declaration = null;
|
||||
let nodes = [
|
||||
getDeclar(node),
|
||||
t.exportNamedDeclaration(null, [buildExportSpecifier(declar.id)])
|
||||
];
|
||||
nodes[1]._blockHoist = 2; // ensure it's hoisted
|
||||
return nodes;
|
||||
} else if (t.isVariableDeclaration(declar)) {
|
||||
// export var foo = "bar";
|
||||
|
||||
11
packages/babel/test/fixtures/transformation/es6.modules/retain-lines/actual.js
vendored
Normal file
11
packages/babel/test/fixtures/transformation/es6.modules/retain-lines/actual.js
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
export function foo() {
|
||||
console.log(1);
|
||||
console.log(2);
|
||||
console.log(3);
|
||||
}
|
||||
|
||||
export function bar() {
|
||||
console.log(1);
|
||||
console.log(2);
|
||||
console.log(3);
|
||||
}
|
||||
10
packages/babel/test/fixtures/transformation/es6.modules/retain-lines/expected.js
vendored
Normal file
10
packages/babel/test/fixtures/transformation/es6.modules/retain-lines/expected.js
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
"use strict";export { foo };export { bar };function foo() {
|
||||
console.log(1);
|
||||
console.log(2);
|
||||
console.log(3);}
|
||||
|
||||
|
||||
function bar() {
|
||||
console.log(1);
|
||||
console.log(2);
|
||||
console.log(3);}
|
||||
3
packages/babel/test/fixtures/transformation/es6.modules/retain-lines/options.json
vendored
Normal file
3
packages/babel/test/fixtures/transformation/es6.modules/retain-lines/options.json
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"retainLines": true
|
||||
}
|
||||
@ -1,7 +1,6 @@
|
||||
"use strict";
|
||||
|
||||
export { foo };
|
||||
|
||||
export { bar };
|
||||
|
||||
function foo() {}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user