From 059d9ab5be3d4b4b26fbb9a5e9aaf05928131f81 Mon Sep 17 00:00:00 2001 From: Luis Martins Date: Sun, 27 Oct 2019 14:23:25 +0000 Subject: [PATCH] Unwrap dynamically imported modules --- index.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 39eeafb..c2170cd 100644 --- a/index.js +++ b/index.js @@ -59,7 +59,14 @@ export function picoapp (components = {}, initialState = {}) { try { const instance = comp(node, evx) - isFn(instance.unmount) && cache.push(instance) + if (instance.then) { + instance.then((value) => { + const asyncInstance = value.default(node, evx); + isFn(asyncInstance.unmount) && cache.push(asyncInstance); + }); + } else { + isFn(instance.unmount) && cache.push(instance); + } } catch (e) { console.log(`🚨 %cpicoapp - ${modules[m]} failed - ${e.message || e}`, 'color: #E85867') console.error(e)