So with Vue and Nuxt to import a route lazily you can do
() => import('~/layouts/Container.vue').then(m => m.default || m)
But I don't want to type .then(m => m.default || m)
each time I add a route. So I created a function that would do this called routeImport. Route import is really simple. It looks like this:
const routeImport = file => import(file).then(m => m.default || m)
So now I can add my route like
() => routeImport('~/layouts/Container.vue')
But this does not give the same result. The first function returns a component whilst the other one throws the error:
Error: Cannot find module '~/layouts/Container.vue'
Does anybody know how I can replace this function?