Comparing version 0.8.0 to 0.8.1
# rollup changelog | ||
## 0.8.1 | ||
* Anonymous functions that are exported as default are converted to named function declarations for correct hoisting, rather than being bound to functions ([#29](https://github.com/rollup/rollup/issues/29)) | ||
* Automatically-generated default export names are deconflicted with local definitions ([#29](https://github.com/rollup/rollup/issues/29)) | ||
## 0.8.0 | ||
@@ -4,0 +9,0 @@ |
@@ -1044,2 +1044,4 @@ 'use strict'; | ||
var isDeclaration = /Declaration$/.test(node.declaration.type); | ||
var isAnonymous = /(?:Class|Function)Expression$/.test(node.declaration.type); | ||
var declaredName = isDeclaration && node.declaration.id.name; | ||
@@ -1055,2 +1057,3 @@ var identifier = node.declaration.type === 'Identifier' && node.declaration.name; | ||
isDeclaration: isDeclaration, | ||
isAnonymous: isAnonymous, | ||
isModified: false // in case of `export default foo; foo = somethingElse` | ||
@@ -1384,6 +1387,15 @@ }; | ||
Module.prototype.suggestName = function suggestName(exportName, suggestion) { | ||
if (!this.suggestedNames[exportName]) { | ||
this.suggestedNames[exportName] = makeLegalIdentifier(suggestion); | ||
Module.prototype.suggestName = function suggestName(defaultOrBatch, suggestion) { | ||
// deconflict anonymous default exports with this module's definitions | ||
var shouldDeconflict = this.exports.default && this.exports.default.isAnonymous; | ||
if (shouldDeconflict) { | ||
while (suggestion in this.definitions) { | ||
suggestion = '_' + suggestion; | ||
} | ||
} | ||
if (!this.suggestedNames[defaultOrBatch]) { | ||
this.suggestedNames[defaultOrBatch] = makeLegalIdentifier(suggestion); | ||
} | ||
}; | ||
@@ -1800,3 +1812,8 @@ | ||
source.overwrite(statement.node.start, statement.node.declaration.start, 'var ' + canonicalName + ' = '); | ||
// anonymous functions should be converted into declarations | ||
if (statement.node.declaration.type === 'FunctionExpression') { | ||
source.overwrite(statement.node.start, statement.node.declaration.start + 8, 'function ' + canonicalName); | ||
} else { | ||
source.overwrite(statement.node.start, statement.node.declaration.start, 'var ' + canonicalName + ' = '); | ||
} | ||
} else { | ||
@@ -1803,0 +1820,0 @@ throw new Error('Unhandled export'); |
{ | ||
"name": "rollup", | ||
"version": "0.8.0", | ||
"version": "0.8.1", | ||
"description": "Next-generation ES6 module bundler", | ||
@@ -5,0 +5,0 @@ "main": "dist/rollup.js", |
@@ -294,3 +294,8 @@ import { basename, dirname, extname, relative, resolve } from 'path'; | ||
source.overwrite( statement.node.start, statement.node.declaration.start, `var ${canonicalName} = ` ); | ||
// anonymous functions should be converted into declarations | ||
if ( statement.node.declaration.type === 'FunctionExpression' ) { | ||
source.overwrite( statement.node.start, statement.node.declaration.start + 8, `function ${canonicalName}` ); | ||
} else { | ||
source.overwrite( statement.node.start, statement.node.declaration.start, `var ${canonicalName} = ` ); | ||
} | ||
} | ||
@@ -297,0 +302,0 @@ |
@@ -130,2 +130,4 @@ import { Promise } from 'sander'; | ||
const isDeclaration = /Declaration$/.test( node.declaration.type ); | ||
const isAnonymous = /(?:Class|Function)Expression$/.test( node.declaration.type ); | ||
const declaredName = isDeclaration && node.declaration.id.name; | ||
@@ -141,2 +143,3 @@ const identifier = node.declaration.type === 'Identifier' && node.declaration.name; | ||
isDeclaration, | ||
isAnonymous, | ||
isModified: false // in case of `export default foo; foo = somethingElse` | ||
@@ -469,7 +472,16 @@ }; | ||
suggestName ( exportName, suggestion ) { | ||
if ( !this.suggestedNames[ exportName ] ) { | ||
this.suggestedNames[ exportName ] = makeLegalIdentifier( suggestion ); | ||
suggestName ( defaultOrBatch, suggestion ) { | ||
// deconflict anonymous default exports with this module's definitions | ||
const shouldDeconflict = this.exports.default && this.exports.default.isAnonymous; | ||
if ( shouldDeconflict ) { | ||
while ( suggestion in this.definitions ) { | ||
suggestion = `_${suggestion}`; | ||
} | ||
} | ||
if ( !this.suggestedNames[ defaultOrBatch ] ) { | ||
this.suggestedNames[ defaultOrBatch ] = makeLegalIdentifier( suggestion ); | ||
} | ||
} | ||
} |
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
127813
3167