rollup-plugin-commonjs
Advanced tools
Comparing version 2.1.0 to 2.2.0
# rollup-plugin-commonjs changelog | ||
## 2.2.0 | ||
* Rewrite top-level `this` expressions to mean the same as `global` ([#31](https://github.com/rollup/rollup-plugin-commonjs/issues/31)) | ||
## 2.1.0 | ||
@@ -4,0 +8,0 @@ |
@@ -145,5 +145,8 @@ 'use strict'; | ||
var scopeDepth = 0; | ||
estreeWalker.walk(ast, { | ||
enter: function enter(node, parent) { | ||
if (node.scope) scope = node.scope; | ||
if (/^Function/.test(node.type)) scopeDepth += 1; | ||
@@ -185,2 +188,8 @@ if (sourceMap) { | ||
if (node.type === 'ThisExpression' && scopeDepth === 0) { | ||
uses.global = true; | ||
magicString.overwrite(node.start, node.end, '__commonjs_global', true); | ||
return; | ||
} | ||
if (node.type !== 'CallExpression') return; | ||
@@ -212,2 +221,3 @@ if (node.callee.name !== 'require' || scope.contains('require')) return; | ||
if (node.scope) scope = scope.parent; | ||
if (/^Function/.test(node.type)) scopeDepth -= 1; | ||
} | ||
@@ -214,0 +224,0 @@ }); |
@@ -141,5 +141,8 @@ import { statSync } from 'fs'; | ||
var scopeDepth = 0; | ||
walk(ast, { | ||
enter: function enter(node, parent) { | ||
if (node.scope) scope = node.scope; | ||
if (/^Function/.test(node.type)) scopeDepth += 1; | ||
@@ -181,2 +184,8 @@ if (sourceMap) { | ||
if (node.type === 'ThisExpression' && scopeDepth === 0) { | ||
uses.global = true; | ||
magicString.overwrite(node.start, node.end, '__commonjs_global', true); | ||
return; | ||
} | ||
if (node.type !== 'CallExpression') return; | ||
@@ -208,2 +217,3 @@ if (node.callee.name !== 'require' || scope.contains('require')) return; | ||
if (node.scope) scope = scope.parent; | ||
if (/^Function/.test(node.type)) scopeDepth -= 1; | ||
} | ||
@@ -210,0 +220,0 @@ }); |
{ | ||
"name": "rollup-plugin-commonjs", | ||
"version": "2.1.0", | ||
"version": "2.2.0", | ||
"description": "Convert CommonJS modules to ES2015", | ||
@@ -5,0 +5,0 @@ "devDependencies": { |
@@ -107,5 +107,8 @@ import { statSync } from 'fs'; | ||
let scopeDepth = 0; | ||
walk( ast, { | ||
enter ( node, parent ) { | ||
if ( node.scope ) scope = node.scope; | ||
if ( /^Function/.test( node.type ) ) scopeDepth += 1; | ||
@@ -147,2 +150,8 @@ if ( sourceMap ) { | ||
if ( node.type === 'ThisExpression' && scopeDepth === 0 ) { | ||
uses.global = true; | ||
magicString.overwrite( node.start, node.end, `__commonjs_global`, true ); | ||
return; | ||
} | ||
if ( node.type !== 'CallExpression' ) return; | ||
@@ -175,2 +184,3 @@ if ( node.callee.name !== 'require' || scope.contains( 'require' ) ) return; | ||
if ( node.scope ) scope = scope.parent; | ||
if ( /^Function/.test( node.type ) ) scopeDepth -= 1; | ||
} | ||
@@ -177,0 +187,0 @@ }); |
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
31401
632