Closed Serhii-the-Dev closed 2 years ago
Hi, sorry for the delay in reply, this should work out of the box without throwing an error. Is this still and issue? And is it possible to provide a bit more context or a way that we can reproduce it?
@erikhaandrikman sorry for a delay as well :) This issue is tied to lng-cli
, it makes a iife
build, which is not compatible with dynamic imports:
https://github.com/rdkcentral/Lightning-CLI/blob/0385006cc28fb53d491dcbcf9ec61c6d7c92063f/src/configs/rollup.es6.config.js#L82
We managed to mitigate the issue with our own Webpack-based bundling pipeline...alas, we are not sure if the pipeline output will be compatible with ML app store, since we have multiple chunks(which are dynamically loaded) instead of a one big js file(like the lng-cli
outputs).
Are you still facing this issue? I'm not able to reproduce this anymore with rollup or esbuild please let us know if any help is required
Hi @erikhaandrikman . Today I also attempted to use a dynamic import on my boot function in my routes.js, but just as @Serhii-the-Dev I got the same error. I'm using a Promise.all() to load various external scripts before the app fully loads but there's this one script that I need to load dynamically (because I have it in a .js file locally and auto executes as soon as it gets imported) to then load my other scripts which depend on it.
boot: () => {
// Other functions that return promises and load scripts go here
function wrapperMessagingSDKPromise() {
return import('../../lib/navigation.js').then(() => {
return new Promise((resolve, reject) => {
const wrapperMessagingSDKScript = document.createElement('script');
wrapperMessagingSDKScript.src =
'https://xxx.xxx.com/someScript.js';
wrapperMessagingSDKScript.addEventListener('load', () => resolve(true));
wrapperMessagingSDKScript.addEventListener('error', () =>
reject(false),
);
document.body.appendChild(wrapperMessagingSDKScript);
})
});
}
return Promise.all([
imaSDKPromise(),
imaDAISDKPromise(),
externalGtagPromise(),
embedGtagPromise(),
wrapperMessagingSDKPromise(),
]);
}
Lightning-CLI 2.5.1 SDK v4.3.3
Are you using esbuild
or rollup
?
Router configuration like this:
will trigger the next error after
lng build
is called: