Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

rollup-plugin-commonjs

Package Overview
Dependencies
Maintainers
4
Versions
70
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rollup-plugin-commonjs - npm Package Compare versions

Comparing version 8.4.1 to 9.0.0

6

CHANGELOG.md
# rollup-plugin-commonjs changelog
## 8.4.0
* Better handle non-CJS files that contain CJS keywords ([#285](https://github.com/rollup/rollup-plugin-commonjs/issues/285))
* Use rollup's plugin context`parse` function ([#287](https://github.com/rollup/rollup-plugin-commonjs/issues/287))
* Improve error handling ([#288](https://github.com/rollup/rollup-plugin-commonjs/issues/288))
## 8.3.0

@@ -4,0 +10,0 @@

30

dist/rollup-plugin-commonjs.cjs.js

@@ -8,3 +8,2 @@ 'use strict';

var rollupPluginutils = require('rollup-pluginutils');
var acorn = _interopDefault(require('acorn'));
var estreeWalker = require('estree-walker');

@@ -193,9 +192,5 @@ var MagicString = _interopDefault(require('magic-string'));

function tryParse ( code, id ) {
function tryParse ( parse, code, id ) {
try {
return acorn.parse( code, {
ecmaVersion: 8,
sourceType: 'module',
allowReturnOutsideFunction: true
});
return parse( code, { allowReturnOutsideFunction: true });
} catch ( err ) {

@@ -212,4 +207,4 @@ err.message += " in " + id;

function checkEsModule (code, id) {
var ast = tryParse(code, id);
function checkEsModule ( parse, code, id ) {
var ast = tryParse( parse, code, id );

@@ -231,4 +226,4 @@ // if there are top-level import/export declarations, this is ES not CommonJS

function transformCommonjs ( code, id, isEntry, ignoreGlobal, ignoreRequire, customNamedExports, sourceMap, allowDynamicRequire, astCache ) {
var ast = astCache || tryParse( code, id );
function transformCommonjs ( parse, code, id, isEntry, ignoreGlobal, ignoreRequire, customNamedExports, sourceMap, allowDynamicRequire, astCache ) {
var ast = astCache || tryParse( parse, code, id );

@@ -774,2 +769,4 @@ var magicString = new MagicString( code );

transform: function transform ( code, id ) {
var this$1 = this;
if ( !filter( id ) ) { return null; }

@@ -779,3 +776,3 @@ if ( extensions.indexOf( path.extname( id ) ) === -1 ) { return null; }

return entryModuleIdsPromise.then( function (entryModuleIds) {
var ref = checkEsModule( code, id );
var ref = checkEsModule( this$1.parse, code, id );
var isEsModule = ref.isEsModule;

@@ -796,7 +793,12 @@ var hasDefaultExport = ref.hasDefaultExport;

var transformed = transformCommonjs( code, id, entryModuleIds.indexOf(id) !== -1, ignoreGlobal, ignoreRequire, customNamedExports[ id ], sourceMap, allowDynamicRequire, ast );
if ( !transformed ) { return; }
var transformed = transformCommonjs( this$1.parse, code, id, entryModuleIds.indexOf(id) !== -1, ignoreGlobal, ignoreRequire, customNamedExports[ id ], sourceMap, allowDynamicRequire, ast );
if ( !transformed ) {
esModulesWithoutDefaultExport.push( id );
return;
}
commonjsModules.set( id, true );
return transformed;
}).catch(function (err) {
this$1.error(err, err.loc);
});

@@ -803,0 +805,0 @@ }

import { statSync } from 'fs';
import { dirname, resolve, basename, extname, sep } from 'path';
import { makeLegalIdentifier, attachScopes, createFilter } from 'rollup-pluginutils';
import acorn from 'acorn';
import { walk } from 'estree-walker';

@@ -188,9 +187,5 @@ import MagicString from 'magic-string';

function tryParse ( code, id ) {
function tryParse ( parse, code, id ) {
try {
return acorn.parse( code, {
ecmaVersion: 8,
sourceType: 'module',
allowReturnOutsideFunction: true
});
return parse( code, { allowReturnOutsideFunction: true });
} catch ( err ) {

@@ -207,4 +202,4 @@ err.message += " in " + id;

function checkEsModule (code, id) {
var ast = tryParse(code, id);
function checkEsModule ( parse, code, id ) {
var ast = tryParse( parse, code, id );

@@ -226,4 +221,4 @@ // if there are top-level import/export declarations, this is ES not CommonJS

function transformCommonjs ( code, id, isEntry, ignoreGlobal, ignoreRequire, customNamedExports, sourceMap, allowDynamicRequire, astCache ) {
var ast = astCache || tryParse( code, id );
function transformCommonjs ( parse, code, id, isEntry, ignoreGlobal, ignoreRequire, customNamedExports, sourceMap, allowDynamicRequire, astCache ) {
var ast = astCache || tryParse( parse, code, id );

@@ -769,2 +764,4 @@ var magicString = new MagicString( code );

transform: function transform ( code, id ) {
var this$1 = this;
if ( !filter( id ) ) { return null; }

@@ -774,3 +771,3 @@ if ( extensions.indexOf( extname( id ) ) === -1 ) { return null; }

return entryModuleIdsPromise.then( function (entryModuleIds) {
var ref = checkEsModule( code, id );
var ref = checkEsModule( this$1.parse, code, id );
var isEsModule = ref.isEsModule;

@@ -791,7 +788,12 @@ var hasDefaultExport = ref.hasDefaultExport;

var transformed = transformCommonjs( code, id, entryModuleIds.indexOf(id) !== -1, ignoreGlobal, ignoreRequire, customNamedExports[ id ], sourceMap, allowDynamicRequire, ast );
if ( !transformed ) { return; }
var transformed = transformCommonjs( this$1.parse, code, id, entryModuleIds.indexOf(id) !== -1, ignoreGlobal, ignoreRequire, customNamedExports[ id ], sourceMap, allowDynamicRequire, ast );
if ( !transformed ) {
esModulesWithoutDefaultExport.push( id );
return;
}
commonjsModules.set( id, true );
return transformed;
}).catch(function (err) {
this$1.error(err, err.loc);
});

@@ -798,0 +800,0 @@ }

{
"name": "rollup-plugin-commonjs",
"version": "8.4.1",
"version": "9.0.0",
"description": "Convert CommonJS modules to ES2015",

@@ -23,20 +23,23 @@ "main": "dist/rollup-plugin-commonjs.cjs.js",

],
"peerDependencies": {
"rollup": ">=0.56.0"
},
"dependencies": {
"acorn": "^5.2.1",
"estree-walker": "^0.5.0",
"estree-walker": "^0.5.1",
"magic-string": "^0.22.4",
"resolve": "^1.4.0",
"resolve": "^1.5.0",
"rollup-pluginutils": "^2.0.1"
},
"devDependencies": {
"eslint": "^4.8.0",
"locate-character": "^2.0.1",
"mocha": "^4.0.1",
"acorn": "^5.5.0",
"eslint": "^4.18.2",
"locate-character": "^2.0.5",
"mocha": "^5.0.1",
"require-relative": "^0.8.7",
"rollup": "^0.55.0",
"rollup-plugin-buble": "^0.16.0",
"rollup-plugin-node-resolve": "^3.0.0",
"rollup": "^0.56.4",
"rollup-plugin-buble": "^0.19.2",
"rollup-plugin-node-resolve": "^3.0.3",
"shx": "^0.2.2",
"source-map": "^0.6.1",
"source-map-support": "^0.5.0"
"source-map-support": "^0.5.3"
},

@@ -43,0 +46,0 @@ "repository": "rollup/rollup-plugin-commonjs",

@@ -172,3 +172,3 @@ import { statSync } from 'fs';

return entryModuleIdsPromise.then( (entryModuleIds) => {
const {isEsModule, hasDefaultExport, ast} = checkEsModule( code, id );
const {isEsModule, hasDefaultExport, ast} = checkEsModule( this.parse, code, id );
if ( isEsModule ) {

@@ -186,7 +186,12 @@ if ( !hasDefaultExport )

const transformed = transformCommonjs( code, id, entryModuleIds.indexOf(id) !== -1, ignoreGlobal, ignoreRequire, customNamedExports[ id ], sourceMap, allowDynamicRequire, ast );
if ( !transformed ) return;
const transformed = transformCommonjs( this.parse, code, id, entryModuleIds.indexOf(id) !== -1, ignoreGlobal, ignoreRequire, customNamedExports[ id ], sourceMap, allowDynamicRequire, ast );
if ( !transformed ) {
esModulesWithoutDefaultExport.push( id );
return;
}
commonjsModules.set( id, true );
return transformed;
}).catch(err => {
this.error(err, err.loc);
});

@@ -193,0 +198,0 @@ }

@@ -1,2 +0,1 @@

import acorn from 'acorn';
import { walk } from 'estree-walker';

@@ -29,9 +28,5 @@ import MagicString from 'magic-string';

function tryParse ( code, id ) {
function tryParse ( parse, code, id ) {
try {
return acorn.parse( code, {
ecmaVersion: 8,
sourceType: 'module',
allowReturnOutsideFunction: true
});
return parse( code, { allowReturnOutsideFunction: true });
} catch ( err ) {

@@ -48,4 +43,4 @@ err.message += ` in ${id}`;

export function checkEsModule (code, id) {
const ast = tryParse(code, id);
export function checkEsModule ( parse, code, id ) {
const ast = tryParse( parse, code, id );

@@ -65,4 +60,4 @@ // if there are top-level import/export declarations, this is ES not CommonJS

export function transformCommonjs ( code, id, isEntry, ignoreGlobal, ignoreRequire, customNamedExports, sourceMap, allowDynamicRequire, astCache ) {
const ast = astCache || tryParse( code, id );
export function transformCommonjs ( parse, code, id, isEntry, ignoreGlobal, ignoreRequire, customNamedExports, sourceMap, allowDynamicRequire, astCache ) {
const ast = astCache || tryParse( parse, code, id );

@@ -69,0 +64,0 @@ const magicString = new MagicString( code );

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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