rollup-plugin-commonjs
Advanced tools
Comparing version 3.0.2 to 3.1.0
# rollup-plugin-commonjs changelog | ||
## 3.1.0 | ||
* Replace `typeof require` with `'function'` ([#38](https://github.com/rollup/rollup-plugin-commonjs/issues/38)) | ||
* Don't attempt to resolve entry file relative to importer ([#63](https://github.com/rollup/rollup-plugin-commonjs/issues/63)) | ||
## 3.0.2 | ||
@@ -4,0 +9,0 @@ |
@@ -118,5 +118,4 @@ 'use strict'; | ||
if ( importee === HELPERS_ID ) return importee; | ||
if ( importee[0] !== '.' || !importer ) return; // not our problem | ||
if ( importee[0] !== '.' ) return; // not our problem | ||
var resolved = path.resolve( path.dirname( importer ), importee ); | ||
@@ -206,2 +205,12 @@ var candidates = getCandidates( resolved, extensions ); | ||
// To allow consumption of UMD modules, transform `typeof require` to `'function'` | ||
if ( node.type === 'UnaryExpression' && node.operator === 'typeof' && node.argument.type === 'Identifier' ) { | ||
var name$1 = node.argument.name; | ||
if ( name$1 === 'require' && !scope.contains( name$1 ) ) { | ||
magicString.overwrite( node.start, node.end, "'function'" ); | ||
return; | ||
} | ||
} | ||
if ( node.type === 'Identifier' ) { | ||
@@ -208,0 +217,0 @@ if ( ( node.name in uses ) && isReference( node, parent ) && !scope.contains( node.name ) ) { |
@@ -114,5 +114,4 @@ import { statSync } from 'fs'; | ||
if ( importee === HELPERS_ID ) return importee; | ||
if ( importee[0] !== '.' || !importer ) return; // not our problem | ||
if ( importee[0] !== '.' ) return; // not our problem | ||
var resolved = resolve( dirname( importer ), importee ); | ||
@@ -202,2 +201,12 @@ var candidates = getCandidates( resolved, extensions ); | ||
// To allow consumption of UMD modules, transform `typeof require` to `'function'` | ||
if ( node.type === 'UnaryExpression' && node.operator === 'typeof' && node.argument.type === 'Identifier' ) { | ||
var name$1 = node.argument.name; | ||
if ( name$1 === 'require' && !scope.contains( name$1 ) ) { | ||
magicString.overwrite( node.start, node.end, "'function'" ); | ||
return; | ||
} | ||
} | ||
if ( node.type === 'Identifier' ) { | ||
@@ -204,0 +213,0 @@ if ( ( node.name in uses ) && isReference( node, parent ) && !scope.contains( node.name ) ) { |
{ | ||
"name": "rollup-plugin-commonjs", | ||
"version": "3.0.2", | ||
"version": "3.1.0", | ||
"description": "Convert CommonJS modules to ES2015", | ||
@@ -32,3 +32,3 @@ "devDependencies": { | ||
"resolve": "^1.1.7", | ||
"rollup-pluginutils": "^1.5.0" | ||
"rollup-pluginutils": "^1.5.1" | ||
}, | ||
@@ -35,0 +35,0 @@ "repository": { |
@@ -84,5 +84,4 @@ import { statSync } from 'fs'; | ||
if ( importee === HELPERS_ID ) return importee; | ||
if ( importee[0] !== '.' || !importer ) return; // not our problem | ||
if ( importee[0] !== '.' ) return; // not our problem | ||
const resolved = resolve( dirname( importer ), importee ); | ||
@@ -172,2 +171,12 @@ const candidates = getCandidates( resolved, extensions ); | ||
// To allow consumption of UMD modules, transform `typeof require` to `'function'` | ||
if ( node.type === 'UnaryExpression' && node.operator === 'typeof' && node.argument.type === 'Identifier' ) { | ||
const name = node.argument.name; | ||
if ( name === 'require' && !scope.contains( name ) ) { | ||
magicString.overwrite( node.start, node.end, `'function'` ); | ||
return; | ||
} | ||
} | ||
if ( node.type === 'Identifier' ) { | ||
@@ -174,0 +183,0 @@ if ( ( node.name in uses ) && isReference( node, parent ) && !scope.contains( node.name ) ) { |
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
33328
687
Updatedrollup-pluginutils@^1.5.1