You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
import { keys } from '../utils/object';
|
|
|
|
|
|
|
|
export default function es6 ( bundle, magicString, exportMode, options ) {
|
|
|
|
const introBlock = ''; // TODO...
|
|
|
|
|
|
|
|
const exports = bundle.entryModule.exports;
|
|
|
|
const exportBlock = keys( exports ).map( exportedName => {
|
|
|
|
const specifier = exports[ exportedName ];
|
|
|
|
|
|
|
|
const canonicalName = bundle.entryModule.getCanonicalName( specifier.localName );
|
|
|
|
|
|
|
|
if ( exportedName === 'default' ) {
|
|
|
|
return `export default ${canonicalName};`;
|
|
|
|
}
|
|
|
|
|
|
|
|
return exportedName === canonicalName ?
|
|
|
|
`export { ${exportedName} };` :
|
|
|
|
`export { ${canonicalName} as ${exportedName} };`;
|
|
|
|
}).join( '\n' );
|
|
|
|
|
|
|
|
if ( exportBlock ) {
|
|
|
|
magicString.append( '\n\n' + exportBlock );
|
|
|
|
}
|
|
|
|
|
|
|
|
return magicString.trim();
|
|
|
|
}
|