Skip to content

Commit

Permalink
Fix parsing & detection of async and generator functions
Browse files Browse the repository at this point in the history
  • Loading branch information
developit committed Feb 1, 2018
1 parent 9490005 commit b862971
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/index.js
Expand Up @@ -83,7 +83,7 @@ function toCjs(code, exportsObjName, exports) {
exports.default = true;
return `${before}${exportsObjName}.default=`;
});
code = code.replace(/^(\s*)export\s+(function|const|let|var)(\s+)([a-zA-Z$_][a-zA-Z0-9$_]*)/mg, (s, before, type, ws, name) => {
code = code.replace(/^(\s*)export\s+((?:async\s*)?function(?:\s*\*)?|const|let|var)(\s+)([a-zA-Z$_][a-zA-Z0-9$_]*)/mg, (s, before, type, ws, name) => {
exports[name] = true;
return `${before}${exportsObjName}.${name}=${type}${ws}${name}`;
});
Expand Down

0 comments on commit b862971

Please sign in to comment.