diff --git a/src/finalisers/es6.js b/src/finalisers/es6.js index 7de4c74..ffdd16d 100644 --- a/src/finalisers/es6.js +++ b/src/finalisers/es6.js @@ -47,10 +47,11 @@ export default function es6 ( bundle, magicString ) { const specifiers = module.getExports().filter( notDefault ).map( name => { const declaration = module.traceExport( name ); + const rendered = declaration.render( true ); - return declaration.name === name ? + return rendered === name ? name : - `${declaration.name} as ${name}`; + `${rendered} as ${name}`; }); let exportBlock = specifiers.length ? `export { ${specifiers.join(', ')} };` : ''; diff --git a/test/form/export-default-import/_config.js b/test/form/export-default-import/_config.js new file mode 100644 index 0000000..860f688 --- /dev/null +++ b/test/form/export-default-import/_config.js @@ -0,0 +1,6 @@ +module.exports = { + description: 'correctly exports a default import, even in ES mode (#513)', + options: { + moduleName: 'myBundle' + } +}; diff --git a/test/form/export-default-import/_expected/amd.js b/test/form/export-default-import/_expected/amd.js new file mode 100644 index 0000000..9158c43 --- /dev/null +++ b/test/form/export-default-import/_expected/amd.js @@ -0,0 +1,9 @@ +define(['exports', 'x'], function (exports, x) { 'use strict'; + + x = 'default' in x ? x['default'] : x; + + + + exports.x = x; + +}); \ No newline at end of file diff --git a/test/form/export-default-import/_expected/cjs.js b/test/form/export-default-import/_expected/cjs.js new file mode 100644 index 0000000..60037db --- /dev/null +++ b/test/form/export-default-import/_expected/cjs.js @@ -0,0 +1,9 @@ +'use strict'; + +function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } + +var x = _interopDefault(require('x')); + + + +exports.x = x; \ No newline at end of file diff --git a/test/form/export-default-import/_expected/es6.js b/test/form/export-default-import/_expected/es6.js new file mode 100644 index 0000000..87ab795 --- /dev/null +++ b/test/form/export-default-import/_expected/es6.js @@ -0,0 +1,5 @@ +import x from 'x'; + + + +export { x }; diff --git a/test/form/export-default-import/_expected/iife.js b/test/form/export-default-import/_expected/iife.js new file mode 100644 index 0000000..4c3865e --- /dev/null +++ b/test/form/export-default-import/_expected/iife.js @@ -0,0 +1,10 @@ +(function (exports,x) { + 'use strict'; + + x = 'default' in x ? x['default'] : x; + + + + exports.x = x; + +}((this.myBundle = this.myBundle || {}),x)); \ No newline at end of file diff --git a/test/form/export-default-import/_expected/umd.js b/test/form/export-default-import/_expected/umd.js new file mode 100644 index 0000000..872c0d8 --- /dev/null +++ b/test/form/export-default-import/_expected/umd.js @@ -0,0 +1,13 @@ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('x')) : + typeof define === 'function' && define.amd ? define(['exports', 'x'], factory) : + (factory((global.myBundle = global.myBundle || {}),global.x)); +}(this, function (exports,x) { 'use strict'; + + x = 'default' in x ? x['default'] : x; + + + + exports.x = x; + +})); \ No newline at end of file diff --git a/test/form/export-default-import/main.js b/test/form/export-default-import/main.js new file mode 100644 index 0000000..31bb602 --- /dev/null +++ b/test/form/export-default-import/main.js @@ -0,0 +1,3 @@ +import x from 'x'; + +export { x };