Browse Source

Merge pull request #1173 from rollup/gh-492

support async functions
gh-786
Rich Harris 8 years ago
committed by GitHub
parent
commit
7b3402f298
  1. 2
      src/Module.js
  2. 3
      test/form/async-function-unused/_config.js
  3. 9
      test/form/async-function-unused/_expected/amd.js
  4. 7
      test/form/async-function-unused/_expected/cjs.js
  5. 5
      test/form/async-function-unused/_expected/es.js
  6. 10
      test/form/async-function-unused/_expected/iife.js
  7. 13
      test/form/async-function-unused/_expected/umd.js
  8. 3
      test/form/async-function-unused/main.js
  9. 7
      test/form/async-function-unused/utils.js

2
src/Module.js

@ -16,7 +16,7 @@ import ModuleScope from './ast/scopes/ModuleScope.js';
function tryParse ( code, comments, acornOptions, id ) {
try {
return parse( code, assign({
ecmaVersion: 7,
ecmaVersion: 8,
sourceType: 'module',
onComment: ( block, text, start, end ) => comments.push({ block, text, start, end }),
preserveParens: false

3
test/form/async-function-unused/_config.js

@ -0,0 +1,3 @@
module.exports = {
description: 'treeshakes async functions (#492)'
};

9
test/form/async-function-unused/_expected/amd.js

@ -0,0 +1,9 @@
define(function () { 'use strict';
async function foo () {
return 'foo';
}
foo().then( value => console.log( value ) );
});

7
test/form/async-function-unused/_expected/cjs.js

@ -0,0 +1,7 @@
'use strict';
async function foo () {
return 'foo';
}
foo().then( value => console.log( value ) );

5
test/form/async-function-unused/_expected/es.js

@ -0,0 +1,5 @@
async function foo () {
return 'foo';
}
foo().then( value => console.log( value ) );

10
test/form/async-function-unused/_expected/iife.js

@ -0,0 +1,10 @@
(function () {
'use strict';
async function foo () {
return 'foo';
}
foo().then( value => console.log( value ) );
}());

13
test/form/async-function-unused/_expected/umd.js

@ -0,0 +1,13 @@
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory() :
typeof define === 'function' && define.amd ? define(factory) :
(factory());
}(this, (function () { 'use strict';
async function foo () {
return 'foo';
}
foo().then( value => console.log( value ) );
})));

3
test/form/async-function-unused/main.js

@ -0,0 +1,3 @@
import { foo } from './utils.js';
foo().then( value => console.log( value ) );

7
test/form/async-function-unused/utils.js

@ -0,0 +1,7 @@
export async function foo () {
return 'foo';
}
export async function bar () {
return 'bar';
}
Loading…
Cancel
Save