Socket
Socket
Sign inDemoInstall

cjs-es

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cjs-es - npm Package Compare versions

Comparing version 0.4.0 to 0.4.1

10

lib/analyzer.js

@@ -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)

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc