Browse Source

Avoid exports:auto warning on format:es

legacy-quote-reserved-properties
Federico Brigante 8 years ago
parent
commit
a3e7b07e85
  1. 2
      src/Bundle.js
  2. 4
      src/utils/getExportMode.js

2
src/Bundle.js

@ -350,7 +350,7 @@ export default class Bundle {
const format = options.format || 'es';
// Determine export mode - 'default', 'named', 'none'
const exportMode = getExportMode( this, options.exports, options.moduleName );
const exportMode = getExportMode( this, options );
let magicString = new MagicStringBundle({ separator: '\n\n' });
const usedModules = [];

4
src/utils/getExportMode.js

@ -4,7 +4,7 @@ function badExports ( option, keys ) {
throw new Error( `'${option}' was specified for options.exports, but entry module has following exports: ${keys.join(', ')}` );
}
export default function getExportMode ( bundle, exportMode, moduleName ) {
export default function getExportMode ( bundle, {exports: exportMode, moduleName, format} ) {
const exportKeys = keys( bundle.entryModule.exports )
.concat( keys( bundle.entryModule.reexports ) )
.concat( bundle.entryModule.exportAllSources ); // not keys, but makes our job easier this way
@ -23,7 +23,7 @@ export default function getExportMode ( bundle, exportMode, moduleName ) {
} else if ( exportKeys.length === 1 && exportKeys[0] === 'default' ) {
exportMode = 'default';
} else {
if ( bundle.entryModule.exports.default ) {
if ( bundle.entryModule.exports.default && format !== 'es') {
bundle.onwarn( `Using named and default exports together. Consumers of your bundle will have to use ${moduleName || 'bundle'}['default'] to access the default export, which may not be what you want. Use \`exports: 'named'\` to disable this warning. See https://github.com/rollup/rollup/wiki/JavaScript-API#exports for more information` );
}
exportMode = 'named';

Loading…
Cancel
Save