diff --git a/packages/okam-build/lib/processor/js/polyfill/async.js b/packages/okam-build/lib/processor/js/polyfill/async.js index 0cad0eea..c220dc18 100644 --- a/packages/okam-build/lib/processor/js/polyfill/async.js +++ b/packages/okam-build/lib/processor/js/polyfill/async.js @@ -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); + } } } }; diff --git a/packages/okam-build/lib/processor/js/polyfill/helper.js b/packages/okam-build/lib/processor/js/polyfill/helper.js index 06a22ec8..ce91e34b 100644 --- a/packages/okam-build/lib/processor/js/polyfill/helper.js +++ b/packages/okam-build/lib/processor/js/polyfill/helper.js @@ -43,6 +43,7 @@ exports.importLocalPolyfill = function (name, path, state, t) { if (name === false) { name = importName; } + if (!shouldPolyfill(importName, name, path)) { return; }