Not sure what’s the benefit over simply using async imports inside component declarations
`components:{ CompanyInfo: () =>import(‘./components/CompanyInfo’)}`
Just my personal opinion here, for simple use cases with v-if v-else
the code looks more readable to me with explicitly declared components vs component :is
.
Also a very important thing to point out is `import(`./components/${name}`)` will actually create a chunk for EVERY component inside components
because webpack won’t know that it should import CompanyInfo
or the other one and will create chunks for all 10 components if you have 10 in that folder.
Quote from webpack docs:
Every module that could potentially be requested on an import()
call is included. For example, import(`./locale/${language}.json`)
will cause every .json
file in the ./locale
directory to be bundled into the new chunk. At run time, when the variable language
has been computed, any file like english.json
or german.json
will be available for consumption.