Skip to content
This repository has been archived by the owner on Aug 4, 2021. It is now read-only.

Commit

Permalink
Fix rollup/rollup#1637 (with tests)
Browse files Browse the repository at this point in the history
  • Loading branch information
caleb531 committed Sep 23, 2017
1 parent 90e3a82 commit e49819a
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/transform.js
Expand Up @@ -374,10 +374,12 @@ export default function transformCommonjs ( code, id, isEntry, ignoreGlobal, ign
`export { ${name} };` :
`export { ${deconflicted} as ${name} };`;

namedExportDeclarations.push({
str: declaration,
name
});
if ( name !== 'default' ) {
namedExportDeclarations.push({
str: declaration,
name
});
}

defaultExportPropertyAssignments.push( `${moduleName}.${name} = ${deconflicted};` );
}
Expand Down
6 changes: 6 additions & 0 deletions test/function/duplicate-default-exports-c/exports.js
@@ -0,0 +1,6 @@
exports.Foo = 1;
exports.var = 'VAR';
exports.default = {
Foo: 2,
default: 3
};
11 changes: 11 additions & 0 deletions test/function/duplicate-default-exports-c/main.js
@@ -0,0 +1,11 @@
import E from './exports.js';
import { Foo } from './exports.js';
import { var as Var } from './exports.js';

assert.strictEqual( E.Foo, 1 );
assert.strictEqual( E.var, 'VAR' );
assert.deepEqual( E.default, { Foo: 2, default: 3 });
assert.strictEqual( E.default.Foo, 2 );
assert.strictEqual( E.default.default, 3 );
assert.strictEqual( Foo, 1 );
assert.strictEqual( Var, 'VAR' );

0 comments on commit e49819a

Please sign in to comment.