diff --git a/src/Module.js b/src/Module.js index 8719a53..778be9b 100644 --- a/src/Module.js +++ b/src/Module.js @@ -297,8 +297,18 @@ export default class Module { let allStatements = []; return sequence( this.statements, statement => { - // skip already-included statements - if ( statement.isIncluded ) return; + // A statement may have already been included, in which case we need to + // curb rollup's enthusiasm and move it down here. It remains to be seen + // if this approach is bulletproof + if ( statement.isIncluded ) { + const index = allStatements.indexOf( statement ); + if ( ~index ) { + allStatements.splice( index, 1 ); + allStatements.push( statement ); + } + + return; + } // skip import declarations... if ( statement.isImportDeclaration ) {