Socket
Socket
Sign inDemoInstall

rollup

Package Overview
Dependencies
28
Maintainers
1
Versions
799
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.6.2 to 0.6.3

5

CHANGELOG.md
# rollup changelog
## 0.6.3
* Fix exports and external module imports with some output formats
* Fix endless cycle bug on Windows ([#3](https://github.com/rollup/rollup/pull/3)) - thanks @Bobris
## 0.6.2

@@ -4,0 +9,0 @@

85

dist/rollup.js

@@ -1032,3 +1032,3 @@ 'use strict';

} else {
exportBlock = '\n\n' + Object.keys(exports).map(function (name) {
exportBlock = Object.keys(exports).map(function (name) {
return 'exports.' + name + ' = ' + exports[name].localName + ';';

@@ -1038,3 +1038,7 @@ }).join('\n');

return magicString.append(exportBlock).trim().indent().append('\n\n});').prepend(intro);
if (exportBlock) {
magicString.append('\n\n' + exportBlock);
}
return magicString.trim().indent().append('\n\n});').prepend(intro);
}

@@ -1082,6 +1086,21 @@

function es6(bundle, magicString, exportMode, options) {
// TODO
var introBlock = '';
var exportBlock = '';
var introBlock = ''; // TODO...
var exports = bundle.entryModule.exports;
var exportBlock = keys(exports).map(function (exportedName) {
var specifier = exports[exportedName];
var canonicalName = bundle.entryModule.getCanonicalName(specifier.localName);
if (exportedName === 'default') {
return 'export default ' + canonicalName + ';';
}
return exportedName === canonicalName ? 'export { ' + exportedName + ' };' : 'export { ' + canonicalName + ' as ' + exportedName + ' };';
}).join('\n');
if (exportBlock) {
magicString.append('\n\n' + exportBlock);
}
return magicString.trim();

@@ -1091,7 +1110,28 @@ }

function iife(bundle, magicString, exportMode, options) {
var globalNames = options.globals || {};
var intro = "(function () { 'use strict';\n\n";
var outro = "\n\n})();";
var dependencies = bundle.externalModules.map(function (module) {
return has(globalNames, module.id) ? globalNames[module.id] : module.name;
});
return magicString.trim().indent().prepend(intro).append(outro);
var args = bundle.externalModules.map(getName);
if (exportMode !== 'none' && !options.moduleName) {
throw new Error('You must supply options.moduleName for IIFE bundles');
}
if (exportMode === 'named') {
dependencies.unshift('(window.' + options.moduleName + ' = {})');
args.unshift('exports');
}
var intro = '(function (' + args + ') { \'use strict\';\n\n';
var outro = '\n\n})(' + dependencies + ');';
if (exportMode === 'default') {
intro = 'var ' + options.moduleName + ' = ' + intro;
magicString.append('\n\nreturn ' + bundle.entryModule.getCanonicalName('default') + ';');
}
return magicString.indent().prepend(intro).append(outro);
}

@@ -1122,11 +1162,25 @@

var intro = ('(function (global, factory) {\n\t\t\ttypeof exports === \'object\' && typeof module !== \'undefined\' ? factory(' + cjsDeps.join(', ') + ') :\n\t\t\ttypeof define === \'function\' && define.amd ? define(' + amdParams + 'factory) :\n\t\t\tfactory(' + globalDeps + ');\n\t\t}(this, function (' + args + ') { \'use strict\';\n\n\t\t').replace(/^\t\t/gm, '').replace(/^\t/gm, indentStr);
var defaultExport = exportMode === 'default' ? 'global.' + options.moduleName + ' = ' : '';
var intro = ('(function (global, factory) {\n\t\t\ttypeof exports === \'object\' && typeof module !== \'undefined\' ? factory(' + cjsDeps.join(', ') + ') :\n\t\t\ttypeof define === \'function\' && define.amd ? define(' + amdParams + 'factory) :\n\t\t\t' + defaultExport + 'factory(' + globalDeps + ');\n\t\t}(this, function (' + args + ') { \'use strict\';\n\n\t\t').replace(/^\t\t/gm, '').replace(/^\t/gm, indentStr);
var exports = bundle.entryModule.exports;
var exportBlock = '\n\n' + Object.keys(exports).map(function (name) {
return 'exports.' + name + ' = ' + exports[name].localName + ';';
}).join('\n');
var exportBlock = undefined;
return magicString.append(exportBlock).trim().indent().append('\n\n}));').prepend(intro);
if (exportMode === 'default') {
var canonicalName = bundle.entryModule.getCanonicalName('default');
exportBlock = 'return ' + canonicalName + ';';
} else {
exportBlock = Object.keys(exports).map(function (name) {
var canonicalName = bundle.entryModule.getCanonicalName(exports[name].localName);
return 'exports.' + name + ' = ' + canonicalName + ';';
}).join('\n');
}
if (exportBlock) {
magicString.append('\n\n' + exportBlock);
}
return magicString.trim().indent().append('\n\n}));').prepend(intro);
}

@@ -1159,5 +1213,6 @@

// for now, only node_modules is supported, and only jsnext:main
var dir = _path.dirname(importer);
var parsed = _path.parse(importer);
var dir = parsed.dir;
while (dir !== '/') {
while (dir !== parsed.root) {
var pkgPath = _path.resolve(dir, 'node_modules', id, 'package.json');

@@ -1164,0 +1219,0 @@ var pkgJson = undefined;

2

package.json
{
"name": "rollup",
"version": "0.6.2",
"version": "0.6.3",
"description": "Next-generation ES6 module bundler",

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

@@ -100,3 +100,2 @@ import { basename, dirname, extname, relative, resolve } from 'path';

});
}

@@ -103,0 +102,0 @@

@@ -26,3 +26,3 @@ import { has } from '../utils/object';

} else {
exportBlock = '\n\n' + Object.keys( exports ).map( name => {
exportBlock = Object.keys( exports ).map( name => {
return `exports.${name} = ${exports[name].localName};`;

@@ -32,4 +32,7 @@ }).join( '\n' );

if ( exportBlock ) {
magicString.append( '\n\n' + exportBlock );
}
return magicString
.append( exportBlock )
.trim()

@@ -36,0 +39,0 @@ .indent()

@@ -0,7 +1,26 @@

import { keys } from '../utils/object';
export default function es6 ( bundle, magicString, exportMode, options ) {
// TODO
const introBlock = '';
const exportBlock = '';
const introBlock = ''; // TODO...
const exports = bundle.entryModule.exports;
const exportBlock = keys( exports ).map( exportedName => {
const specifier = exports[ exportedName ];
const canonicalName = bundle.entryModule.getCanonicalName( specifier.localName );
if ( exportedName === 'default' ) {
return `export default ${canonicalName};`;
}
return exportedName === canonicalName ?
`export { ${exportedName} };` :
`export { ${canonicalName} as ${exportedName} };`;
}).join( '\n' );
if ( exportBlock ) {
magicString.append( '\n\n' + exportBlock );
}
return magicString.trim();
}

@@ -0,8 +1,31 @@

import { has } from '../utils/object';
import { getName } from '../utils/map-helpers';
export default function iife ( bundle, magicString, exportMode, options ) {
const globalNames = options.globals || {};
const intro = `(function () { 'use strict';\n\n`;
const outro = `\n\n})();`;
let dependencies = bundle.externalModules.map( module => {
return has( globalNames, module.id ) ? globalNames[ module.id ] : module.name;
});
let args = bundle.externalModules.map( getName );
if ( exportMode !== 'none' && !options.moduleName ) {
throw new Error( 'You must supply options.moduleName for IIFE bundles' );
}
if ( exportMode === 'named' ) {
dependencies.unshift( `(window.${options.moduleName} = {})` );
args.unshift( 'exports' );
}
let intro = `(function (${args}) { 'use strict';\n\n`;
let outro = `\n\n})(${dependencies});`;
if ( exportMode === 'default' ) {
intro = `var ${options.moduleName} = ${intro}`;
magicString.append( `\n\nreturn ${bundle.entryModule.getCanonicalName('default')};` );
}
return magicString
.trim()
.indent()

@@ -9,0 +32,0 @@ .prepend( intro )

@@ -29,2 +29,4 @@ import { has } from '../utils/object';

const defaultExport = exportMode === 'default' ? `global.${options.moduleName} = ` : '';
const intro =

@@ -34,3 +36,3 @@ `(function (global, factory) {

typeof define === 'function' && define.amd ? define(${amdParams}factory) :
factory(${globalDeps});
${defaultExport}factory(${globalDeps});
}(this, function (${args}) { 'use strict';

@@ -42,8 +44,19 @@

const exportBlock = '\n\n' + Object.keys( exports ).map( name => {
return `exports.${name} = ${exports[name].localName};`;
}).join( '\n' );
let exportBlock;
if ( exportMode === 'default' ) {
const canonicalName = bundle.entryModule.getCanonicalName( 'default' );
exportBlock = `return ${canonicalName};`;
} else {
exportBlock = Object.keys( exports ).map( name => {
const canonicalName = bundle.entryModule.getCanonicalName( exports[ name ].localName );
return `exports.${name} = ${canonicalName};`;
}).join( '\n' );
}
if ( exportBlock ) {
magicString.append( '\n\n' + exportBlock );
}
return magicString
.append( exportBlock )
.trim()

@@ -50,0 +63,0 @@ .indent()

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

import { dirname, isAbsolute, resolve } from 'path';
import { dirname, isAbsolute, resolve, parse } from 'path';
import { readFileSync } from 'sander';

@@ -21,5 +21,6 @@

// for now, only node_modules is supported, and only jsnext:main
let dir = dirname( importer );
let parsed = parse( importer );
let dir = parsed.dir;
while ( dir !== '/' ) {
while ( dir !== parsed.root ) {
const pkgPath = resolve( dir, 'node_modules', id, 'package.json' );

@@ -26,0 +27,0 @@ let pkgJson;

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc