Skip to content

Commit

Permalink
Make sure Program nodes are really only included if they have an effect
Browse files Browse the repository at this point in the history
  • Loading branch information
lukastaegert committed Apr 16, 2018
1 parent 93f75b6 commit 3e1c6fc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Module.ts
Expand Up @@ -562,7 +562,7 @@ export default class Module {
}

include() {
return this.ast.include();
return this.ast.shouldBeIncluded() && this.ast.include();
}

namespace(): NamespaceVariable {
Expand Down
7 changes: 7 additions & 0 deletions src/ast/nodes/Program.ts
Expand Up @@ -2,12 +2,19 @@ import MagicString from 'magic-string';
import { NodeBase, StatementNode } from './shared/Node';
import { NodeType } from './NodeType';
import { RenderOptions, renderStatementList } from '../../utils/renderHelpers';
import ExecutionPathOptions from '../ExecutionPathOptions';

export default class Program extends NodeBase {
type: NodeType.Program;
body: StatementNode[];
sourceType: 'module';

hasEffects(options: ExecutionPathOptions) {
for (const node of this.body) {
if (node.hasEffects(options)) return true;
}
}

include() {
let anotherPassNeeded = false;
this.included = true;
Expand Down

0 comments on commit 3e1c6fc

Please sign in to comment.