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

Don't generate a default export for ES modules that don't have one #225

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -391,9 +391,8 @@ export default function transformCommonjs ( code, id, isEntry, ignoreGlobal, ign
}
}

const defaultExport = /__esModule/.test( code ) ?
`export default ${HELPERS_NAME}.unwrapExports(${moduleName});` :
`export default ${moduleName};`;
const defaultExport = !/__esModule/.test( code ) ? `export default ${moduleName};`
: hasDefaultExport ? `export default ${HELPERS_NAME}.unwrapExports(${moduleName});` : '';

const named = namedExportDeclarations
.filter( x => x.name !== 'default' || !hasDefaultExport )
Expand Down
1 change: 0 additions & 1 deletion test/function/__esModule/main.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as x from './answer';

assert.ok( 'answer' in x );
assert.ok( 'default' in x ); // TODO is this right?
assert.ok( !( '__esModule' in x ) );