Skip to content

Commit

Permalink
support async functions in es6 detection
Browse files Browse the repository at this point in the history
  • Loading branch information
guybedford committed Dec 17, 2014
1 parent a65443f commit ca501e8
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/extension-core.js
Expand Up @@ -99,7 +99,7 @@ function core(loader) {

// Traceur conveniences
// good enough ES6 detection regex - format detections not designed to be accurate, but to handle the 99% use case
var es6RegEx = /(^\s*|[}\);\n]\s*)(import\s+(['"]|(\*\s+as\s+)?[^"'\(\)\n;]+\s+from\s+['"]|\{)|export\s+\*\s+from\s+["']|export\s+(\{|default|function|class|var|const|let))/;
var es6RegEx = /(^\s*|[}\);\n]\s*)(import\s+(['"]|(\*\s+as\s+)?[^"'\(\)\n;]+\s+from\s+['"]|\{)|export\s+\*\s+from\s+["']|export\s+(\{|default|function|class|var|const|let|async\s+function))/;

var traceurRuntimeRegEx = /\$traceurRuntime/;

Expand Down
9 changes: 9 additions & 0 deletions test/test.js
Expand Up @@ -22,6 +22,8 @@ function err(e) {

var ie8 = typeof navigator != 'undefined' && navigator.appVersion && navigator.appVersion.indexOf('MSIE 8') != -1;

System.traceurOptions = { asyncFunctions: true };

asyncTest('Error handling', function() {
System['import']('tests/error-loader').then(err, function(e) {
ok(true);
Expand Down Expand Up @@ -486,6 +488,13 @@ asyncTest('AMD simplified CommonJS wrapping with an aliased require', function()
if (ie8)
return;

asyncTest('Async functions', function() {
System['import']('tests/async').then(function(m) {
ok(true);
start();
});
});

asyncTest('Wrapper module support', function() {
System['import']('tests/wrapper').then(function(m) {
ok(m['default'] == 'default1', 'Wrapper module not defined.');
Expand Down
5 changes: 5 additions & 0 deletions test/tests/async.js
@@ -0,0 +1,5 @@
// will detect as CommonJS
if (false) require('asdf');

// should detect as ES6 first
export async function p() {}
2 changes: 1 addition & 1 deletion test/tests/wrapper.js
@@ -1 +1 @@
export * from './default1';
export * from './default1';

0 comments on commit ca501e8

Please sign in to comment.