Skip to content

Commit

Permalink
fix(okam-build): optimize the async await local polyfill for weixin #2
Browse files Browse the repository at this point in the history
  • Loading branch information
wuhy committed Nov 11, 2018
1 parent 220d942 commit f63bbcc
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
26 changes: 26 additions & 0 deletions packages/okam-build/lib/processor/js/polyfill/async.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,32 @@ module.exports = function ({types: t}) {
*/
AwaitExpression(path, state) {
importLocalPolyfill(false, path, state, t);
},

/**
* Process `async xxx` expression
*
* @param {Object} path the node path
* @param {Object} state the plugin state
*/
FunctionExpression(path, state) {
let node = path.node;
if (node.async) {
importLocalPolyfill(false, path, state, t);
}
},

/**
* Process `async xxx() {}` object member
*
* @param {Object} path the node path
* @param {Object} state the plugin state
*/
ObjectMember(path, state) {
let node = path.node;
if (node.async) {
importLocalPolyfill(false, path, state, t);
}
}
}
};
Expand Down
1 change: 1 addition & 0 deletions packages/okam-build/lib/processor/js/polyfill/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ exports.importLocalPolyfill = function (name, path, state, t) {
if (name === false) {
name = importName;
}

if (!shouldPolyfill(importName, name, path)) {
return;
}
Expand Down

0 comments on commit f63bbcc

Please sign in to comment.