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

rollup-plugin-commonjs

Package Overview
Dependencies
Maintainers
3
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 7.0.1 to 7.0.2

4

CHANGELOG.md
# rollup-plugin-commonjs changelog
## 7.0.2
* Handle duplicate default exports ([#158](https://github.com/rollup/rollup-plugin-commonjs/issues/158))
## 7.0.1

@@ -4,0 +8,0 @@

@@ -366,3 +366,7 @@ 'use strict';

if ( !isEntry ) {
var exportModuleExports = "export { " + moduleName + " as __moduleExports };";
var exportModuleExports = {
str: ("export { " + moduleName + " as __moduleExports };"),
name: '__moduleExports'
};
namedExportDeclarations.push( exportModuleExports );

@@ -380,3 +384,6 @@ }

namedExportDeclarations.push( declaration );
namedExportDeclarations.push({
str: declaration,
name: x
});
}

@@ -426,3 +433,7 @@

namedExportDeclarations.push( declaration );
namedExportDeclarations.push({
str: declaration,
name: name
});
defaultExportPropertyAssignments.push( (moduleName + "." + name + " = " + deconflicted + ";") );

@@ -447,4 +458,8 @@ }

var named = namedExportDeclarations
.filter( function (x) { return x.name !== 'default' || !hasDefaultExport; } )
.map( function (x) { return x.str; } );
var exportBlock = '\n\n' + [ defaultExport ]
.concat( namedExportDeclarations )
.concat( named )
.concat( hasDefaultExport ? defaultExportPropertyAssignments : [] )

@@ -451,0 +466,0 @@ .join( '\n' );

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

if ( !isEntry ) {
var exportModuleExports = "export { " + moduleName + " as __moduleExports };";
var exportModuleExports = {
str: ("export { " + moduleName + " as __moduleExports };"),
name: '__moduleExports'
};
namedExportDeclarations.push( exportModuleExports );

@@ -377,3 +381,6 @@ }

namedExportDeclarations.push( declaration );
namedExportDeclarations.push({
str: declaration,
name: x
});
}

@@ -423,3 +430,7 @@

namedExportDeclarations.push( declaration );
namedExportDeclarations.push({
str: declaration,
name: name
});
defaultExportPropertyAssignments.push( (moduleName + "." + name + " = " + deconflicted + ";") );

@@ -444,4 +455,8 @@ }

var named = namedExportDeclarations
.filter( function (x) { return x.name !== 'default' || !hasDefaultExport; } )
.map( function (x) { return x.str; } );
var exportBlock = '\n\n' + [ defaultExport ]
.concat( namedExportDeclarations )
.concat( named )
.concat( hasDefaultExport ? defaultExportPropertyAssignments : [] )

@@ -448,0 +463,0 @@ .join( '\n' );

2

package.json
{
"name": "rollup-plugin-commonjs",
"version": "7.0.1",
"version": "7.0.2",
"description": "Convert CommonJS modules to ES2015",

@@ -5,0 +5,0 @@ "main": "dist/rollup-plugin-commonjs.cjs.js",

@@ -21,8 +21,10 @@ # rollup-plugin-commonjs [![Build Status][travis-img]][travis]

```js
import { rollup } from 'rollup';
// rollup.config.js
import commonjs from 'rollup-plugin-commonjs';
import nodeResolve from 'rollup-plugin-node-resolve';
rollup({
export default {
entry: 'main.js',
dest: 'bundle.js',
format: 'iife',
plugins: [

@@ -49,9 +51,9 @@ nodeResolve({

sourceMap: false, // Default: true
// explicitly specify unresolvable named exports
// (see below for more details)
namedExports: { './module.js': ['foo', 'bar' ] } // Default: undefined
namedExports: { './module.js': ['foo', 'bar' ] } // Default: undefined
})
]
}).then(...)
};
```

@@ -85,15 +87,22 @@

```js
commonjs({
namedExports: {
// left-hand side can be an absolute path, a path
// relative to the current directory, or the name
// of a module in node_modules
'node_modules/my-lib/index.js': [ 'named' ]
}
})
commonjs({
namedExports: {
// left-hand side can be an absolute path, a path
// relative to the current directory, or the name
// of a module in node_modules
'node_modules/my-lib/index.js': [ 'named' ]
}
})
```
## Strict mode
ES modules are *always* parsed in strict mode. That means that certain non-strict constructs (like octal literals) will be treated as syntax errors when Rollup parses modules that use them. Some older CommonJS modules depend on those constructs, and if you depend on them your bundle will blow up. There's basically nothing we can do about that.
Luckily, there is absolutely no good reason *not* to use strict mode for everything — so the solution to this problem is to lobby the authors of those modules to update them.
## License
MIT

@@ -238,3 +238,7 @@ import acorn from 'acorn';

if ( !isEntry ) {
const exportModuleExports = `export { ${moduleName} as __moduleExports };`;
const exportModuleExports = {
str: `export { ${moduleName} as __moduleExports };`,
name: '__moduleExports'
};
namedExportDeclarations.push( exportModuleExports );

@@ -252,3 +256,6 @@ }

namedExportDeclarations.push( declaration );
namedExportDeclarations.push({
str: declaration,
name: x
});
}

@@ -298,3 +305,7 @@

namedExportDeclarations.push( declaration );
namedExportDeclarations.push({
str: declaration,
name
});
defaultExportPropertyAssignments.push( `${moduleName}.${name} = ${deconflicted};` );

@@ -316,4 +327,8 @@ }

const named = namedExportDeclarations
.filter( x => x.name !== 'default' || !hasDefaultExport )
.map( x => x.str );
const exportBlock = '\n\n' + [ defaultExport ]
.concat( namedExportDeclarations )
.concat( named )
.concat( hasDefaultExport ? defaultExportPropertyAssignments : [] )

@@ -320,0 +335,0 @@ .join( '\n' );

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