Skip to content

Commit

Permalink
refactor: simplify branch conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
JLHwung committed Sep 25, 2020
1 parent af612db commit 86738ad
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions packages/babel-plugin-transform-modules-systemjs/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -390,27 +390,28 @@ export default declare((api, options) => {

for (const specifier of specifiers) {
const binding = scope.getBinding(specifier.local.name);
// hoisted function export
if (
binding &&
t.isFunctionDeclaration(binding.path.node)
) {
exportNames.push(specifier.exported.name);
exportValues.push(t.cloneNode(specifier.local));
}
// only globals also exported this way
else if (!binding) {
if (binding) {
// hoisted function export
const bindingPath = binding.path;
if (bindingPath.isFunctionDeclaration()) {
exportNames.push(specifier.exported.name);
exportValues.push(t.cloneNode(specifier.local));
} else {
// the exportNames will be later added in hoistVariables
addExportName(
specifier.local.name,
specifier.exported.name,
);
}
} else {
// only globals also exported this way
nodes.push(
buildExportCall(
specifier.exported.name,
specifier.local,
),
);
}
addExportName(
specifier.local.name,
specifier.exported.name,
);
}

path.replaceWithMultiple(nodes);
Expand Down

0 comments on commit 86738ad

Please sign in to comment.