Comparing version 0.7.4 to 0.7.5
# rollup changelog | ||
## 0.7.5 | ||
* Prevent accidental conflicts with the global namespace ([#20](https://github.com/rollup/rollup/issues/20)) | ||
## 0.7.4 | ||
@@ -4,0 +8,0 @@ |
@@ -854,2 +854,10 @@ 'use strict'; | ||
}); | ||
this.statements.forEach(function (statement) { | ||
keys(statement.dependsOn).forEach(function (name) { | ||
if (!_this2.definitions[name] && !_this2.imports[name]) { | ||
_this2.bundle.assumedGlobals[name] = true; | ||
} | ||
}); | ||
}); | ||
}; | ||
@@ -1505,2 +1513,3 @@ | ||
this.internalNamespaceModules = []; | ||
this.assumedGlobals = blank(); | ||
} | ||
@@ -1586,2 +1595,4 @@ | ||
Bundle.prototype.deconflict = function deconflict() { | ||
var _this3 = this; | ||
var definers = blank(); | ||
@@ -1637,2 +1648,9 @@ var conflicts = blank(); | ||
// Ensure we don't conflict with globals | ||
keys(this.assumedGlobals).forEach(function (name) { | ||
if (definers[name]) { | ||
conflicts[name] = true; | ||
} | ||
}); | ||
// Rename conflicting identifiers so they can live in the same scope | ||
@@ -1642,3 +1660,8 @@ keys(conflicts).forEach(function (name) { | ||
modules.pop(); // the module closest to the entryModule gets away with keeping things as they are | ||
if (!_this3.assumedGlobals[name]) { | ||
// the module closest to the entryModule gets away with | ||
// keeping things as they are, unless we have a conflict | ||
// with a global name | ||
modules.pop(); | ||
} | ||
@@ -1662,3 +1685,3 @@ modules.forEach(function (module) { | ||
Bundle.prototype.generate = function generate() { | ||
var _this3 = this; | ||
var _this4 = this; | ||
@@ -1690,11 +1713,11 @@ var options = arguments[0] === undefined ? {} : arguments[0]; | ||
keys(this.entryModule.exports).forEach(function (key) { | ||
var exportDeclaration = _this3.entryModule.exports[key]; | ||
var exportDeclaration = _this4.entryModule.exports[key]; | ||
var originalDeclaration = _this3.entryModule.findDeclaration(exportDeclaration.localName); | ||
var originalDeclaration = _this4.entryModule.findDeclaration(exportDeclaration.localName); | ||
if (originalDeclaration && originalDeclaration.type === 'VariableDeclaration') { | ||
var canonicalName = _this3.entryModule.getCanonicalName(exportDeclaration.localName); | ||
var canonicalName = _this4.entryModule.getCanonicalName(exportDeclaration.localName); | ||
allBundleExports[canonicalName] = 'exports.' + key; | ||
_this3.varExports[key] = true; | ||
_this4.varExports[key] = true; | ||
} | ||
@@ -1707,3 +1730,3 @@ }); | ||
this.toExport = keys(this.entryModule.exports).filter(function (key) { | ||
return !_this3.varExports[key]; | ||
return !_this4.varExports[key]; | ||
}); | ||
@@ -1710,0 +1733,0 @@ |
{ | ||
"name": "rollup", | ||
"version": "0.7.4", | ||
"version": "0.7.5", | ||
"description": "Next-generation ES6 module bundler", | ||
@@ -5,0 +5,0 @@ "main": "dist/rollup.js", |
@@ -46,2 +46,3 @@ import { basename, dirname, extname, relative, resolve } from 'path'; | ||
this.internalNamespaceModules = []; | ||
this.assumedGlobals = blank(); | ||
} | ||
@@ -173,2 +174,9 @@ | ||
// Ensure we don't conflict with globals | ||
keys( this.assumedGlobals ).forEach( name => { | ||
if ( definers[ name ] ) { | ||
conflicts[ name ] = true; | ||
} | ||
}); | ||
// Rename conflicting identifiers so they can live in the same scope | ||
@@ -178,3 +186,8 @@ keys( conflicts ).forEach( name => { | ||
modules.pop(); // the module closest to the entryModule gets away with keeping things as they are | ||
if ( !this.assumedGlobals[ name ] ) { | ||
// the module closest to the entryModule gets away with | ||
// keeping things as they are, unless we have a conflict | ||
// with a global name | ||
modules.pop(); | ||
} | ||
@@ -181,0 +194,0 @@ modules.forEach( module => { |
@@ -184,2 +184,10 @@ import { Promise } from 'sander'; | ||
}); | ||
this.statements.forEach( statement => { | ||
keys( statement.dependsOn ).forEach( name => { | ||
if ( !this.definitions[ name ] && !this.imports[ name ] ) { | ||
this.bundle.assumedGlobals[ name ] = true; | ||
} | ||
}); | ||
}); | ||
} | ||
@@ -186,0 +194,0 @@ |
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
217680
3128