jthegedus / svelte-adapter-firebase

SvelteKit adapter for Firebase Hosting rewrites to Cloud Functions for a Svelte SSR experience

Home Page:https://github.com/jthegedus/svelte-adapter-firebase

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

bug: functions.source missing error even though it's not missing

Pieter0313 opened this issue · comments

Describe the Bug

When running npm run build I get the following error:

error during build:
Error: Error: Required "functions.source" field is missing from Firebase Configuration file.
    at parseFirebaseConfiguration (file:///Users/pieterseegers/Documents/Websites/Avatary/avatary/node_modules/svelte-adapter-firebase/src/utils.js:164:9)
    at adapt (file:///Users/pieterseegers/Documents/Websites/Avatary/avatary/node_modules/svelte-adapter-firebase/src/index.js:26:35)
    at adapt (file:///Users/pieterseegers/Documents/Websites/Avatary/avatary/node_modules/@sveltejs/kit/src/core/adapt/index.js:28:8)
    at Object.handler (file:///Users/pieterseegers/Documents/Websites/Avatary/avatary/node_modules/@sveltejs/kit/src/exports/vite/index.js:611:12)
    at async PluginDriver.hookParallel (file:///Users/pieterseegers/Documents/Websites/Avatary/avatary/node_modules/rollup/dist/es/shared/rollup.js:23582:17)
    at async Object.close (file:///Users/pieterseegers/Documents/Websites/Avatary/avatary/node_modules/rollup/dist/es/shared/rollup.js:24937:13)
    at async Promise.all (index 0)
    at async build (file:///Users/pieterseegers/Documents/Websites/Avatary/avatary/node_modules/vite/dist/node/chunks/dep-5e7f419b.js:44352:13)
    at async CAC.<anonymous> (file:///Users/pieterseegers/Documents/Websites/Avatary/avatary/node_modules/vite/dist/node/cli.js:808:9)

It says that the functions.source field is missing from my firebase configuration file, but it's definitely there;

{
	"firestore": {
		"rules": "firestore.rules",
		"indexes": "firestore.indexes.json"
	},
	"hosting": {
		"predeploy": "npm run build",
		"public": "build",
		"ignore": ["firebase.json", "**/.*", "**/node_modules/**"],
		"rewrites": [
			{
				"source": "**",
				"function": "ssr",
				"region": "europe-west1"
			}
		]
	},
	"functions": [
		{
			"codebase": "default",
			"ignore": ["node_modules", ".git", "firebase-debug.log", "firebase-debug.*.log"],
			"source": "build"
		}
	],
	"storage": {
		"rules": "storage.rules"
	},
	"emulators": {
		"functions": {
			"port": 5001
		},
		"firestore": {
			"port": 8000
		},
		"hosting": {
			"port": 5005
		},
		"storage": {
			"port": 9199
		},
		"ui": {
			"enabled": true
		},
		"singleProjectMode": true
	}
}

Steps to Reproduce

  1. Added the adapter to svelte.config.js;
	kit: {
		adapter: adapter({
		})
	},
  1. Added a functions.source field
  2. Got the error

Expected Behaviour

I think it should recognize this field, but I'm not 100% sure if I'm doing something wrong.

svelte-adapter-firebase version

0.14.4

sveltejs/kit version

1.0.1

Just to help with this, it looks like after init, the functions property is now an array of objects rather than an object. Removing the array and making it just the object worked for me.

True, but it should really be an array. I'm deploying functions from multiple sources..

It's also supported by Firebase to have an array.

Related to #196