nitrojs / nitro

Next Generation Server Toolkit. Create web servers with everything you need and deploy them wherever you prefer.
https://nitro.build
MIT License
6.24k stars 514 forks source link

Nuxt3 fails to build with preset when serverFunctionName is set #2643

Closed FenixTubluk closed 1 month ago

FenixTubluk commented 3 months ago

Environment

Node version v20.15.0 Nuxt 3.12.4 Nitropack 2.9.7

Reproduction

Create a new Nuxt3 project and try to build it with npm run build -- --preset=firebase

nuxt.config.ts

// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
  compatibilityDate: '2024-04-03',
  devtools: { enabled: true },
  nitro: {
    preset: "firebase",
    firebase: {
      gen: 2,
      serverFunctionName: "my-awesome-function",
      nodeVersion: "18",
      httpsOptions: {
        region: 'europe-west1',
      }
    }
  },
})

Describe the bug

When building with preset firebase in latest version of Nuxt3 nitropack fails if serverFunctionName is set.

Additional context

No response

Logs

RollupError: node_modules/.pnpm/nitropack@2.9.7_magicast@0.3.4/node_modules/nitropack/dist/runtime/entries/firebase-gen-2.mjs (7:13): 'const' declarations must be initialized (Note that you need plugins to import files that are not JavaScript)

5: import { useAppConfig } from "#internal/nitro";
6: const firebaseConfig = useAppConfig().nitro.firebase;
7: export const __firebaseServerFunctionName__ = onRequest(
                ^
8:   {
9:     // Must be set to public to allow all public requests by default

[18:15:10]  ERROR  node_modules/.pnpm/nitropack@2.9.7_magicast@0.3.4/node_modules/nitropack/dist/runtime/entries/firebase-gen-2.mjs (7:13): 'const' declarations must be initialized (Note that you need plugins to import files that are not JavaScript)

  at getRollupError (/F:/tmp/test/node_modules/.pnpm/rollup@4.20.0/node_modules/rollup/dist/es/shared/parseAst.js:392:41)
  at ParseError.initialise (/F:/tmp/test/node_modules/.pnpm/rollup@4.20.0/node_modules/rollup/dist/es/shared/node-entry.js:11485:28)
  at convertNode (/F:/tmp/test/node_modules/.pnpm/rollup@4.20.0/node_modules/rollup/dist/es/shared/node-entry.js:13181:10)
  at convertProgram (/F:/tmp/test/node_modules/.pnpm/rollup@4.20.0/node_modules/rollup/dist/es/shared/node-entry.js:12525:12)
  at Module.setSource (/F:/tmp/test/node_modules/.pnpm/rollup@4.20.0/node_modules/rollup/dist/es/shared/node-entry.js:14346:24)
  at async ModuleLoader.addModuleSource (/F:/tmp/test/node_modules/.pnpm/rollup@4.20.0/node_modules/rollup/dist/es/shared/node-entry.js:19003:13)

[18:15:10]  ERROR  node_modules/.pnpm/nitropack@2.9.7_magicast@0.3.4/node_modules/nitropack/dist/runtime/entries/firebase-gen-2.mjs (7:13): 'const' declarations must be initialized (Note that you need plugins to import files that are not JavaScript)
FenixTubluk commented 3 months ago

It seems to be dash in the serverFunctionName that is causing it.

adria-fsbd commented 2 months ago

Confirmed, if the serverFunctionName contains a dash it fails on build

snsxn commented 2 months ago

Yes, I can confirm it too. With an underscore (_) works fine

marcosgomesneto commented 1 month ago

same problem, we wait for the fix, in the meantime don't use "-"