Skip to content

Commit a99f09b

Browse files
fix(schematics): use the exported logger/compat subpath in generated functions (#3730)
The SSR Cloud Function generated by `ng deploy` crashed at cold start: Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './lib/logger/compat' is not defined by "exports" in node_modules/firebase-functions/package.json Both generated templates required `firebase-functions/lib/logger/compat`. firebase-functions declares an exports map, and the internal `lib/` path is not in it. The exported subpath is `firebase-functions/logger/compat`, which maps to the same file. Verified by generating the function source and loading it against a real firebase-functions install: the shipped path throws, the exported path loads and emits structured Cloud Logging JSON, which is what the compat logger is there to do. This affects the deployed function rather than the build, so it fails at runtime in Cloud Functions rather than during `ng deploy`, and it is present in both the 20.x and 21.x lines.
1 parent 6ef4767 commit a99f09b

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/schematics/deploy/functions-templates.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export const defaultFunction = (
3737
) => `const functions = require('firebase-functions');
3838
3939
// Increase readability in Cloud Logging
40-
require("firebase-functions/lib/logger/compat");
40+
require("firebase-functions/logger/compat");
4141
4242
const expressApp = require('./${path}/main').app();
4343
@@ -55,7 +55,7 @@ export const functionGen2 = (
5555
) => `const { onRequest } = require('firebase-functions/v2/https');
5656
5757
// Increase readability in Cloud Logging
58-
require("firebase-functions/lib/logger/compat");
58+
require("firebase-functions/logger/compat");
5959
6060
const expressApp = require('./${path}/main').app();
6161

0 commit comments

Comments
 (0)