Skip to content

Commit f0836fa

Browse files
committed
fix(vuetify-nuxt-module): handle missing component entries safely
1 parent af8bfbc commit f0836fa

File tree

1 file changed

+27
-12
lines changed

1 file changed

+27
-12
lines changed

packages/vuetify-nuxt-module/src/vite/vuetify-configuration-plugin.ts

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,8 @@ async function buildConfiguration (ctx: VuetifyNuxtContext) {
129129

130130
const componentsToImport = new Map<string, string[]>()
131131
for (const component of config.components) {
132-
const { from } = importMapComponents[component]
132+
const componentEntry = importMapComponents[component]
133+
const from = componentEntry?.from
133134
if (!from) {
134135
logger.warn(`Component ${component} not found in Vuetify.`)
135136
continue
@@ -140,19 +141,24 @@ async function buildConfiguration (ctx: VuetifyNuxtContext) {
140141
logger.warn(`Component ${component} not found in Vuetify, please report a new issue.`)
141142
continue
142143
}
144+
const bucket = parts[1]
145+
if (!bucket) {
146+
continue
147+
}
143148

144-
if (!componentsToImport.has(parts[1])) {
145-
componentsToImport.set(parts[1], [])
149+
if (!componentsToImport.has(bucket)) {
150+
componentsToImport.set(bucket, [])
146151
}
147152

148-
const componentsArray = componentsToImport.get(parts[1])!
153+
const componentsArray = componentsToImport.get(bucket)!
149154
if (!componentsArray.includes(component)) {
150155
componentsArray.push(component)
151156
}
152157
}
153158

154159
for (const [key, component] of Object.entries(config.aliases)) {
155-
const { from } = importMapComponents[component]
160+
const componentEntry = importMapComponents[component]
161+
const from = componentEntry?.from
156162
if (!from) {
157163
logger.warn(`Component ${component} not found in Vuetify.`)
158164
continue
@@ -163,12 +169,16 @@ async function buildConfiguration (ctx: VuetifyNuxtContext) {
163169
logger.warn(`Component ${component} not found in Vuetify, please report a new issue.`)
164170
continue
165171
}
172+
const bucket = parts[1]
173+
if (!bucket) {
174+
continue
175+
}
166176

167-
if (!componentsToImport.has(parts[1])) {
168-
componentsToImport.set(parts[1], [])
177+
if (!componentsToImport.has(bucket)) {
178+
componentsToImport.set(bucket, [])
169179
}
170180

171-
const componentsArray = componentsToImport.get(parts[1])!
181+
const componentsArray = componentsToImport.get(bucket)!
172182
if (!componentsArray.includes(component)) {
173183
componentsArray.push(component)
174184
}
@@ -203,7 +213,8 @@ async function buildConfiguration (ctx: VuetifyNuxtContext) {
203213
componentsToImport.clear()
204214
const importMapLabComponents = await labComponentsPromise
205215
for (const component of useLabComponents) {
206-
const { from } = importMapLabComponents[component]
216+
const componentEntry = importMapLabComponents[component]
217+
const from = componentEntry?.from
207218
if (!from) {
208219
logger.warn(`Lab Component ${component} not found in Vuetify.`)
209220
continue
@@ -214,12 +225,16 @@ async function buildConfiguration (ctx: VuetifyNuxtContext) {
214225
logger.warn(`Lab Component ${component} not found in Vuetify, please report a new issue.`)
215226
continue
216227
}
228+
const bucket = parts[1]
229+
if (!bucket) {
230+
continue
231+
}
217232

218-
if (!componentsToImport.has(parts[1])) {
219-
componentsToImport.set(parts[1], [])
233+
if (!componentsToImport.has(bucket)) {
234+
componentsToImport.set(bucket, [])
220235
}
221236

222-
const componentsArray = componentsToImport.get(parts[1])!
237+
const componentsArray = componentsToImport.get(bucket)!
223238
if (!componentsArray.includes(component)) {
224239
componentsArray.push(component)
225240
}

0 commit comments

Comments
 (0)