From a97602fd41a18269b4152f1ddbcaa5a455de914b Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Fri, 17 Jan 2025 22:56:03 +0000 Subject: [PATCH] fix(nuxt): fall back to `plugin.src` for variable name generation (#30649) --- packages/nuxt/src/core/templates.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/nuxt/src/core/templates.ts b/packages/nuxt/src/core/templates.ts index b7723bae54..a99237fc0b 100644 --- a/packages/nuxt/src/core/templates.ts +++ b/packages/nuxt/src/core/templates.ts @@ -68,7 +68,7 @@ export const clientPluginTemplate: NuxtTemplate = { const imports: string[] = [] for (const plugin of clientPlugins) { const path = relative(ctx.nuxt.options.rootDir, plugin.src) - const variable = genSafeVariableName(filename(plugin.src)).replace(PLUGIN_TEMPLATE_RE, '_') + '_' + hash(path) + const variable = genSafeVariableName(filename(plugin.src) || path).replace(PLUGIN_TEMPLATE_RE, '_') + '_' + hash(path) exports.push(variable) imports.push(genImport(plugin.src, variable)) } @@ -88,7 +88,7 @@ export const serverPluginTemplate: NuxtTemplate = { const imports: string[] = [] for (const plugin of serverPlugins) { const path = relative(ctx.nuxt.options.rootDir, plugin.src) - const variable = genSafeVariableName(filename(path)).replace(PLUGIN_TEMPLATE_RE, '_') + '_' + hash(path) + const variable = genSafeVariableName(filename(plugin.src) || path).replace(PLUGIN_TEMPLATE_RE, '_') + '_' + hash(path) exports.push(variable) imports.push(genImport(plugin.src, variable)) }