Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: Deploy only one function from a multiple functions app #160

Closed
pikilon opened this issue Oct 18, 2023 · 4 comments
Closed

Comments

@pikilon
Copy link

pikilon commented Oct 18, 2023

Current behavior

  • You can have multiple functions in a single cloud function app
  • You can deploy all the functions using this package
  • Firebase project (without nx) can deploy only one function using firebase deploy --only functions:function-name

Expected behavior

  • you can deploy only one function within a Firebase app
@simondotm
Copy link
Owner

simondotm commented Oct 18, 2023

ah, good scenario, thanks @pikilon . I might have to think about how best to handle this in plugin.

The good news is that you can do this with the Firebase CLI.

Each nx-firebase function app is effectively a codebase, so the magic spell you need to deploy just one function from a codebase collection is:

npx firebase deploy --only functions:<codebase>:function-name

where <codebase> is whatever name you gave your nx-firebase:function project.

@simondotm
Copy link
Owner

simondotm commented Oct 18, 2023

An alternative solution is to generate another nx-firebase:function project and move your single function into it.

I havent yet decided in my own workflow if it makes sense to have one nx-firebase:function project per exported firebase cloud function definition. 🤔

This approach does have the benefit that esbuild tree shakes the compiled output to only contain code for that one function being exported, which depending on your project complexity could mean faster cold starts etc.

Plus since one app, one function, then nx deploy my-function does deploy just that one cloud function.

Downside is a lot more boiler plate and code fragments in the workspace since there are more app projects around.

But I tend to have very little code in my firebase function main.ts and just import what I need from an Nx Typescript library.

@simondotm
Copy link
Owner

UPDATE: Actually the plugin can in fact do this already, even if you have multiple exports in your nx-firebase:functions project, it's similar syntax:

npx nx deploy <codebase> --only functions:<codebase>:function-name

As above, where <codebase> is whatever name you gave your nx-firebase:function project.

@pikilon
Copy link
Author

pikilon commented Oct 20, 2023

npx firebase deploy --only functions::function-name

Thank you very much, I will use it.
I will try to help you as a tester until I know enough to help you with the code.
Until then here you have 4 coffees
https://Ko-fi.com/home/coffeeshop?txid=137771cf-a7c6-42ad-9d80-24fe744c5282&mode=public&img=ogiboughtsomeone

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants