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.6.3 to 0.6.4

11

lib/analyzer.js

@@ -187,2 +187,11 @@ const {walk} = require("estree-walker");

function analyzeThisExpression() {
if (context.scope) {
const fnNode = context.scope.findFunction();
if (fnNode) {
fnNode.containThis = true;
}
}
}
function analyze() {

@@ -238,2 +247,4 @@ walk(context.ast, {

analyzeNestedExports(node);
} else if (node.type === "ThisExpression") {
analyzeThisExpression();
}

@@ -240,0 +251,0 @@ if (!context.nested && !context.topLevel.isTop()) {

1

lib/export-writer.js

@@ -96,2 +96,3 @@ function createExportWriter(context) {

context.hasDefaultComment(node) ||
node.exported.object.properties.some(p => p.value && p.value.containThis) ||
context.isExportPreferDefault()

@@ -98,0 +99,0 @@ )

@@ -33,4 +33,5 @@ const {attachScopes} = require("rollup-pluginutils");

const rootScope = attachScopes(ast, "scope");
rootScope._node = ast;
let scope = rootScope;
return {enter, leave, has, isRootVar};
return {enter, leave, has, isRootVar, findFunction};

@@ -40,2 +41,3 @@ function enter(node) {

scope = node.scope;
scope._node = node;
}

@@ -59,2 +61,14 @@ }

}
function findFunction() {
// exclude arrow functions
let node = scope._node;
while (node) {
if (node.type === "FunctionExpression" || node.type === "FunctionDeclaration") {
return node;
}
node = node.scope.parent && node.scope.parent._node;
}
return null;
}
}

@@ -61,0 +75,0 @@

2

package.json
{
"name": "cjs-es",
"version": "0.6.3",
"version": "0.6.4",
"description": "Transform CommonJS module into ES module.",

@@ -5,0 +5,0 @@ "keywords": [

@@ -316,2 +316,6 @@ cjs-es

* 0.6.4 (Jun 6, 2019)
- Fix: export default if the object literal has function properties and the function contains `this`.
* 0.6.3 (Jun 6, 2019)

@@ -318,0 +322,0 @@

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