You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I moved everything from the /functions dir into the root of /API as that is all I want in this folder.
initialize a project-constants package in your packages dir
create index.ts
index.ts -> export const hello = 'world';
install project-constants as a dev dep in api e.g "project-constants": "*"
api/src/index.ts -> `import {hello} from 'project-constants';
run yarn workspace api dev in your terminal
[REQUIRED] Expected behavior
The index.ts in the api dir should be able to handle typescript files being imported from a package in a turbo repo.
[REQUIRED] Actual behavior
yarn workspace api dev
yarn workspace v1.22.19
yarn run v1.22.19
$ npm run build:watch | firebase emulators:start --only functions --debug
[2023-09-22T16:05:08.695Z] >command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"]
[2023-09-22T16:05:08.697Z] > authorizing via signed-in user (tanka.labs@gmail.com)
i emulators: Starting emulators: functions {"metadata":{"emulator":{"name":"hub"},"message":"Starting emulators: functions"}}
[2023-09-22T16:05:09.221Z] [logging] Logging Emulator only supports listening on one address (127.0.0.1). Not listening on ::1
[2023-09-22T16:05:09.222Z] assigned listening specs for emulators {"user":{"hub":[{"address":"127.0.0.1","family":"IPv4","port":4400},{"address":"::1","family":"IPv6","port":4400}],"ui":[{"address":"127.0.0.1","family":"IPv4","port":4000},{"address":"::1","family":"IPv6","port":4000}],"logging":[{"address":"127.0.0.1","family":"IPv4","port":4500}]},"metadata":{"message":"assigned listening specs for emulators"}}
[2023-09-22T16:05:09.240Z] [hub] writing locator at /var/folders/k6/7_y8fc8x0f1g8j1v3cz7jgbc0000gn/T/hub-pocket-nhs.json
[2023-09-22T16:05:09.550Z] [functions] Functions Emulator only supports listening on one address (127.0.0.1). Not listening on ::1
[2023-09-22T16:05:09.551Z] [eventarc] Eventarc Emulator only supports listening on one address (127.0.0.1). Not listening on ::1
[2023-09-22T16:05:09.551Z] late-assigned ports for functions and eventarc emulators {"user":{"hub":[{"address":"127.0.0.1","family":"IPv4","port":4400},{"address":"::1","family":"IPv6","port":4400}],"ui":[{"address":"127.0.0.1","family":"IPv4","port":4000},{"address":"::1","family":"IPv6","port":4000}],"logging":[{"address":"127.0.0.1","family":"IPv4","port":4500}],"functions":[{"address":"127.0.0.1","family":"IPv4","port":5001}],"eventarc":[{"address":"127.0.0.1","family":"IPv4","port":9299}]},"metadata":{"message":"late-assigned ports for functions and eventarc emulators"}}
⚠ functions: The following emulators are not running, calls to these services from the Functions emulator will affect production: auth, firestore, database, hosting, pubsub, storage {"metadata":{"emulator":{"name":"functions"},"message":"The following emulators are not running, calls to these services from the Functions emulator will affect production: \u001b[1mauth, firestore, database, hosting, pubsub, storage\u001b[22m"}}
[2023-09-22T16:05:09.572Z] defaultcredentials: writing to file /Users/francisleigh/.config/firebase/tanka_labs_gmail.com_application_default_credentials.json
[2023-09-22T16:05:09.587Z] Setting GAC to /Users/francisleigh/.config/firebase/tanka_labs_gmail.com_application_default_credentials.json {"metadata":{"emulator":{"name":"functions"},"message":"Setting GAC to /Users/francisleigh/.config/firebase/tanka_labs_gmail.com_application_default_credentials.json"}}
[2023-09-22T16:05:09.588Z] > refreshing access token with scopes: []
[2023-09-22T16:05:09.590Z] >>> [apiv2][query] POST https://www.googleapis.com/oauth2/v3/token [none]
[2023-09-22T16:05:09.590Z] >>> [apiv2][body] POST https://www.googleapis.com/oauth2/v3/token [omitted]
[2023-09-22T16:05:09.724Z] <<<[apiv2][status] POST https://www.googleapis.com/oauth2/v3/token 200
[2023-09-22T16:05:09.724Z] <<<[apiv2][body] POST https://www.googleapis.com/oauth2/v3/token [omitted]
[2023-09-22T16:05:09.777Z] >>> [apiv2][query] GET https://firebase.googleapis.com/v1beta1/projects/pocket-nhs/adminSdkConfig [none]
[2023-09-22T16:05:10.157Z] <<<[apiv2][status] GET https://firebase.googleapis.com/v1beta1/projects/pocket-nhs/adminSdkConfig 200
[2023-09-22T16:05:10.157Z] <<<[apiv2][body] GET https://firebase.googleapis.com/v1beta1/projects/pocket-nhs/adminSdkConfig {"projectId":"pocket-nhs","storageBucket":"pocket-nhs.appspot.com"}
[2023-09-22T16:05:10.194Z] Ignoring unsupported arg: auto_download {"metadata":{"emulator":{"name":"ui"},"message":"Ignoring unsupported arg: auto_download"}}
[2023-09-22T16:05:10.194Z] Ignoring unsupported arg: port {"metadata":{"emulator":{"name":"ui"},"message":"Ignoring unsupported arg: port"}}
[2023-09-22T16:05:10.194Z] Starting Emulator UI with command {"binary":"node","args":["/Users/francisleigh/.cache/firebase/emulators/ui-v1.11.7/server/server.js"],"optionalArgs":[],"joinArgs":false} {"metadata":{"emulator":{"name":"ui"},"message":"Starting Emulator UI with command {\"binary\":\"node\",\"args\":[\"/Users/francisleigh/.cache/firebase/emulators/ui-v1.11.7/server/server.js\"],\"optionalArgs\":[],\"joinArgs\":false}"}}
i ui: Emulator UI logging to ui-debug.log {"metadata":{"emulator":{"name":"ui"},"message":"Emulator UI logging to \u001b[1mui-debug.log\u001b[22m"}}
[2023-09-22T16:05:10.323Z] Web / API server started at 127.0.0.1:4000
{"metadata":{"emulator":{"name":"ui"},"message":"Web / API server started at 127.0.0.1:4000\n"}}
[2023-09-22T16:05:10.323Z] Web / API server started at ::1:4000
{"metadata":{"emulator":{"name":"ui"},"message":"Web / API server started at ::1:4000\n"}}
i functions: Watching "/Users/francisleigh/Developer/pocket-nhs/apps/api"for Cloud Functions... {"metadata":{"emulator":{"name":"functions"},"message":"Watching \"/Users/francisleigh/Developer/pocket-nhs/apps/api\" for Cloud Functions..."}}
[2023-09-22T16:05:10.468Z] Validating nodejs source
[2023-09-22T16:05:11.102Z] > [functions] package.json contents: {
"name": "api",
"version": "1.0.0",
"scripts": {
"build": "tsc",
"build:watch": "tsc --watch",
"dev": "npm run build:watch | firebase emulators:start --only functions --debug",
"shell": "npm run build && firebase functions:shell",
"start": "npm run shell",
"deploy": "firebase deploy --only functions",
"logs": "firebase functions:log"
},
"engines": {
"node": "18"
},
"main": "lib/index.js",
"dependencies": {
"firebase-admin": "^11.8.0",
"firebase-functions": "^4.3.1",
"openai": "3.3.0"
},
"devDependencies": {
"typescript": "^4.9.0",
"firebase-functions-test": "^3.1.0",
"types": "*",
"project-constants": "*"
},
"private": true
}
[2023-09-22T16:05:11.104Z] Building nodejs source
[2023-09-22T16:05:11.104Z] Failed to find version of module node: reached end of search path /Users/francisleigh/Developer/pocket-nhs/apps/api/node_modules
✔ functions: Using node@18 from host.
[2023-09-22T16:05:11.109Z] Could not find functions.yaml. Must use http discovery
[2023-09-22T16:05:11.116Z] Found firebase-functions binary at '/Users/francisleigh/Developer/pocket-nhs/apps/api/node_modules/.bin/firebase-functions'
Serving at port 8617
[2023-09-22T16:05:11.462Z] Got response code 400; body Failed to generate manifest from functionsource: SyntaxError: Unexpected token 'export'
shutdown requested via /__/quitquitquit
⬢ functions: Failed to load functiondefinition from source: FirebaseError: Functions codebase could not be analyzed successfully. It may have a syntax or runtime error {"metadata":{"emulator":{"name":"functions"},"message":"Failed to load function definition from source: FirebaseError: Functions codebase could not be analyzed successfully. It may have a syntax or runtime error"}}
┌─────────────────────────────────────────────────────────────┐
│ ✔ All emulators ready! It is now safe to connect your app. │
│ i View Emulator UI at http://127.0.0.1:4000/ │
└─────────────────────────────────────────────────────────────┘
┌───────────┬────────────────┬─────────────────────────────────┐
│ Emulator │ Host:Port │ View in Emulator UI │
├───────────┼────────────────┼─────────────────────────────────┤
│ Functions │ 127.0.0.1:5001 │ http://127.0.0.1:4000/functions │
└───────────┴────────────────┴─────────────────────────────────┘
Emulator Hub running at 127.0.0.1:4400
Other reserved ports: 4500
Issues? Report them at https://github.com/firebase/firebase-tools/issues and attach the *-debug.log files.
This issue does not have all the information required by the template. Looks like you forgot to fill out some sections. Please update the issue with more information.
Hi @francisleigh - thanks for opening your first issue here. Officially, Firebase Functions does not support monorepos, only vanilla npm. Unofficially, we try our best to handle popular methods that customers use. There is a large issue(#653) where community members have posted workarounds for tooling/setups they use. I'm going to close this issue as a duplicate since the problem looks like it has to do with supporting another monorepos and ask that you check out that larger open issue. Thanks
I ended up going down an aws serverless route which worked simply. I'll be sure to use Firebase in non monorepo situations although I'm generally using monorepos more and more 🤷♂️
[REQUIRED] Environment info
firebase-tools:
12.5.4
Platform:
macOS
[REQUIRED] Test case
Mentioned in steps to reproduce
[REQUIRED] Steps to reproduce
Create turbo repo
initialize a
API
app in yourapps
dircd API
firebase init (just functions)
I moved everything from the /functions dir into the root of /API as that is all I want in this folder.
initialize a
project-constants
package in yourpackages
dircreate index.ts
index.ts ->
export const hello = 'world';
install
project-constants
as a dev dep in api e.g"project-constants": "*"
api/src/index.ts -> `import {hello} from 'project-constants';
run
yarn workspace api dev
in your terminal[REQUIRED] Expected behavior
The index.ts in the api dir should be able to handle typescript files being imported from a package in a turbo repo.
[REQUIRED] Actual behavior
The text was updated successfully, but these errors were encountered: