Comparing version 0.4.0 to 0.4.1
@@ -45,6 +45,10 @@ const {walk} = require("estree-walker"); | ||
function analyzeAssignExport(node) { | ||
const exported = getExportInfo(node); | ||
if (node.expression.type !== "AssignmentExpression") { | ||
return; | ||
} | ||
const exported = getExportInfo(node.expression); | ||
if (!exported) { | ||
return; | ||
} | ||
exported.statement = node; | ||
exported.leftMost.exported = exported; | ||
@@ -57,3 +61,3 @@ exported.leftMost.rootPos = context.topLevel.get().start; | ||
} | ||
node.left.shouldSkip = true; | ||
node.expression.left.shouldSkip = true; | ||
} | ||
@@ -147,3 +151,3 @@ | ||
analyzeDeclareExport(node); | ||
} else if (node.type === "AssignmentExpression" && context.topLevel.isTopChild()) { | ||
} else if (node.type === "ExpressionStatement" && context.topLevel.isTop()) { | ||
analyzeAssignExport(node); | ||
@@ -150,0 +154,0 @@ } else if (node.type === "CallExpression") { |
@@ -103,4 +103,3 @@ function createExportWriter(context) { | ||
properties[i], | ||
i > 0, | ||
i < properties.length - 1 | ||
i > 0 | ||
); | ||
@@ -110,6 +109,6 @@ start = properties[i].value.end; | ||
// , ... } | ||
context.s.remove(start, node.exported.value.end); | ||
context.s.remove(start, node.exported.statement.end); | ||
} | ||
function writeProperty(start, property, newLine, semi) { | ||
function writeProperty(start, property, newLine) { | ||
if (newLine) { | ||
@@ -144,5 +143,3 @@ context.s.appendLeft(start, "\n"); | ||
} | ||
if (semi) { | ||
context.s.appendLeft(property.value.end, ";"); | ||
} | ||
context.s.appendLeft(property.value.end, ";"); | ||
} | ||
@@ -176,5 +173,6 @@ | ||
); | ||
context.s.appendLeft( | ||
context.s.overwrite( | ||
node.exported.value.end, | ||
`;\nexport {_export_${node.exported.name}_ as ${node.exported.name}}` | ||
node.exported.statement.end, | ||
`;\nexport {_export_${node.exported.name}_ as ${node.exported.name}};` | ||
); | ||
@@ -188,5 +186,6 @@ } else { | ||
); | ||
context.s.appendLeft( | ||
context.s.overwrite( | ||
node.exported.value.end, | ||
`${node.exported.value.name !== node.exported.name ? ` as ${node.exported.name}` : ""}}` | ||
node.exported.statement.end, | ||
`${node.exported.value.name !== node.exported.name ? ` as ${node.exported.name}` : ""}};` | ||
); | ||
@@ -193,0 +192,0 @@ } |
{ | ||
"name": "cjs-es", | ||
"version": "0.4.0", | ||
"version": "0.4.1", | ||
"description": "Transform CommonJS module into ES module.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -5,3 +5,2 @@ cjs-es | ||
[![Build Status](https://travis-ci.org/eight04/cjs-es.svg?branch=master)](https://travis-ci.org/eight04/cjs-es) | ||
[![Coverage Status](https://coveralls.io/repos/github/eight04/cjs-es/badge.svg?branch=master)](https://coveralls.io/github/eight04/cjs-es?branch=master) | ||
@@ -234,8 +233,13 @@ | ||
* 0.4.1 (Apr 30, 2018) | ||
- Fix: syntax error if exported value is enclosed by parentheses. | ||
* 0.4.0 (Apr 30, 2018) | ||
- Rewrite for async. `options.importStyle` and `options.exportStyle` are async now. | ||
- **Change: `transform` function is async now.** | ||
- **Drop: `options.hoist`, `options.dynamicImport`.** | ||
- Add: `options.nested`. | ||
- Fix: namespace is not callable. | ||
- **Drop: `options.hoist`, `options.dynamicImport`.** | ||
@@ -242,0 +246,0 @@ * 0.3.3 (Apr 29, 2018) |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
33687
835
283
0