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

rollup-plugin-commonjs

Package Overview
Dependencies
Maintainers
1
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 1.0.0 to 1.1.0

9

CHANGELOG.md
# rollup-plugin-commonjs changelog
## 1.1.0
* Handle dots in filenames ([#3](https://github.com/rollup/rollup-plugin-commonjs/issues/3))
* Wrap modules in IIFE for more readable output
## 1.0.0
* Stable release, now that Rollup supports plugins
## 0.2.1

@@ -4,0 +13,0 @@

25

dist/rollup-plugin-commonjs.cjs.js

@@ -22,18 +22,9 @@ 'use strict';

var withExtension = rollupPluginutils.addExtension(importee);
var resolved = path.resolve(path.dirname(importer), withExtension);
var resolved = path.resolve(path.dirname(importer), importee);
var candidates = [resolved, resolved + '.js', resolved + (path.sep + 'index.js')];
// look for `foo.js`...
try {
fs.statSync(resolved);
return resolved;
} catch (err) {}
// ...then `foo/index.js`
if (importee !== withExtension) {
for (var i = 0; i < candidates.length; i += 1) {
try {
resolved = resolved.replace(/\.js$/, path.sep + 'index.js');
fs.statSync(resolved);
return resolved;
var stats = fs.statSync(candidates[i]);
if (stats.isFile()) return candidates[i];
} catch (err) {}

@@ -123,6 +114,6 @@ }

var intro = 'var exports = {}, module = { \'exports\': exports };\n';
var outro = '\nexport default module.exports;';
var intro = '\n\nexport default (function (module) {\nvar exports = module.exports;\n';
var outro = '\nreturn module.exports;\n})({exports:{}});';
magicString.trim().prepend(importBlock + intro).append(outro);
magicString.trim().prepend(importBlock + intro).trim().append(outro);

@@ -129,0 +120,0 @@ code = magicString.toString();

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

import MagicString from 'magic-string';
import { addExtension, createFilter } from 'rollup-pluginutils';
import { createFilter } from 'rollup-pluginutils';

@@ -19,18 +19,9 @@ var firstpass = /\b(?:require|module|exports)\b/;

var withExtension = addExtension(importee);
var resolved = resolve(dirname(importer), withExtension);
var resolved = resolve(dirname(importer), importee);
var candidates = [resolved, resolved + '.js', resolved + (sep + 'index.js')];
// look for `foo.js`...
try {
statSync(resolved);
return resolved;
} catch (err) {}
// ...then `foo/index.js`
if (importee !== withExtension) {
for (var i = 0; i < candidates.length; i += 1) {
try {
resolved = resolved.replace(/\.js$/, sep + 'index.js');
statSync(resolved);
return resolved;
var stats = statSync(candidates[i]);
if (stats.isFile()) return candidates[i];
} catch (err) {}

@@ -120,6 +111,6 @@ }

var intro = 'var exports = {}, module = { \'exports\': exports };\n';
var outro = '\nexport default module.exports;';
var intro = '\n\nexport default (function (module) {\nvar exports = module.exports;\n';
var outro = '\nreturn module.exports;\n})({exports:{}});';
magicString.trim().prepend(importBlock + intro).append(outro);
magicString.trim().prepend(importBlock + intro).trim().append(outro);

@@ -126,0 +117,0 @@ code = magicString.toString();

{
"name": "rollup-plugin-commonjs",
"version": "1.0.0",
"version": "1.1.0",
"devDependencies": {

@@ -5,0 +5,0 @@ "eslint": "^1.7.3",

# rollup-plugin-commonjs
**experimental – depends on an unreleased version of Rollup**
Convert CommonJS modules to ES6, so they can be included in a Rollup bundle

@@ -6,0 +4,0 @@

@@ -17,18 +17,13 @@ import { statSync } from 'fs';

let withExtension = addExtension( importee );
let resolved = resolve( dirname( importer ), withExtension );
const resolved = resolve( dirname( importer ), importee );
const candidates = [
resolved,
resolved + '.js',
resolved + `${sep}index.js`
];
// look for `foo.js`...
try {
statSync( resolved );
return resolved;
} catch ( err ) {}
// ...then `foo/index.js`
if ( importee !== withExtension ) {
for ( let i = 0; i < candidates.length; i += 1 ) {
try {
resolved = resolved.replace( /\.js$/, `${sep}index.js` );
statSync( resolved );
return resolved;
const stats = statSync( candidates[i] );
if ( stats.isFile() ) return candidates[i];
} catch ( err ) {}

@@ -118,7 +113,8 @@ }

const intro = `var exports = {}, module = { 'exports': exports };\n`;
const outro = `\nexport default module.exports;`;
const intro = `\n\nexport default (function (module) {\nvar exports = module.exports;\n`;
const outro = `\nreturn module.exports;\n})({exports:{}});`;
magicString.trim()
.prepend( importBlock + intro )
.trim()
.append( outro );

@@ -125,0 +121,0 @@

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