From be15ec33a687bb682ecb05fab704b933f39ca332 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oskar=20Segersv=C3=A4rd?= Date: Fri, 4 Sep 2015 17:11:11 +0200 Subject: [PATCH] Simplified Statement.mark by moving reexport special case to analyze --- src/Statement.js | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/Statement.js b/src/Statement.js index 35c5ee3..e43ef01 100644 --- a/src/Statement.js +++ b/src/Statement.js @@ -53,6 +53,19 @@ export default class Statement { analyse () { if ( this.isImportDeclaration ) return; // nothing to analyse + // `export { name } from './other'` is a special case + if ( this.isReexportDeclaration ) { + this.node.specifiers && this.node.specifiers.forEach( specifier => { + const id = this.module.exports.lookup( specifier.exported.name ); + + if ( !~this.dependantIds.indexOf( id ) ) { + this.dependantIds.push( id ); + } + }); + + return; + } + let scope = this.scope; walk( this.node, { @@ -339,17 +352,6 @@ export default class Statement { if ( this.isIncluded ) return; // prevent infinite loops this.isIncluded = true; - // `export { name } from './other'` is a special case - if ( this.isReexportDeclaration ) { - // TODO: If we add the specifiers to `dependantIds`, - // we can remove this special case. - this.node.specifiers.forEach( specifier => { - this.module.exports.lookup( specifier.exported.name ).mark(); - }); - - return; - } - this.dependantIds.forEach( id => id.mark() ); // TODO: perhaps these could also be added?