Comparing version 3.1.1 to 3.1.2
@@ -72,3 +72,3 @@ { | ||
}, | ||
"version": "3.1.1" | ||
"version": "3.1.2" | ||
} |
@@ -350,7 +350,3 @@ import * as t from 'babel-types'; | ||
function rewriteAssignmentToDefaultExport(path: Path, module: Module) { | ||
let node = path.node; | ||
let right = path.node.expression.right; | ||
metadata(module).exports.push({ type: 'default-export', node: cleanNode(node) }); | ||
function getAssignmentEqualsEnd(node: Node, module: Module): number { | ||
let equalsToken = findToken('=', module.tokensForNode(node)); | ||
@@ -361,4 +357,13 @@ let equalsEnd = equalsToken.token.end; | ||
} | ||
module.magicString.overwrite(path.node.start, equalsEnd, 'export default '); | ||
return equalsEnd; | ||
} | ||
function rewriteAssignmentToDefaultExport(path: Path, module: Module) { | ||
let node = path.node; | ||
let right = path.node.expression.right; | ||
metadata(module).exports.push({ type: 'default-export', node: cleanNode(node) }); | ||
module.magicString.overwrite( | ||
path.node.start, getAssignmentEqualsEnd(node, module), 'export default '); | ||
path.replaceWith(t.exportDefaultDeclaration(right)); | ||
@@ -401,3 +406,3 @@ } | ||
// ^^^^^^^^^^^^^^ ^^^^^^^ | ||
module.magicString.overwrite(node.start, right.start, 'export '); | ||
module.magicString.overwrite(node.start, getAssignmentEqualsEnd(node, module), 'export '); | ||
@@ -433,3 +438,4 @@ if (!id) { | ||
isFunctionDeclaration = false; | ||
module.magicString.overwrite(node.start, right.start, `let ${localName} = `); | ||
module.magicString.overwrite( | ||
node.start, getAssignmentEqualsEnd(node, module), `let ${localName} = `); | ||
declaration = t.variableDeclaration( | ||
@@ -505,3 +511,4 @@ 'let', | ||
if (localBinding === property.name) { | ||
module.magicString.overwrite(node.start, right.start, `export let ${localBinding} = `); | ||
module.magicString.overwrite( | ||
node.start, getAssignmentEqualsEnd(node, module), `export let ${localBinding} = `); | ||
replacements = [ | ||
@@ -523,3 +530,4 @@ t.exportNamedDeclaration( | ||
} else { | ||
module.magicString.overwrite(node.start, right.start, `let ${localBinding} = `); | ||
module.magicString.overwrite( | ||
node.start, getAssignmentEqualsEnd(node, module), `let ${localBinding} = `); | ||
module.magicString.appendRight(node.end, `\nexport { ${localBinding} as ${property.name} };`); | ||
@@ -612,3 +620,4 @@ replacements = [ | ||
// ^^^^^^^^^^^^^^ ^^^^^^^^^^^^ | ||
module.magicString.overwrite(node.start, right.start, `let ${localBinding} = `); | ||
module.magicString.overwrite( | ||
node.start, getAssignmentEqualsEnd(node, module), `let ${localBinding} = `); | ||
@@ -615,0 +624,0 @@ let nodeIndex = path.parent.body.indexOf(node); |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
269982
7961