rollup-plugin-commonjs
Advanced tools
Comparing version 8.2.6 to 8.3.0
# rollup-plugin-commonjs changelog | ||
## 8.3.0 | ||
* Handle multiple entry points ([#283](https://github.com/rollup/rollup-plugin-commonjs/issues/283)) | ||
* Extract named exports from exported object literals ([#272](https://github.com/rollup/rollup-plugin-commonjs/issues/272)) | ||
* Fix when `options.external` is modified by other plugins ([#264](https://github.com/rollup/rollup-plugin-commonjs/issues/264)) | ||
* Recognize static template strings in require statements ([#271](https://github.com/rollup/rollup-plugin-commonjs/issues/271)) | ||
## 8.2.4 | ||
@@ -4,0 +11,0 @@ |
@@ -7,3 +7,2 @@ 'use strict'; | ||
var path = require('path'); | ||
var resolve$1 = require('resolve'); | ||
var rollupPluginutils = require('rollup-pluginutils'); | ||
@@ -13,2 +12,3 @@ var acorn = _interopDefault(require('acorn')); | ||
var MagicString = _interopDefault(require('magic-string')); | ||
var resolve = require('resolve'); | ||
@@ -261,3 +261,3 @@ var HELPERS_ID = '\0commonjsHelpers'; | ||
if ( node.callee.name !== 'require' || scope.contains( 'require' ) ) { return; } | ||
if ( node.arguments.length !== 1 || node.arguments[0].type !== 'Literal' ) { return; } // TODO handle these weird cases? | ||
if ( node.arguments.length !== 1 || (node.arguments[0].type !== 'Literal' && (node.arguments[0].type !== 'TemplateLiteral' || node.arguments[0].expressions.length > 0) ) ) { return; } // TODO handle these weird cases? | ||
if ( ignoreRequire( node.arguments[0].value ) ) { return; } | ||
@@ -269,3 +269,3 @@ | ||
function getRequired ( node, name ) { | ||
var source = node.arguments[0].value; | ||
var source = node.arguments[0].type === 'Literal' ? node.arguments[0].value : node.arguments[0].quasis[0].value.cooked; | ||
@@ -533,6 +533,2 @@ var existing = required[ source ]; | ||
wrapperEnd = "\n});"; | ||
Object.keys( namedExports ) | ||
.filter( function (key) { return !blacklist[ key ]; } ) | ||
.forEach( addExport ); | ||
} else { | ||
@@ -571,2 +567,3 @@ var names = []; | ||
}); | ||
delete namedExports[name]; | ||
} | ||
@@ -588,2 +585,5 @@ | ||
} | ||
Object.keys( namedExports ) | ||
.filter( function (key) { return !blacklist[ key ]; } ) | ||
.forEach( addExport ); | ||
@@ -661,3 +661,3 @@ var defaultExport = /__esModule/.test( code ) ? | ||
try { | ||
resolvedId = resolve$1.sync( id, { basedir: process.cwd() }); | ||
resolvedId = resolve.sync( id, { basedir: process.cwd() }); | ||
} catch ( err ) { | ||
@@ -680,4 +680,3 @@ resolvedId = path.resolve( id ); | ||
var entryModuleIdPromise = null; | ||
var entryModuleId = null; | ||
var entryModuleIdsPromise = null; | ||
@@ -738,6 +737,6 @@ function resolveId ( importee, importer ) { | ||
var isExternal = options$1.external ? | ||
Array.isArray( options$1.external ) ? function (id) { return ~options$1.external.indexOf( id ); } : | ||
options$1.external : | ||
function () { return false; }; | ||
var isExternal = function (id) { return options$1.external ? | ||
Array.isArray( options$1.external ) ? ~options$1.external.indexOf( id ) : | ||
options$1.external(id) : | ||
false; }; | ||
@@ -748,5 +747,6 @@ resolvers.unshift( function (id) { return isExternal( id ) ? false : null; } ); | ||
entryModuleIdPromise = resolveId( options$1.input || options$1.entry ).then( function (resolved) { | ||
entryModuleId = resolved; | ||
}); | ||
var entryModules = [].concat( options$1.input || options$1.entry ); | ||
entryModuleIdsPromise = Promise.all( | ||
entryModules.map( function (entry) { return resolveId( entry ); }) | ||
); | ||
}, | ||
@@ -784,3 +784,3 @@ | ||
return entryModuleIdPromise.then( function () { | ||
return entryModuleIdsPromise.then( function (entryModuleIds) { | ||
var ref = checkEsModule( code, id ); | ||
@@ -802,3 +802,3 @@ var isEsModule = ref.isEsModule; | ||
var transformed = transformCommonjs( code, id, id === entryModuleId, ignoreGlobal, ignoreRequire, customNamedExports[ id ], sourceMap, allowDynamicRequire, ast ); | ||
var transformed = transformCommonjs( code, id, entryModuleIds.indexOf(id) !== -1, ignoreGlobal, ignoreRequire, customNamedExports[ id ], sourceMap, allowDynamicRequire, ast ); | ||
if ( !transformed ) { return; } | ||
@@ -805,0 +805,0 @@ |
import { statSync } from 'fs'; | ||
import { basename, dirname, extname, resolve, sep } from 'path'; | ||
import { sync } from 'resolve'; | ||
import { attachScopes, createFilter, makeLegalIdentifier } from 'rollup-pluginutils'; | ||
import { dirname, resolve, basename, extname, sep } from 'path'; | ||
import { makeLegalIdentifier, attachScopes, createFilter } from 'rollup-pluginutils'; | ||
import acorn from 'acorn'; | ||
import { walk } from 'estree-walker'; | ||
import MagicString from 'magic-string'; | ||
import { sync } from 'resolve'; | ||
@@ -36,4 +36,4 @@ var HELPERS_ID = '\0commonjsHelpers'; | ||
function isAbsolute ( path$$1 ) { | ||
return absolutePath.test( path$$1 ); | ||
function isAbsolute ( path ) { | ||
return absolutePath.test( path ); | ||
} | ||
@@ -256,3 +256,3 @@ | ||
if ( node.callee.name !== 'require' || scope.contains( 'require' ) ) { return; } | ||
if ( node.arguments.length !== 1 || node.arguments[0].type !== 'Literal' ) { return; } // TODO handle these weird cases? | ||
if ( node.arguments.length !== 1 || (node.arguments[0].type !== 'Literal' && (node.arguments[0].type !== 'TemplateLiteral' || node.arguments[0].expressions.length > 0) ) ) { return; } // TODO handle these weird cases? | ||
if ( ignoreRequire( node.arguments[0].value ) ) { return; } | ||
@@ -264,3 +264,3 @@ | ||
function getRequired ( node, name ) { | ||
var source = node.arguments[0].value; | ||
var source = node.arguments[0].type === 'Literal' ? node.arguments[0].value : node.arguments[0].quasis[0].value.cooked; | ||
@@ -528,6 +528,2 @@ var existing = required[ source ]; | ||
wrapperEnd = "\n});"; | ||
Object.keys( namedExports ) | ||
.filter( function (key) { return !blacklist[ key ]; } ) | ||
.forEach( addExport ); | ||
} else { | ||
@@ -566,2 +562,3 @@ var names = []; | ||
}); | ||
delete namedExports[name]; | ||
} | ||
@@ -583,2 +580,5 @@ | ||
} | ||
Object.keys( namedExports ) | ||
.filter( function (key) { return !blacklist[ key ]; } ) | ||
.forEach( addExport ); | ||
@@ -674,4 +674,3 @@ var defaultExport = /__esModule/.test( code ) ? | ||
var entryModuleIdPromise = null; | ||
var entryModuleId = null; | ||
var entryModuleIdsPromise = null; | ||
@@ -732,6 +731,6 @@ function resolveId ( importee, importer ) { | ||
var isExternal = options$1.external ? | ||
Array.isArray( options$1.external ) ? function (id) { return ~options$1.external.indexOf( id ); } : | ||
options$1.external : | ||
function () { return false; }; | ||
var isExternal = function (id) { return options$1.external ? | ||
Array.isArray( options$1.external ) ? ~options$1.external.indexOf( id ) : | ||
options$1.external(id) : | ||
false; }; | ||
@@ -742,5 +741,6 @@ resolvers.unshift( function (id) { return isExternal( id ) ? false : null; } ); | ||
entryModuleIdPromise = resolveId( options$1.input || options$1.entry ).then( function (resolved) { | ||
entryModuleId = resolved; | ||
}); | ||
var entryModules = [].concat( options$1.input || options$1.entry ); | ||
entryModuleIdsPromise = Promise.all( | ||
entryModules.map( function (entry) { return resolveId( entry ); }) | ||
); | ||
}, | ||
@@ -778,3 +778,3 @@ | ||
return entryModuleIdPromise.then( function () { | ||
return entryModuleIdsPromise.then( function (entryModuleIds) { | ||
var ref = checkEsModule( code, id ); | ||
@@ -796,3 +796,3 @@ var isEsModule = ref.isEsModule; | ||
var transformed = transformCommonjs( code, id, id === entryModuleId, ignoreGlobal, ignoreRequire, customNamedExports[ id ], sourceMap, allowDynamicRequire, ast ); | ||
var transformed = transformCommonjs( code, id, entryModuleIds.indexOf(id) !== -1, ignoreGlobal, ignoreRequire, customNamedExports[ id ], sourceMap, allowDynamicRequire, ast ); | ||
if ( !transformed ) { return; } | ||
@@ -799,0 +799,0 @@ |
{ | ||
"name": "rollup-plugin-commonjs", | ||
"version": "8.2.6", | ||
"version": "8.3.0", | ||
"description": "Convert CommonJS modules to ES2015", | ||
@@ -35,3 +35,3 @@ "main": "dist/rollup-plugin-commonjs.cjs.js", | ||
"require-relative": "^0.8.7", | ||
"rollup": "^0.50.0", | ||
"rollup": "^0.55.0", | ||
"rollup-plugin-buble": "^0.16.0", | ||
@@ -38,0 +38,0 @@ "rollup-plugin-node-resolve": "^3.0.0", |
@@ -70,4 +70,3 @@ import { statSync } from 'fs'; | ||
let entryModuleIdPromise = null; | ||
let entryModuleId = null; | ||
let entryModuleIdsPromise = null; | ||
@@ -128,6 +127,6 @@ function resolveId ( importee, importer ) { | ||
const isExternal = options.external ? | ||
Array.isArray( options.external ) ? id => ~options.external.indexOf( id ) : | ||
options.external : | ||
() => false; | ||
const isExternal = id => options.external ? | ||
Array.isArray( options.external ) ? ~options.external.indexOf( id ) : | ||
options.external(id) : | ||
false; | ||
@@ -138,5 +137,6 @@ resolvers.unshift( id => isExternal( id ) ? false : null ); | ||
entryModuleIdPromise = resolveId( options.input || options.entry ).then( resolved => { | ||
entryModuleId = resolved; | ||
}); | ||
const entryModules = [].concat( options.input || options.entry ); | ||
entryModuleIdsPromise = Promise.all( | ||
entryModules.map( entry => resolveId( entry )) | ||
); | ||
}, | ||
@@ -174,3 +174,3 @@ | ||
return entryModuleIdPromise.then( () => { | ||
return entryModuleIdsPromise.then( (entryModuleIds) => { | ||
const {isEsModule, hasDefaultExport, ast} = checkEsModule( code, id ); | ||
@@ -189,3 +189,3 @@ if ( isEsModule ) { | ||
const transformed = transformCommonjs( code, id, id === entryModuleId, ignoreGlobal, ignoreRequire, customNamedExports[ id ], sourceMap, allowDynamicRequire, ast ); | ||
const transformed = transformCommonjs( code, id, entryModuleIds.indexOf(id) !== -1, ignoreGlobal, ignoreRequire, customNamedExports[ id ], sourceMap, allowDynamicRequire, ast ); | ||
if ( !transformed ) return; | ||
@@ -192,0 +192,0 @@ |
@@ -94,3 +94,3 @@ import acorn from 'acorn'; | ||
if ( node.callee.name !== 'require' || scope.contains( 'require' ) ) return; | ||
if ( node.arguments.length !== 1 || node.arguments[0].type !== 'Literal' ) return; // TODO handle these weird cases? | ||
if ( node.arguments.length !== 1 || (node.arguments[0].type !== 'Literal' && (node.arguments[0].type !== 'TemplateLiteral' || node.arguments[0].expressions.length > 0) ) ) return; // TODO handle these weird cases? | ||
if ( ignoreRequire( node.arguments[0].value ) ) return; | ||
@@ -102,3 +102,3 @@ | ||
function getRequired ( node, name ) { | ||
const source = node.arguments[0].value; | ||
const source = node.arguments[0].type === 'Literal' ? node.arguments[0].value : node.arguments[0].quasis[0].value.cooked; | ||
@@ -364,6 +364,2 @@ const existing = required[ source ]; | ||
wrapperEnd = `\n});`; | ||
Object.keys( namedExports ) | ||
.filter( key => !blacklist[ key ] ) | ||
.forEach( addExport ); | ||
} else { | ||
@@ -402,2 +398,3 @@ const names = []; | ||
}); | ||
delete namedExports[name]; | ||
} | ||
@@ -416,2 +413,5 @@ | ||
} | ||
Object.keys( namedExports ) | ||
.filter( key => !blacklist[ key ] ) | ||
.forEach( addExport ); | ||
@@ -418,0 +418,0 @@ const defaultExport = /__esModule/.test( code ) ? |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
193649
1845