I am wondering how to check when an async component has loaded.
Normally I would load my component like so:
Vue.component(
'booking-overlay',
() => import('@/components/BookingOverlayAsync.vue')
);
Using something like this does not work:
Vue.component(
'booking-overlay',
() => import('@/components/BookingOverlayAsync.vue').then(() => {
console.log('component has loaded');
})
);
It leads to the following error:
Uncaught (in promise) TypeError: Cannot read property '__esModule' of undefined at ensureCtor..
The component no longer loads but the promise does resolve though. By adding the then it no longer resolves the promise itself it seems.
How can I globally register this async component and also check when this components chunk of JavaScript has been loaded?
Obviously I could simply do this together with setting the global component:
import('@/components/BookingOverlayAsync.vue').then(() => {
console.log('Chunk loaded');
});
This just seems like a very ugly solution though.