From 07df082a25a2a470188c911e113fd1c0ccbfc744 Mon Sep 17 00:00:00 2001 From: Travis Hoover Date: Mon, 25 Apr 2022 14:30:55 -0700 Subject: [PATCH 1/2] If window.__eaiEngineLookup is present load promises from it Ember auto import will create this object for lazy engines such that asset loader can "lazy" load imports. --- addon/services/asset-loader.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/addon/services/asset-loader.js b/addon/services/asset-loader.js index 98fd46a..d9c7fef 100644 --- a/addon/services/asset-loader.js +++ b/addon/services/asset-loader.js @@ -89,6 +89,12 @@ export default Ember.Service.extend({ const assets = bundle.assets || []; const assetPromises = assets.map((asset) => this.loadAsset(asset, retryLoad)); + // ember-auto-import creates window.__eaiEngineLookup when a lazy engine uses eai v2. + // this enables lazy engine's imports to be lazy themselves. + if (window.__eaiEngineLookup && window.__eaiEngineLookup[name]) { + assetPromises.push(window.__eaiEngineLookup[name]()); + } + const bundlePromise = RSVP.allSettled([ ...dependencyPromises, ...assetPromises ]); const bundleWithFail = bundlePromise.then((promises) => { From f38f7121aea37478c13847ec8a9b86360f01a8d2 Mon Sep 17 00:00:00 2001 From: Travis Hoover Date: Thu, 5 May 2022 11:54:02 -0700 Subject: [PATCH 2/2] Update addon/services/asset-loader.js Co-authored-by: Robert Jackson --- addon/services/asset-loader.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addon/services/asset-loader.js b/addon/services/asset-loader.js index d9c7fef..a741fcf 100644 --- a/addon/services/asset-loader.js +++ b/addon/services/asset-loader.js @@ -91,8 +91,8 @@ export default Ember.Service.extend({ // ember-auto-import creates window.__eaiEngineLookup when a lazy engine uses eai v2. // this enables lazy engine's imports to be lazy themselves. - if (window.__eaiEngineLookup && window.__eaiEngineLookup[name]) { - assetPromises.push(window.__eaiEngineLookup[name]()); + if (typeof __eaiEngineLookup === 'object' && __eaiEngineLookup[name]) { + assetPromises.push(__eaiEngineLookup[name]()); } const bundlePromise = RSVP.allSettled([ ...dependencyPromises, ...assetPromises ]);