From 76502ea6774f5b83f876d329d6a91ee91c6d19ec Mon Sep 17 00:00:00 2001 From: Rich-Harris Date: Sat, 14 Nov 2015 13:01:18 -0500 Subject: [PATCH 1/7] make aggressive mode a bit less aggressive --- src/Bundle.js | 12 +++++------- src/Declaration.js | 10 +++++----- src/Module.js | 4 ++-- src/Statement.js | 4 ++-- src/utils/run.js | 16 +++++++++------- test/function/aggressive-mode/_config.js | 8 ++++++++ test/function/aggressive-mode/foo.js | 11 +++++++++++ test/function/aggressive-mode/main.js | 3 +++ 8 files changed, 45 insertions(+), 23 deletions(-) create mode 100644 test/function/aggressive-mode/_config.js create mode 100644 test/function/aggressive-mode/foo.js create mode 100644 test/function/aggressive-mode/main.js diff --git a/src/Bundle.js b/src/Bundle.js index 1d3255b..0a670d2 100644 --- a/src/Bundle.js +++ b/src/Bundle.js @@ -82,17 +82,15 @@ export default class Bundle { }); // mark statements that should appear in the bundle + const safe = !this.aggressive; + let settled = false; while ( !settled ) { settled = true; - if ( this.aggressive ) { - settled = !entryModule.run(); - } else { - this.modules.forEach( module => { - if ( module.run() ) settled = false; - }); - } + this.modules.forEach( module => { + if ( module.run( safe || module === entryModule ) ) settled = false; + }); } // Phase 4 – final preparation. We order the modules with an diff --git a/src/Declaration.js b/src/Declaration.js index 03a5b17..bc343ea 100644 --- a/src/Declaration.js +++ b/src/Declaration.js @@ -39,14 +39,14 @@ export default class Declaration { return `exports.${this.name}`; } - run ( strongDependencies ) { + run ( strongDependencies, safe ) { if ( this.tested ) return this.hasSideEffects; this.tested = true; if ( !this.statement || !this.functionNode ) { this.hasSideEffects = true; // err on the side of caution. TODO handle unambiguous `var x; x = y => z` cases } else { - this.hasSideEffects = run( this.functionNode.body, this.functionNode._scope, this.statement, strongDependencies ); + this.hasSideEffects = run( this.functionNode.body, this.functionNode._scope, this.statement, strongDependencies, false, safe ); } return this.hasSideEffects; @@ -93,13 +93,13 @@ export class SyntheticDefaultDeclaration { this.original.render(); } - run ( strongDependencies ) { + run ( strongDependencies, safe ) { if ( this.original ) { - return this.original.run( strongDependencies ); + return this.original.run( strongDependencies, safe ); } if ( /FunctionExpression/.test( this.node.declaration.type ) ) { - return run( this.node.declaration.body, this.statement.scope, this.statement, strongDependencies ); + return run( this.node.declaration.body, this.statement.scope, this.statement, strongDependencies, false, safe ); } } diff --git a/src/Module.js b/src/Module.js index 1c50b10..e1965ab 100644 --- a/src/Module.js +++ b/src/Module.js @@ -559,11 +559,11 @@ export default class Module { return magicString.trim(); } - run () { + run ( safe ) { let marked = false; this.statements.forEach( statement => { - marked = marked || statement.run( this.strongDependencies ); + marked = marked || statement.run( this.strongDependencies, safe ); }); return marked; diff --git a/src/Statement.js b/src/Statement.js index f374a2b..b4a707e 100644 --- a/src/Statement.js +++ b/src/Statement.js @@ -159,11 +159,11 @@ export default class Statement { }); } - run ( strongDependencies ) { + run ( strongDependencies, safe ) { if ( ( this.ran && this.isIncluded ) || this.isImportDeclaration || this.isFunctionDeclaration ) return; this.ran = true; - if ( run( this.node, this.scope, this, strongDependencies ) ) { + if ( run( this.node, this.scope, this, strongDependencies, false, safe ) ) { this.mark(); return true; } diff --git a/src/utils/run.js b/src/utils/run.js index 1f97b5c..8139a40 100644 --- a/src/utils/run.js +++ b/src/utils/run.js @@ -46,7 +46,7 @@ simdTypes.forEach( t => { -export default function run ( node, scope, statement, strongDependencies, force ) { +export default function run ( node, scope, statement, strongDependencies, force, safe ) { let hasSideEffect = false; walk( node, { @@ -60,7 +60,9 @@ export default function run ( node, scope, statement, strongDependencies, force if ( flattened.name === 'arguments' ) { hasSideEffect = true; - } if ( !scope.contains( flattened.name ) ) { + } + + else if ( !scope.contains( flattened.name ) ) { const declaration = statement.module.trace( flattened.name ); if ( declaration && !declaration.isExternal ) { const module = declaration.module || declaration.statement.module; // TODO is this right? @@ -81,10 +83,10 @@ export default function run ( node, scope, statement, strongDependencies, force statement.module.trace( node.callee.name ); if ( declaration ) { - if ( declaration.isExternal || declaration.run( strongDependencies ) ) { + if ( declaration.isExternal || declaration.run( strongDependencies, safe ) ) { hasSideEffect = true; } - } else if ( !pureFunctions[ node.callee.name ] ) { + } else if ( safe && !pureFunctions[ node.callee.name ] ) { hasSideEffect = true; } } @@ -97,7 +99,7 @@ export default function run ( node, scope, statement, strongDependencies, force // TODO make pureFunctions configurable const declaration = scope.findDeclaration( flattened.name ) || statement.module.trace( flattened.name ); - if ( !!declaration || !pureFunctions[ flattened.keypath ] ) { + if ( safe && ( !!declaration || !pureFunctions[ flattened.keypath ] ) ) { hasSideEffect = true; } } else { @@ -108,7 +110,7 @@ export default function run ( node, scope, statement, strongDependencies, force } // otherwise we're probably dealing with a function expression - else if ( run( node.callee, scope, statement, strongDependencies, true ) ) { + else if ( run( node.callee, scope, statement, strongDependencies, true, safe ) ) { hasSideEffect = true; } } @@ -124,7 +126,7 @@ export default function run ( node, scope, statement, strongDependencies, force } else { declaration = statement.module.trace( subject.name ); - if ( !declaration || declaration.isExternal || declaration.isUsed ) { + if ( ( safe && ( !declaration || declaration.isExternal ) ) || declaration && declaration.isUsed ) { hasSideEffect = true; } } diff --git a/test/function/aggressive-mode/_config.js b/test/function/aggressive-mode/_config.js new file mode 100644 index 0000000..7317b3f --- /dev/null +++ b/test/function/aggressive-mode/_config.js @@ -0,0 +1,8 @@ +module.exports = { + // solo: true, + // show: true, + description: 'aggressive mode distinguishes between necessary and probably-not-necessary side-effects', + options: { + aggressive: true + } +}; diff --git a/test/function/aggressive-mode/foo.js b/test/function/aggressive-mode/foo.js new file mode 100644 index 0000000..15ed18e --- /dev/null +++ b/test/function/aggressive-mode/foo.js @@ -0,0 +1,11 @@ +function Foo () {} + +Foo.prototype = { + answer: function () { + return 42; + } +}; + +export default function foo () { + return new Foo(); +} diff --git a/test/function/aggressive-mode/main.js b/test/function/aggressive-mode/main.js new file mode 100644 index 0000000..707c46a --- /dev/null +++ b/test/function/aggressive-mode/main.js @@ -0,0 +1,3 @@ +import foo from './foo'; + +assert.equal( foo().answer(), 42 ); From c33b3d2437459499b961163b07b01256d8e62259 Mon Sep 17 00:00:00 2001 From: Rich-Harris Date: Sat, 14 Nov 2015 16:58:10 -0500 Subject: [PATCH 2/7] attach statements to all declarations --- src/Declaration.js | 4 ++-- src/Statement.js | 8 +------- src/ast/Scope.js | 5 +++-- 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/src/Declaration.js b/src/Declaration.js index bc343ea..f4d2e0d 100644 --- a/src/Declaration.js +++ b/src/Declaration.js @@ -2,7 +2,7 @@ import { blank, keys } from './utils/object.js'; import run from './utils/run.js'; export default class Declaration { - constructor ( node, isParam ) { + constructor ( node, isParam, statement ) { if ( node ) { if ( node.type === 'FunctionDeclaration' ) { this.isFunctionDeclaration = true; @@ -13,7 +13,7 @@ export default class Declaration { } } - this.statement = null; + this.statement = statement; this.name = null; this.isParam = isParam; diff --git a/src/Statement.js b/src/Statement.js index b4a707e..a9efc49 100644 --- a/src/Statement.js +++ b/src/Statement.js @@ -39,7 +39,7 @@ export default class Statement { this.end = end; this.next = null; // filled in later - this.scope = new Scope(); + this.scope = new Scope({ statement: this }); this.references = []; this.stringLiteralRanges = []; @@ -61,12 +61,6 @@ export default class Statement { // attach scopes attachScopes( this ); - // attach statement to each top-level declaration, - // so we can mark statements easily - this.scope.eachDeclaration( ( name, declaration ) => { - declaration.statement = this; - }); - // find references const statement = this; let { module, references, scope, stringLiteralRanges } = this; diff --git a/src/ast/Scope.js b/src/ast/Scope.js index 1adcd47..508bf31 100644 --- a/src/ast/Scope.js +++ b/src/ast/Scope.js @@ -39,6 +39,7 @@ export default class Scope { options = options || {}; this.parent = options.parent; + this.statement = options.statement || this.parent.statement; this.isBlockScope = !!options.block; this.isTopLevel = !this.parent || ( this.parent.isTopLevel && this.isBlockScope ); @@ -47,7 +48,7 @@ export default class Scope { if ( options.params ) { options.params.forEach( param => { extractNames( param ).forEach( name => { - this.declarations[ name ] = new Declaration( param, true ); + this.declarations[ name ] = new Declaration( param, true, this.statement ); }); }); } @@ -60,7 +61,7 @@ export default class Scope { this.parent.addDeclaration( node, isBlockDeclaration, isVar ); } else { extractNames( node.id ).forEach( name => { - this.declarations[ name ] = new Declaration( node ); + this.declarations[ name ] = new Declaration( node, false, this.statement ); }); } } From 3db1236024346704706b7a02d2505c8bf183cf98 Mon Sep 17 00:00:00 2001 From: Rich-Harris Date: Sat, 14 Nov 2015 16:58:38 -0500 Subject: [PATCH 3/7] additional side effect test --- test/form/side-effect-l/_config.js | 3 +++ test/form/side-effect-l/_expected/amd.js | 5 +++++ test/form/side-effect-l/_expected/cjs.js | 1 + test/form/side-effect-l/_expected/es6.js | 0 test/form/side-effect-l/_expected/iife.js | 5 +++++ test/form/side-effect-l/_expected/umd.js | 9 +++++++++ test/form/side-effect-l/foo.js | 6 ++++++ test/form/side-effect-l/main.js | 1 + 8 files changed, 30 insertions(+) create mode 100644 test/form/side-effect-l/_config.js create mode 100644 test/form/side-effect-l/_expected/amd.js create mode 100644 test/form/side-effect-l/_expected/cjs.js create mode 100644 test/form/side-effect-l/_expected/es6.js create mode 100644 test/form/side-effect-l/_expected/iife.js create mode 100644 test/form/side-effect-l/_expected/umd.js create mode 100644 test/form/side-effect-l/foo.js create mode 100644 test/form/side-effect-l/main.js diff --git a/test/form/side-effect-l/_config.js b/test/form/side-effect-l/_config.js new file mode 100644 index 0000000..51f192c --- /dev/null +++ b/test/form/side-effect-l/_config.js @@ -0,0 +1,3 @@ +module.exports = { + description: 'discards function with no side-effects in imported module' +}; diff --git a/test/form/side-effect-l/_expected/amd.js b/test/form/side-effect-l/_expected/amd.js new file mode 100644 index 0000000..f9f8229 --- /dev/null +++ b/test/form/side-effect-l/_expected/amd.js @@ -0,0 +1,5 @@ +define(function () { 'use strict'; + + + +}); diff --git a/test/form/side-effect-l/_expected/cjs.js b/test/form/side-effect-l/_expected/cjs.js new file mode 100644 index 0000000..ad9a93a --- /dev/null +++ b/test/form/side-effect-l/_expected/cjs.js @@ -0,0 +1 @@ +'use strict'; diff --git a/test/form/side-effect-l/_expected/es6.js b/test/form/side-effect-l/_expected/es6.js new file mode 100644 index 0000000..e69de29 diff --git a/test/form/side-effect-l/_expected/iife.js b/test/form/side-effect-l/_expected/iife.js new file mode 100644 index 0000000..fe68252 --- /dev/null +++ b/test/form/side-effect-l/_expected/iife.js @@ -0,0 +1,5 @@ +(function () { 'use strict'; + + + +})(); diff --git a/test/form/side-effect-l/_expected/umd.js b/test/form/side-effect-l/_expected/umd.js new file mode 100644 index 0000000..c833540 --- /dev/null +++ b/test/form/side-effect-l/_expected/umd.js @@ -0,0 +1,9 @@ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? factory() : + typeof define === 'function' && define.amd ? define(factory) : + factory(); +}(this, function () { 'use strict'; + + + +})); diff --git a/test/form/side-effect-l/foo.js b/test/form/side-effect-l/foo.js new file mode 100644 index 0000000..e37fcd7 --- /dev/null +++ b/test/form/side-effect-l/foo.js @@ -0,0 +1,6 @@ +export default function foo () { + bar(); + function bar () {} +} + +var x = foo(); diff --git a/test/form/side-effect-l/main.js b/test/form/side-effect-l/main.js new file mode 100644 index 0000000..025664b --- /dev/null +++ b/test/form/side-effect-l/main.js @@ -0,0 +1 @@ +import './foo.js'; From 2ded15a0d8fa38639c1f6ac171e5bf7c64b1a223 Mon Sep 17 00:00:00 2001 From: Rich-Harris Date: Sat, 14 Nov 2015 17:27:12 -0500 Subject: [PATCH 4/7] unify APIs --- src/Declaration.js | 6 +++++- src/utils/run.js | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Declaration.js b/src/Declaration.js index f4d2e0d..31f9345 100644 --- a/src/Declaration.js +++ b/src/Declaration.js @@ -43,7 +43,7 @@ export default class Declaration { if ( this.tested ) return this.hasSideEffects; this.tested = true; - if ( !this.statement || !this.functionNode ) { + if ( !this.functionNode ) { this.hasSideEffects = true; // err on the side of caution. TODO handle unambiguous `var x; x = y => z` cases } else { this.hasSideEffects = run( this.functionNode.body, this.functionNode._scope, this.statement, strongDependencies, false, safe ); @@ -224,6 +224,10 @@ export class ExternalDeclaration { return es6 ? this.name : `${this.module.name}.${this.name}`; } + run ( strongDependencies, safe ) { + return safe; + } + use () { // noop? } diff --git a/src/utils/run.js b/src/utils/run.js index 8139a40..2d9ca6e 100644 --- a/src/utils/run.js +++ b/src/utils/run.js @@ -83,7 +83,7 @@ export default function run ( node, scope, statement, strongDependencies, force, statement.module.trace( node.callee.name ); if ( declaration ) { - if ( declaration.isExternal || declaration.run( strongDependencies, safe ) ) { + if ( declaration.run( strongDependencies, safe ) ) { hasSideEffect = true; } } else if ( safe && !pureFunctions[ node.callee.name ] ) { @@ -104,7 +104,7 @@ export default function run ( node, scope, statement, strongDependencies, force, } } else { // is not a keypath like `foo.bar.baz` – could be e.g. - // `(a || b).foo()`. Err on the side of caution + // `foo[bar].baz()`. Err on the side of caution hasSideEffect = true; } } From 5beac6d85ef3f10335594f0a01835212bf34722c Mon Sep 17 00:00:00 2001 From: Rich-Harris Date: Sat, 14 Nov 2015 17:36:47 -0500 Subject: [PATCH 5/7] remove aggressive mode --- src/Bundle.js | 4 +--- src/Declaration.js | 14 +++++++------- src/utils/run.js | 12 ++++++------ test/form/aggressive/_config.js | 6 ------ test/form/aggressive/_expected/amd.js | 9 --------- test/form/aggressive/_expected/cjs.js | 7 ------- test/form/aggressive/_expected/es6.js | 5 ----- test/form/aggressive/_expected/iife.js | 9 --------- test/form/aggressive/_expected/umd.js | 13 ------------- test/form/aggressive/foo.js | 9 --------- test/form/aggressive/main.js | 3 --- test/function/aggressive-mode/_config.js | 8 -------- test/function/aggressive-mode/foo.js | 11 ----------- test/function/aggressive-mode/main.js | 3 --- 14 files changed, 14 insertions(+), 99 deletions(-) delete mode 100644 test/form/aggressive/_config.js delete mode 100644 test/form/aggressive/_expected/amd.js delete mode 100644 test/form/aggressive/_expected/cjs.js delete mode 100644 test/form/aggressive/_expected/es6.js delete mode 100644 test/form/aggressive/_expected/iife.js delete mode 100644 test/form/aggressive/_expected/umd.js delete mode 100644 test/form/aggressive/foo.js delete mode 100644 test/form/aggressive/main.js delete mode 100644 test/function/aggressive-mode/_config.js delete mode 100644 test/function/aggressive-mode/foo.js delete mode 100644 test/function/aggressive-mode/main.js diff --git a/src/Bundle.js b/src/Bundle.js index 0a670d2..9f66026 100644 --- a/src/Bundle.js +++ b/src/Bundle.js @@ -82,14 +82,12 @@ export default class Bundle { }); // mark statements that should appear in the bundle - const safe = !this.aggressive; - let settled = false; while ( !settled ) { settled = true; this.modules.forEach( module => { - if ( module.run( safe || module === entryModule ) ) settled = false; + if ( module.run() ) settled = false; }); } diff --git a/src/Declaration.js b/src/Declaration.js index 31f9345..76c7fa1 100644 --- a/src/Declaration.js +++ b/src/Declaration.js @@ -39,14 +39,14 @@ export default class Declaration { return `exports.${this.name}`; } - run ( strongDependencies, safe ) { + run ( strongDependencies ) { if ( this.tested ) return this.hasSideEffects; this.tested = true; if ( !this.functionNode ) { this.hasSideEffects = true; // err on the side of caution. TODO handle unambiguous `var x; x = y => z` cases } else { - this.hasSideEffects = run( this.functionNode.body, this.functionNode._scope, this.statement, strongDependencies, false, safe ); + this.hasSideEffects = run( this.functionNode.body, this.functionNode._scope, this.statement, strongDependencies, false ); } return this.hasSideEffects; @@ -93,13 +93,13 @@ export class SyntheticDefaultDeclaration { this.original.render(); } - run ( strongDependencies, safe ) { + run ( strongDependencies ) { if ( this.original ) { - return this.original.run( strongDependencies, safe ); + return this.original.run( strongDependencies ); } if ( /FunctionExpression/.test( this.node.declaration.type ) ) { - return run( this.node.declaration.body, this.statement.scope, this.statement, strongDependencies, false, safe ); + return run( this.node.declaration.body, this.statement.scope, this.statement, strongDependencies, false ); } } @@ -224,8 +224,8 @@ export class ExternalDeclaration { return es6 ? this.name : `${this.module.name}.${this.name}`; } - run ( strongDependencies, safe ) { - return safe; + run ( strongDependencies ) { + return true; } use () { diff --git a/src/utils/run.js b/src/utils/run.js index 2d9ca6e..ac303f1 100644 --- a/src/utils/run.js +++ b/src/utils/run.js @@ -46,7 +46,7 @@ simdTypes.forEach( t => { -export default function run ( node, scope, statement, strongDependencies, force, safe ) { +export default function run ( node, scope, statement, strongDependencies, force ) { let hasSideEffect = false; walk( node, { @@ -83,10 +83,10 @@ export default function run ( node, scope, statement, strongDependencies, force, statement.module.trace( node.callee.name ); if ( declaration ) { - if ( declaration.run( strongDependencies, safe ) ) { + if ( declaration.run( strongDependencies ) ) { hasSideEffect = true; } - } else if ( safe && !pureFunctions[ node.callee.name ] ) { + } else if ( !pureFunctions[ node.callee.name ] ) { hasSideEffect = true; } } @@ -99,7 +99,7 @@ export default function run ( node, scope, statement, strongDependencies, force, // TODO make pureFunctions configurable const declaration = scope.findDeclaration( flattened.name ) || statement.module.trace( flattened.name ); - if ( safe && ( !!declaration || !pureFunctions[ flattened.keypath ] ) ) { + if ( !!declaration || !pureFunctions[ flattened.keypath ] ) { hasSideEffect = true; } } else { @@ -110,7 +110,7 @@ export default function run ( node, scope, statement, strongDependencies, force, } // otherwise we're probably dealing with a function expression - else if ( run( node.callee, scope, statement, strongDependencies, true, safe ) ) { + else if ( run( node.callee, scope, statement, strongDependencies, true ) ) { hasSideEffect = true; } } @@ -126,7 +126,7 @@ export default function run ( node, scope, statement, strongDependencies, force, } else { declaration = statement.module.trace( subject.name ); - if ( ( safe && ( !declaration || declaration.isExternal ) ) || declaration && declaration.isUsed ) { + if ( !declaration || declaration.isExternal || declaration.isUsed ) { hasSideEffect = true; } } diff --git a/test/form/aggressive/_config.js b/test/form/aggressive/_config.js deleted file mode 100644 index bafb1e0..0000000 --- a/test/form/aggressive/_config.js +++ /dev/null @@ -1,6 +0,0 @@ -module.exports = { - description: 'ignores side-effects outside entry module in aggressive mode', - options: { - aggressive: true - } -} diff --git a/test/form/aggressive/_expected/amd.js b/test/form/aggressive/_expected/amd.js deleted file mode 100644 index eac4f98..0000000 --- a/test/form/aggressive/_expected/amd.js +++ /dev/null @@ -1,9 +0,0 @@ -define(function () { 'use strict'; - - function foo () { - return 42; - } - - assert.equal( foo(), 42 ); - -}); \ No newline at end of file diff --git a/test/form/aggressive/_expected/cjs.js b/test/form/aggressive/_expected/cjs.js deleted file mode 100644 index a547fb6..0000000 --- a/test/form/aggressive/_expected/cjs.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -function foo () { - return 42; -} - -assert.equal( foo(), 42 ); \ No newline at end of file diff --git a/test/form/aggressive/_expected/es6.js b/test/form/aggressive/_expected/es6.js deleted file mode 100644 index f32ad00..0000000 --- a/test/form/aggressive/_expected/es6.js +++ /dev/null @@ -1,5 +0,0 @@ -function foo () { - return 42; -} - -assert.equal( foo(), 42 ); \ No newline at end of file diff --git a/test/form/aggressive/_expected/iife.js b/test/form/aggressive/_expected/iife.js deleted file mode 100644 index 3ba1058..0000000 --- a/test/form/aggressive/_expected/iife.js +++ /dev/null @@ -1,9 +0,0 @@ -(function () { 'use strict'; - - function foo () { - return 42; - } - - assert.equal( foo(), 42 ); - -})(); \ No newline at end of file diff --git a/test/form/aggressive/_expected/umd.js b/test/form/aggressive/_expected/umd.js deleted file mode 100644 index 1eb1ef2..0000000 --- a/test/form/aggressive/_expected/umd.js +++ /dev/null @@ -1,13 +0,0 @@ -(function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? factory() : - typeof define === 'function' && define.amd ? define(factory) : - factory(); -}(this, function () { 'use strict'; - - function foo () { - return 42; - } - - assert.equal( foo(), 42 ); - -})); \ No newline at end of file diff --git a/test/form/aggressive/foo.js b/test/form/aggressive/foo.js deleted file mode 100644 index 16f57e9..0000000 --- a/test/form/aggressive/foo.js +++ /dev/null @@ -1,9 +0,0 @@ -function x () { - console.log( 'side-effect' ); -} - -x(); - -export function foo () { - return 42; -} diff --git a/test/form/aggressive/main.js b/test/form/aggressive/main.js deleted file mode 100644 index 66c6979..0000000 --- a/test/form/aggressive/main.js +++ /dev/null @@ -1,3 +0,0 @@ -import { foo } from './foo'; - -assert.equal( foo(), 42 ); diff --git a/test/function/aggressive-mode/_config.js b/test/function/aggressive-mode/_config.js deleted file mode 100644 index 7317b3f..0000000 --- a/test/function/aggressive-mode/_config.js +++ /dev/null @@ -1,8 +0,0 @@ -module.exports = { - // solo: true, - // show: true, - description: 'aggressive mode distinguishes between necessary and probably-not-necessary side-effects', - options: { - aggressive: true - } -}; diff --git a/test/function/aggressive-mode/foo.js b/test/function/aggressive-mode/foo.js deleted file mode 100644 index 15ed18e..0000000 --- a/test/function/aggressive-mode/foo.js +++ /dev/null @@ -1,11 +0,0 @@ -function Foo () {} - -Foo.prototype = { - answer: function () { - return 42; - } -}; - -export default function foo () { - return new Foo(); -} diff --git a/test/function/aggressive-mode/main.js b/test/function/aggressive-mode/main.js deleted file mode 100644 index 707c46a..0000000 --- a/test/function/aggressive-mode/main.js +++ /dev/null @@ -1,3 +0,0 @@ -import foo from './foo'; - -assert.equal( foo().answer(), 42 ); From 79730115c974f7859daea83afc2819f1e7dc34a7 Mon Sep 17 00:00:00 2001 From: Rich-Harris Date: Sat, 14 Nov 2015 17:39:01 -0500 Subject: [PATCH 6/7] tidy up --- src/Bundle.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Bundle.js b/src/Bundle.js index 9f66026..27f4a04 100644 --- a/src/Bundle.js +++ b/src/Bundle.js @@ -49,7 +49,6 @@ export default class Bundle { this.external = options.external || []; this.onwarn = options.onwarn || onwarn; - this.aggressive = options.aggressive; // TODO strictly speaking, this only applies with non-ES6, non-default-only bundles [ 'module', 'exports' ].forEach( global => this.assumedGlobals[ global ] = true ); From c11dcb513face4d73cc3478d0693f757ffc8136c Mon Sep 17 00:00:00 2001 From: Rich-Harris Date: Fri, 27 Nov 2015 19:47:40 -0500 Subject: [PATCH 7/7] lint --- src/Declaration.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Declaration.js b/src/Declaration.js index d5e69b6..2b7556e 100644 --- a/src/Declaration.js +++ b/src/Declaration.js @@ -226,7 +226,7 @@ export class ExternalDeclaration { return es6 ? this.name : `${this.module.name}.${this.name}`; } - run ( strongDependencies ) { + run () { return true; }