Skip to content

Commit

Permalink
* resolve #1601
Browse files Browse the repository at this point in the history
* resolve #786
  • Loading branch information
lukastaegert committed Aug 31, 2017
1 parent a83b309 commit c15cfe3
Show file tree
Hide file tree
Showing 8 changed files with 135 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/ast/nodes/shared/pureFunctions.js
Expand Up @@ -26,7 +26,7 @@ simdTypes.forEach( t => {
'ArrayBuffer', 'ArrayBuffer.isView',
'DataView',
'JSON.parse', 'JSON.stringify',
'Promise', 'Promise.all', 'Promise.race', 'Promise.reject', 'Promise.resolve',
'Promise.all', 'Promise.race', 'Promise.resolve',
'Intl.Collator', 'Intl.Collator.supportedLocalesOf', 'Intl.DateTimeFormat', 'Intl.DateTimeFormat.supportedLocalesOf', 'Intl.NumberFormat', 'Intl.NumberFormat.supportedLocalesOf'

// TODO properties of e.g. window...
Expand Down
4 changes: 4 additions & 0 deletions test/form/samples/promises/_config.js
@@ -0,0 +1,4 @@
module.exports = {
description: 'do not remove promise creations',
options: { name: 'bundle' }
};
23 changes: 23 additions & 0 deletions test/form/samples/promises/_expected/amd.js
@@ -0,0 +1,23 @@
define(['exports'], function (exports) { 'use strict';

const p1 = new Promise( () => {
console.log( 'fire & forget' );
} );

const p2 = new Promise( () => {
console.info( 'forget me as well' );
} );

const p3 = new Promise( () => {
console.info( 'and me too' );
} );

const p5 = Promise.reject('should be kept for uncaught rejections');

const allExported = Promise.all([p2, p3]);

exports.allExported = allExported;

Object.defineProperty(exports, '__esModule', { value: true });

});
21 changes: 21 additions & 0 deletions test/form/samples/promises/_expected/cjs.js
@@ -0,0 +1,21 @@
'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

const p1 = new Promise( () => {
console.log( 'fire & forget' );
} );

const p2 = new Promise( () => {
console.info( 'forget me as well' );
} );

const p3 = new Promise( () => {
console.info( 'and me too' );
} );

const p5 = Promise.reject('should be kept for uncaught rejections');

const allExported = Promise.all([p2, p3]);

exports.allExported = allExported;
17 changes: 17 additions & 0 deletions test/form/samples/promises/_expected/es.js
@@ -0,0 +1,17 @@
const p1 = new Promise( () => {
console.log( 'fire & forget' );
} );

const p2 = new Promise( () => {
console.info( 'forget me as well' );
} );

const p3 = new Promise( () => {
console.info( 'and me too' );
} );

const p5 = Promise.reject('should be kept for uncaught rejections');

const allExported = Promise.all([p2, p3]);

export { allExported };
24 changes: 24 additions & 0 deletions test/form/samples/promises/_expected/iife.js
@@ -0,0 +1,24 @@
var bundle = (function (exports) {
'use strict';

const p1 = new Promise( () => {
console.log( 'fire & forget' );
} );

const p2 = new Promise( () => {
console.info( 'forget me as well' );
} );

const p3 = new Promise( () => {
console.info( 'and me too' );
} );

const p5 = Promise.reject('should be kept for uncaught rejections');

const allExported = Promise.all([p2, p3]);

exports.allExported = allExported;

return exports;

}({}));
27 changes: 27 additions & 0 deletions test/form/samples/promises/_expected/umd.js
@@ -0,0 +1,27 @@
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(factory((global.bundle = {})));
}(this, (function (exports) { 'use strict';

const p1 = new Promise( () => {
console.log( 'fire & forget' );
} );

const p2 = new Promise( () => {
console.info( 'forget me as well' );
} );

const p3 = new Promise( () => {
console.info( 'and me too' );
} );

const p5 = Promise.reject('should be kept for uncaught rejections');

const allExported = Promise.all([p2, p3]);

exports.allExported = allExported;

Object.defineProperty(exports, '__esModule', { value: true });

})));
18 changes: 18 additions & 0 deletions test/form/samples/promises/main.js
@@ -0,0 +1,18 @@
const p1 = new Promise( () => {
console.log( 'fire & forget' );
} );

const p2 = new Promise( () => {
console.info( 'forget me as well' );
} );

const p3 = new Promise( () => {
console.info( 'and me too' );
} );

const p4 = Promise.resolve('no side effect');
const p5 = Promise.reject('should be kept for uncaught rejections');

const all = Promise.all([p2, p3]);
export const allExported = Promise.all([p2, p3]);
const race = Promise.race([p2, p3]);

0 comments on commit c15cfe3

Please sign in to comment.