Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/deploy/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ Setting `functionsNodeVersion` and `functionsRuntimeOptions` in your `angular.js
"deploy": {
"builder": "@angular/fire:deploy",
"options": {
"functionsNodeVersion": 12,
"functionsNodeVersion": 22,
"functionsRuntimeOptions": {
"memory": "2GB",
"timeoutSeconds": 10,
Expand Down
4 changes: 2 additions & 2 deletions site/src/get-started/deploying.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,13 @@ To customize the deployment flow, you can use the configuration files you're alr

### Configuring Cloud Functions

Setting `functionsNodeVersion` and `functionsRuntimeOptions` in your `angular.json` allow you to custimze the version of Node.js Cloud Functions is running and run-time settings like timeout, VPC connectors, and memory.
Setting `functionsNodeVersion` and `functionsRuntimeOptions` in your `angular.json` allow you to customize the version of Node.js Cloud Functions is running and run-time settings like timeout, VPC connectors, and memory.

```json
"deploy": {
"builder": "@angular/fire:deploy",
"options": {
"functionsNodeVersion": 12,
"functionsNodeVersion": 22,
"functionsRuntimeOptions": {
"memory": "2GB",
"timeoutSeconds": 10,
Expand Down
20 changes: 20 additions & 0 deletions src/schematics/deploy/functions-templates.jasmine.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { DEFAULT_NODE_VERSION, defaultFunction, defaultPackage } from './functions-templates.js';
import 'jasmine';

describe('functions templates', () => {
describe('defaultFunction', () => {
it('requires the firebase-functions/v1 subpath, where the v1 API lives on firebase-functions 6', () => {
const generated = defaultFunction('dist/app', {}, undefined);
expect(generated).toContain(`require('firebase-functions/v1')`);
expect(generated).not.toContain(`require('firebase-functions')`);
});
});

describe('defaultPackage', () => {
it('defaults engines.node to a runtime Cloud Functions still accepts', () => {
const generated = defaultPackage({}, {}, {});
expect(generated.engines.node).toBe(DEFAULT_NODE_VERSION.toString());
expect(DEFAULT_NODE_VERSION).toBe(22);
});
});
});
9 changes: 7 additions & 2 deletions src/schematics/deploy/functions-templates.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { DeployBuilderOptions } from './actions';

export const DEFAULT_NODE_VERSION = 14;
// Must be a runtime Cloud Functions still accepts, and must satisfy the engines of @angular/core
// (the function runs the Angular server) and of firebase-admin. The `dockerfile` template below
// also drops it into `FROM node:<version>-slim`, so it picks the base image on the Cloud Run path.
export const DEFAULT_NODE_VERSION = 22;
export const DEFAULT_FUNCTION_NAME = 'ssr';

const DEFAULT_FUNCTION_REGION = 'us-central1';
Expand Down Expand Up @@ -30,11 +33,13 @@ export const defaultPackage = (
private: true
});

// `.region()` lives on the /v1 subpath since firebase-functions 6. Requiring the package root
// instead still resolves, and fails only when the deployed function serves its first request.
export const defaultFunction = (
path: string,
options: DeployBuilderOptions,
functionName: string|undefined,
) => `const functions = require('firebase-functions');
) => `const functions = require('firebase-functions/v1');

// Increase readability in Cloud Logging
require("firebase-functions/logger/compat");
Expand Down
Loading