Browse Source

err on side of caution with late definitions

better-aggressive
Rich-Harris 9 years ago
parent
commit
f1ad31c8ba
  1. 2
      src/Declaration.js
  2. 2
      test/form/side-effect-e/_config.js
  3. 6
      test/form/side-effect-j/_config.js
  4. 5
      test/form/side-effect-j/_expected/amd.js
  5. 1
      test/form/side-effect-j/_expected/cjs.js
  6. 0
      test/form/side-effect-j/_expected/es6.js
  7. 0
      test/form/side-effect-j/_expected/iife.js
  8. 0
      test/form/side-effect-j/_expected/umd.js
  9. 4
      test/form/side-effect-j/foo.js
  10. 4
      test/form/side-effect-j/main.js

2
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 );
}

2
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'
}

6
test/form/side-effect-j/_config.js

@ -0,0 +1,6 @@
module.exports = {
description: 'includes late function declarations with side-effects',
options: {
moduleName: 'myBundle'
}
};

5
test/form/side-effect-j/_expected/amd.js

@ -0,0 +1,5 @@
define(function () { 'use strict';
});

1
test/form/side-effect-j/_expected/cjs.js

@ -0,0 +1 @@
'use strict';

0
test/form/side-effect-j/_expected/es6.js

0
test/form/side-effect-j/_expected/iife.js

0
test/form/side-effect-j/_expected/umd.js

4
test/form/side-effect-j/foo.js

@ -0,0 +1,4 @@
var augment;
augment = x => x.augmented = true;
export { augment };

4
test/form/side-effect-j/main.js

@ -0,0 +1,4 @@
import { augment } from './foo.js';
export default function x () {}
augment( x );
Loading…
Cancel
Save