mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-26 23:52:06 +00:00
fix(bridge, kit): don't modify template array whilst traversing it (#2244)
This commit is contained in:
parent
6e719d6977
commit
d52acbffd8
@ -69,13 +69,10 @@ export function defineNuxtModule<OptionsT extends ModuleOptions> (input: NuxtMod
|
|||||||
// Support virtual templates with getContents() by writing them to .nuxt directory
|
// Support virtual templates with getContents() by writing them to .nuxt directory
|
||||||
let virtualTemplates: NuxtTemplate[]
|
let virtualTemplates: NuxtTemplate[]
|
||||||
nuxt.hook('builder:prepared', (_builder, buildOptions) => {
|
nuxt.hook('builder:prepared', (_builder, buildOptions) => {
|
||||||
virtualTemplates = []
|
virtualTemplates = buildOptions.templates.filter(t => t.getContents)
|
||||||
buildOptions.templates.forEach((template, index, arr) => {
|
for (const template of virtualTemplates) {
|
||||||
if (!template.getContents) { return }
|
buildOptions.templates.splice(buildOptions.templates.indexOf(template), 1)
|
||||||
// Remove template from template array to handle it ourselves
|
}
|
||||||
arr.splice(index, 1)
|
|
||||||
virtualTemplates.push(template)
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
nuxt.hook('build:templates', async (templates) => {
|
nuxt.hook('build:templates', async (templates) => {
|
||||||
const context = {
|
const context = {
|
||||||
|
Loading…
Reference in New Issue
Block a user