mirror of https://github.com/lukechilds/rollup.git
Rich-Harris
8 years ago
12 changed files with 218 additions and 21 deletions
@ -1,7 +0,0 @@ |
|||
import Node from '../Node.js'; |
|||
|
|||
export default class ReturnStatement extends Node { |
|||
// hasEffects () {
|
|||
// return true;
|
|||
// }
|
|||
} |
@ -0,0 +1,6 @@ |
|||
module.exports = { |
|||
description: 'preserves side-effects inside promises (#786)', |
|||
options: { |
|||
moduleName: 'myBundle' |
|||
} |
|||
}; |
@ -0,0 +1,32 @@ |
|||
define(['exports'], function (exports) { 'use strict'; |
|||
|
|||
function x () { |
|||
return new Promise( ( resolve, reject ) => { |
|||
console.log( 'this is a side-effect' ); |
|||
resolve(); |
|||
}); |
|||
} |
|||
|
|||
x(); |
|||
|
|||
function promiseCallback ( resolve, reject ) { |
|||
console.log( 'this is a side-effect' ); |
|||
resolve(); |
|||
} |
|||
|
|||
function y () { |
|||
return new Promise( promiseCallback ); |
|||
} |
|||
|
|||
y(); |
|||
|
|||
function z ( x ) { |
|||
// this function has no side-effects, so should be excluded...
|
|||
} |
|||
|
|||
exports.a = 1; |
|||
z( exports.a += 1 ); // ...unless the call expression statement has its own side-effects
|
|||
|
|||
Object.defineProperty(exports, '__esModule', { value: true }); |
|||
|
|||
}); |
@ -0,0 +1,30 @@ |
|||
'use strict'; |
|||
|
|||
Object.defineProperty(exports, '__esModule', { value: true }); |
|||
|
|||
function x () { |
|||
return new Promise( ( resolve, reject ) => { |
|||
console.log( 'this is a side-effect' ); |
|||
resolve(); |
|||
}); |
|||
} |
|||
|
|||
x(); |
|||
|
|||
function promiseCallback ( resolve, reject ) { |
|||
console.log( 'this is a side-effect' ); |
|||
resolve(); |
|||
} |
|||
|
|||
function y () { |
|||
return new Promise( promiseCallback ); |
|||
} |
|||
|
|||
y(); |
|||
|
|||
function z ( x ) { |
|||
// this function has no side-effects, so should be excluded...
|
|||
} |
|||
|
|||
exports.a = 1; |
|||
z( exports.a += 1 ); // ...unless the call expression statement has its own side-effects
|
@ -0,0 +1,28 @@ |
|||
function x () { |
|||
return new Promise( ( resolve, reject ) => { |
|||
console.log( 'this is a side-effect' ); |
|||
resolve(); |
|||
}); |
|||
} |
|||
|
|||
x(); |
|||
|
|||
function promiseCallback ( resolve, reject ) { |
|||
console.log( 'this is a side-effect' ); |
|||
resolve(); |
|||
} |
|||
|
|||
function y () { |
|||
return new Promise( promiseCallback ); |
|||
} |
|||
|
|||
y(); |
|||
|
|||
function z ( x ) { |
|||
// this function has no side-effects, so should be excluded...
|
|||
} |
|||
|
|||
let a = 1; |
|||
z( a += 1 ); // ...unless the call expression statement has its own side-effects
|
|||
|
|||
export { a }; |
@ -0,0 +1,31 @@ |
|||
(function (exports) { |
|||
'use strict'; |
|||
|
|||
function x () { |
|||
return new Promise( ( resolve, reject ) => { |
|||
console.log( 'this is a side-effect' ); |
|||
resolve(); |
|||
}); |
|||
} |
|||
|
|||
x(); |
|||
|
|||
function promiseCallback ( resolve, reject ) { |
|||
console.log( 'this is a side-effect' ); |
|||
resolve(); |
|||
} |
|||
|
|||
function y () { |
|||
return new Promise( promiseCallback ); |
|||
} |
|||
|
|||
y(); |
|||
|
|||
function z ( x ) { |
|||
// this function has no side-effects, so should be excluded...
|
|||
} |
|||
|
|||
exports.a = 1; |
|||
z( exports.a += 1 ); // ...unless the call expression statement has its own side-effects
|
|||
|
|||
}((this.myBundle = this.myBundle || {}))); |
@ -0,0 +1,36 @@ |
|||
(function (global, factory) { |
|||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : |
|||
typeof define === 'function' && define.amd ? define(['exports'], factory) : |
|||
(factory((global.myBundle = global.myBundle || {}))); |
|||
}(this, (function (exports) { 'use strict'; |
|||
|
|||
function x () { |
|||
return new Promise( ( resolve, reject ) => { |
|||
console.log( 'this is a side-effect' ); |
|||
resolve(); |
|||
}); |
|||
} |
|||
|
|||
x(); |
|||
|
|||
function promiseCallback ( resolve, reject ) { |
|||
console.log( 'this is a side-effect' ); |
|||
resolve(); |
|||
} |
|||
|
|||
function y () { |
|||
return new Promise( promiseCallback ); |
|||
} |
|||
|
|||
y(); |
|||
|
|||
function z ( x ) { |
|||
// this function has no side-effects, so should be excluded...
|
|||
} |
|||
|
|||
exports.a = 1; |
|||
z( exports.a += 1 ); // ...unless the call expression statement has its own side-effects
|
|||
|
|||
Object.defineProperty(exports, '__esModule', { value: true }); |
|||
|
|||
}))); |
@ -0,0 +1,28 @@ |
|||
function x () { |
|||
return new Promise( ( resolve, reject ) => { |
|||
console.log( 'this is a side-effect' ); |
|||
resolve(); |
|||
}); |
|||
} |
|||
|
|||
x(); |
|||
|
|||
function promiseCallback ( resolve, reject ) { |
|||
console.log( 'this is a side-effect' ); |
|||
resolve(); |
|||
} |
|||
|
|||
function y () { |
|||
return new Promise( promiseCallback ); |
|||
} |
|||
|
|||
y(); |
|||
|
|||
function z ( x ) { |
|||
// this function has no side-effects, so should be excluded...
|
|||
} |
|||
|
|||
let a = 1; |
|||
z( a += 1 ); // ...unless the call expression statement has its own side-effects
|
|||
|
|||
export { a }; |
Loading…
Reference in new issue