Browse Source

dont undo hasSideEffects

better-aggressive
Rich-Harris 10 years ago
parent
commit
dfcfb92929
  1. 4
      src/utils/testForSideEffects.js
  2. 27
      test/form/side-effect-k/_expected/amd.js
  3. 25
      test/form/side-effect-k/_expected/cjs.js
  4. 24
      test/form/side-effect-k/_expected/es6.js
  5. 28
      test/form/side-effect-k/_expected/iife.js
  6. 32
      test/form/side-effect-k/_expected/umd.js

4
src/utils/testForSideEffects.js

@ -38,7 +38,7 @@ export default function testForSideEffects ( node, scope, statement, strongDepen
else if ( node.type === 'ThrowStatement' ) {
// we only care about errors thrown at the top level, otherwise
// any function with error checking gets included if called
hasSideEffect = scope.isTopLevel;
if ( scope.isTopLevel ) hasSideEffect = true;
}
else if ( node.type === 'CallExpression' || node.type === 'NewExpression' ) {
@ -86,7 +86,7 @@ export default function testForSideEffects ( node, scope, statement, strongDepen
let declaration = scope.findDeclaration( subject.name );
if ( declaration ) {
hasSideEffect = declaration.isParam;
if ( declaration.isParam ) hasSideEffect = true;
} else {
declaration = statement.module.trace( subject.name );

27
test/form/side-effect-k/_expected/amd.js

@ -1,5 +1,28 @@
define(function () { 'use strict';
function augment ( x ) {
var prop, source;
});
var i = arguments.length;
var sources = Array( i - 1 );
while ( i-- ) {
sources[i-1] = arguments[i];
}
while (source = sources.shift()) {
for (prop in source) {
if (hasOwn.call(source, prop)) {
x[prop] = source[prop];
}
}
}
return x;
}
function x () {}
augment( x.prototype );
return x;
});

25
test/form/side-effect-k/_expected/cjs.js

@ -1 +1,26 @@
'use strict';
function augment ( x ) {
var prop, source;
var i = arguments.length;
var sources = Array( i - 1 );
while ( i-- ) {
sources[i-1] = arguments[i];
}
while (source = sources.shift()) {
for (prop in source) {
if (hasOwn.call(source, prop)) {
x[prop] = source[prop];
}
}
}
return x;
}
function x () {}
augment( x.prototype );
module.exports = x;

24
test/form/side-effect-k/_expected/es6.js

@ -0,0 +1,24 @@
function augment ( x ) {
var prop, source;
var i = arguments.length;
var sources = Array( i - 1 );
while ( i-- ) {
sources[i-1] = arguments[i];
}
while (source = sources.shift()) {
for (prop in source) {
if (hasOwn.call(source, prop)) {
x[prop] = source[prop];
}
}
}
return x;
}
function x () {}
augment( x.prototype );
export default x;

28
test/form/side-effect-k/_expected/iife.js

@ -0,0 +1,28 @@
var myBundle = (function () { 'use strict';
function augment ( x ) {
var prop, source;
var i = arguments.length;
var sources = Array( i - 1 );
while ( i-- ) {
sources[i-1] = arguments[i];
}
while (source = sources.shift()) {
for (prop in source) {
if (hasOwn.call(source, prop)) {
x[prop] = source[prop];
}
}
}
return x;
}
function x () {}
augment( x.prototype );
return x;
})();

32
test/form/side-effect-k/_expected/umd.js

@ -0,0 +1,32 @@
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
global.myBundle = factory();
}(this, function () { 'use strict';
function augment ( x ) {
var prop, source;
var i = arguments.length;
var sources = Array( i - 1 );
while ( i-- ) {
sources[i-1] = arguments[i];
}
while (source = sources.shift()) {
for (prop in source) {
if (hasOwn.call(source, prop)) {
x[prop] = source[prop];
}
}
}
return x;
}
function x () {}
augment( x.prototype );
return x;
}));
Loading…
Cancel
Save