diff --git a/docs/2.deploy/20.providers/firebase.md b/docs/2.deploy/20.providers/firebase.md index df01952a8b..933f9e2daa 100644 --- a/docs/2.deploy/20.providers/firebase.md +++ b/docs/2.deploy/20.providers/firebase.md @@ -265,5 +265,5 @@ export default defineNuxtConfig({ :: ::important -`serverFunctionName` should not include dashes (`-`). +`serverFunctionName` cannot include dashes (`-`). :: diff --git a/src/presets/firebase/preset.ts b/src/presets/firebase/preset.ts index 92011d4d5b..5c9246d5f0 100644 --- a/src/presets/firebase/preset.ts +++ b/src/presets/firebase/preset.ts @@ -1,6 +1,7 @@ import { defineNitroPreset } from "nitropack/kit"; import { basename } from "pathe"; import type { Plugin } from "rollup"; +import { genSafeVariableName } from "knitwork" import { updatePackageJSON, writeFirebaseConfig } from "./utils"; export type { FirebaseOptions as PresetOptions } from "./types"; @@ -33,10 +34,9 @@ const firebase = defineNitroPreset( nitro.options.appConfig.nitro = nitro.options.appConfig.nitro || {}; nitro.options.appConfig.nitro.firebase = nitro.options.firebase; - if(nitro.options.firebase?.serverFunctionName.includes('-')){ - nitro.logger.warn( - "Your `serverFunctionName` should not include dashes (`-`). We have normalized it to use underscores (`_`) but it is recommended that you change it." - ); + const { serverFunctionName } = nitro.options.firebase + if(serverFunctionName && serverFunctionName !== genSafeVariableName(serverFunctionName)) { + throw new Error("`serverFunctionName` cannot include dashes") } // Replace __firebaseServerFunctionName__ to actual name in entries @@ -47,7 +47,7 @@ const firebase = defineNitroPreset( return { code: code.replace( /__firebaseServerFunctionName__/g, - nitro.options.firebase?.serverFunctionName.replace(/-/g, '_') || "server" + serverFunctionName || "server" ), map: null, };