diff --git a/src/Declaration.js b/src/Declaration.js index 74c39c2..abe86b5 100644 --- a/src/Declaration.js +++ b/src/Declaration.js @@ -37,7 +37,7 @@ export default class Declaration { this.tested = true; if ( !this.statement || !this.functionNode ) { - this.hasSideEffects = false; + this.hasSideEffects = true; // err on the side of caution. TODO handle unambiguous `var x; x = y => z` cases } else { this.hasSideEffects = testForSideEffects( this.functionNode.body, this.functionNode._scope, this.statement, strongDependencies ); } diff --git a/test/form/side-effect-e/_config.js b/test/form/side-effect-e/_config.js index a8d5bf9..225bacd 100644 --- a/test/form/side-effect-e/_config.js +++ b/test/form/side-effect-e/_config.js @@ -1,5 +1,5 @@ module.exports = { - description: 'excludes functions that are known to be pure', + description: 'accounts for local scopes when tested function purity', options: { moduleName: 'myBundle' } diff --git a/test/form/side-effect-j/_config.js b/test/form/side-effect-j/_config.js new file mode 100644 index 0000000..91550c0 --- /dev/null +++ b/test/form/side-effect-j/_config.js @@ -0,0 +1,6 @@ +module.exports = { + description: 'includes late function declarations with side-effects', + options: { + moduleName: 'myBundle' + } +}; diff --git a/test/form/side-effect-j/_expected/amd.js b/test/form/side-effect-j/_expected/amd.js new file mode 100644 index 0000000..85bce30 --- /dev/null +++ b/test/form/side-effect-j/_expected/amd.js @@ -0,0 +1,5 @@ +define(function () { 'use strict'; + + + +}); diff --git a/test/form/side-effect-j/_expected/cjs.js b/test/form/side-effect-j/_expected/cjs.js new file mode 100644 index 0000000..ad9a93a --- /dev/null +++ b/test/form/side-effect-j/_expected/cjs.js @@ -0,0 +1 @@ +'use strict'; diff --git a/test/form/side-effect-j/_expected/es6.js b/test/form/side-effect-j/_expected/es6.js new file mode 100644 index 0000000..e69de29 diff --git a/test/form/side-effect-j/_expected/iife.js b/test/form/side-effect-j/_expected/iife.js new file mode 100644 index 0000000..e69de29 diff --git a/test/form/side-effect-j/_expected/umd.js b/test/form/side-effect-j/_expected/umd.js new file mode 100644 index 0000000..e69de29 diff --git a/test/form/side-effect-j/foo.js b/test/form/side-effect-j/foo.js new file mode 100644 index 0000000..2f4073f --- /dev/null +++ b/test/form/side-effect-j/foo.js @@ -0,0 +1,4 @@ +var augment; +augment = x => x.augmented = true; + +export { augment }; diff --git a/test/form/side-effect-j/main.js b/test/form/side-effect-j/main.js new file mode 100644 index 0000000..3032b85 --- /dev/null +++ b/test/form/side-effect-j/main.js @@ -0,0 +1,4 @@ +import { augment } from './foo.js'; + +export default function x () {} +augment( x );