hoist FunctionDeclaration exports to top, possible fix for #30
This commit is contained in:
@@ -3,6 +3,8 @@ var foo2;
|
||||
var foo3;
|
||||
var foo8;
|
||||
(function () {
|
||||
exports.foo7 = foo7;
|
||||
|
||||
foo = 1;
|
||||
exports.foo = foo;
|
||||
|
||||
@@ -21,7 +23,6 @@ var foo8;
|
||||
exports.foo6 = foo6;
|
||||
|
||||
function foo7 () {}
|
||||
exports.foo7 = foo7;
|
||||
|
||||
foo8 = function () {
|
||||
function foo8() {
|
||||
|
||||
11
test/fixtures/modules/hoist-function-exports/actual.js
vendored
Normal file
11
test/fixtures/modules/hoist-function-exports/actual.js
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
import { isEven } from "./evens";
|
||||
|
||||
export function nextOdd(n) {
|
||||
return isEven(n) ? n + 1 : n + 2;
|
||||
}
|
||||
|
||||
export var isOdd = (function(isEven) {
|
||||
return function(n) {
|
||||
return !isEven(n);
|
||||
};
|
||||
})(isEven);
|
||||
13
test/fixtures/modules/hoist-function-exports/expected.js
vendored
Normal file
13
test/fixtures/modules/hoist-function-exports/expected.js
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
exports.nextOdd = nextOdd;
|
||||
|
||||
var isEven = require("./evens").isEven;
|
||||
function nextOdd(n) {
|
||||
return isEven(n) ? n + 1 : n + 2;
|
||||
}
|
||||
|
||||
var isOdd = (function(isEven) {
|
||||
return function(n) {
|
||||
return !isEven(n);
|
||||
};
|
||||
})(isEven);
|
||||
exports.isOdd = isOdd;
|
||||
Reference in New Issue
Block a user