Browse Source

empty imports are assumed to have side-effects

contingency-plan
Rich Harris 10 years ago
parent
commit
876f10825d
  1. 17
      src/Module.js

17
src/Module.js

@ -356,7 +356,22 @@ export default class Module {
if ( statement._included ) return;
// skip import declarations
if ( /^Import/.test( statement.type ) ) return;
if ( statement.type === 'ImportDeclaration' ) {
// unless they're empty, in which case assume we're importing them for the side-effects
// THIS IS NOT FOOLPROOF. Probably need /*rollup: include */ or similar
if ( !statement.specifiers.length ) {
return this.bundle.fetchModule( statement.source.value, this.path )
.then( module => {
statement.module = module;
return module.expandAllStatements();
})
.then( statements => {
allStatements.push.apply( allStatements, statements );
});
}
return;
}
// skip `export { foo, bar, baz }`
if ( statement.type === 'ExportNamedDeclaration' && statement.specifiers.length ) {

Loading…
Cancel
Save