I’m trying to dynamic import firebase-auth
module in Nuxt 3, however the build always preload firebase-auth
despite dynamic import, sample code below:
onMounted(async () => {
if (Math.random() > 100) {
const { getAuth } = await import('firebase/auth')
console.log('getAuth() imported')
}
})
I don’t expect the firebase-auth
to preload as the if
statement will never be executed.
A minimal reproduction is available at:
- https://stackblitz.com/edit/nuxt-preloaded-dynamic-import
Also posted to https://github.com/nuxt/nuxt/issues/18376 as it might be related.
Thanks!