From 24da208385fbef08db262fc3e6da30057f7adc2d Mon Sep 17 00:00:00 2001 From: zodern Date: Thu, 30 Mar 2023 15:48:00 -0500 Subject: [PATCH] Fix checkAsyncModule --- packages/core-runtime/load-js-image.js | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/packages/core-runtime/load-js-image.js b/packages/core-runtime/load-js-image.js index b80a84165c..2492acb920 100644 --- a/packages/core-runtime/load-js-image.js +++ b/packages/core-runtime/load-js-image.js @@ -83,9 +83,7 @@ function runEagerModules(config, callback) { var path = config.eagerModulePaths[index]; var exports = config.require(path); - // TODO[fibers]: retest the function checkAsyncModule. It looks like it's returning the wrong values - // returning false when exports is a promise - if (exports && exports.then) { + if (checkAsyncModule(exports)) { if (path === config.mainModulePath) { mainModuleAsync = true; } @@ -127,15 +125,14 @@ function runEagerModules(config, callback) { } function checkAsyncModule (exports) { - // Uses property descriptor to avoid running any getters - var isPromise = exports && hasOwn.call(exports, 'then') && - typeof Object.getOwnPropertyDescriptor(exports, 'then').value === 'function'; + var potentiallyAsync = exports && typeof exports === 'object' && + hasOwn.call(exports, '__reifyAsyncModule'); - if (!isPromise) { - return false; + if (!potentiallyAsync) { + return; } - return hasOwn.call(exports, '__reifyAsyncModule'); + return typeof exports.then === 'function'; } // For this to be accurate, all linked files must be queued before calling this