Skip to content

Commit

Permalink
Merge pull request #47 from esperantojs/gh-45
Browse files Browse the repository at this point in the history
  • Loading branch information
Rich-Harris committed Jan 10, 2015
2 parents a521bd5 + 64b4b82 commit cf4b372
Show file tree
Hide file tree
Showing 13 changed files with 74 additions and 5 deletions.
2 changes: 1 addition & 1 deletion dist/esperanto.js
Original file line number Diff line number Diff line change
Expand Up @@ -747,7 +747,7 @@ function populateIdentifierReplacements ( bundle ) {

if ( x = mod.defaultExport ) {
if ( x.hasDeclaration && x.name ) {
mod.identifierReplacements.default = hasOwnProp.call( conflicts, x.name ) || otherModulesDeclare( mod, mod.name ) ?
mod.identifierReplacements.default = hasOwnProp.call( conflicts, x.name ) || otherModulesDeclare( mod, x.name ) ?
mod.name + '__' + x.name :
x.name;
} else {
Expand Down
2 changes: 1 addition & 1 deletion esperanto.js
Original file line number Diff line number Diff line change
Expand Up @@ -747,7 +747,7 @@ function populateIdentifierReplacements ( bundle ) {

if ( x = mod.defaultExport ) {
if ( x.hasDeclaration && x.name ) {
mod.identifierReplacements.default = hasOwnProp.call( conflicts, x.name ) || otherModulesDeclare( mod, mod.name ) ?
mod.identifierReplacements.default = hasOwnProp.call( conflicts, x.name ) || otherModulesDeclare( mod, x.name ) ?
mod.name + '__' + x.name :
x.name;
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/bundler/combine/populateIdentifierReplacements.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default function populateIdentifierReplacements ( bundle ) {

if ( x = mod.defaultExport ) {
if ( x.hasDeclaration && x.name ) {
mod.identifierReplacements.default = hasOwnProp.call( conflicts, x.name ) || otherModulesDeclare( mod, mod.name ) ?
mod.identifierReplacements.default = hasOwnProp.call( conflicts, x.name ) || otherModulesDeclare( mod, x.name ) ?
mod.name + '__' + x.name :
x.name;
} else {
Expand Down
5 changes: 3 additions & 2 deletions test/bundle/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ module.exports = function () {
{ dir: '27', description: 'correctly infers indentation with single-line edge case' },
{ dir: '28', description: 'environment GetThisBinding is always undefined' },
{ dir: '29', description: 'both named and default bindings can be imported from an external module', strict: true },
{ dir: '30', description: 'batch import from external module' }
{ dir: '30', description: 'batch import from external module' },
{ dir: '31', description: 'renames identifiers consistently' }
];

profiles.forEach( function ( profile ) {
Expand All @@ -156,7 +157,7 @@ module.exports = function () {
( t.only ? it.only : it )( t.description, function () {
return esperanto.bundle({
base: path.resolve( 'bundle/input', t.dir ),
entry: t.entry || 'main',
entry: config.entry || 'main',
skip: config.skip,
names: config.names,
transform: config.transform
Expand Down
1 change: 1 addition & 0 deletions test/bundle/input/31/exportedX.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default function someOtherName () {}
4 changes: 4 additions & 0 deletions test/bundle/input/31/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import x from './exportedX';
import './notExportedX';

x();
1 change: 1 addition & 0 deletions test/bundle/input/31/notExportedX.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
function x () {}
11 changes: 11 additions & 0 deletions test/bundle/output/amd/31.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
define(function () {

'use strict';

function someOtherName () {}

function x () {}

someOtherName();

});
11 changes: 11 additions & 0 deletions test/bundle/output/amdDefaults/31.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
define(function () {

'use strict';

function someOtherName () {}

function x () {}

someOtherName();

});
7 changes: 7 additions & 0 deletions test/bundle/output/cjs/31.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
'use strict';

function someOtherName () {}

function x () {}

someOtherName();
7 changes: 7 additions & 0 deletions test/bundle/output/cjsDefaults/31.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
'use strict';

function someOtherName () {}

function x () {}

someOtherName();
13 changes: 13 additions & 0 deletions test/bundle/output/umd/31.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
(function (factory) {
!(typeof exports === 'object' && typeof module !== 'undefined') &&
typeof define === 'function' && define.amd ? define(factory) :
factory()
}(function () { 'use strict';

function someOtherName () {}

function x () {}

someOtherName();

}));
13 changes: 13 additions & 0 deletions test/bundle/output/umdDefaults/31.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
(function (factory) {
!(typeof exports === 'object' && typeof module !== 'undefined') &&
typeof define === 'function' && define.amd ? define(factory) :
factory()
}(function () { 'use strict';

function someOtherName () {}

function x () {}

someOtherName();

}));

0 comments on commit cf4b372

Please sign in to comment.