From 910fa30432de3ec1623c247a14b91c43d11198ed Mon Sep 17 00:00:00 2001 From: Christina Holland Date: Thu, 22 Jun 2023 14:56:55 -0700 Subject: [PATCH 1/2] Initial fix attempt --- src/deploy/hosting/prepare.ts | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/deploy/hosting/prepare.ts b/src/deploy/hosting/prepare.ts index df55b527330..dabb448243e 100644 --- a/src/deploy/hosting/prepare.ts +++ b/src/deploy/hosting/prepare.ts @@ -12,6 +12,7 @@ import * as utils from "../../utils"; import { HostingSource, RunRewrite } from "../../firebaseConfig"; import * as backend from "../functions/backend"; import { ensureTargeted } from "../../functions/ensureTargeted"; +import { normalizeAndValidate } from "../../functions/projectConfig"; function handlePublicDirectoryFlag(options: HostingOptions & Options): void { // Allow the public directory to be overridden by the --public flag @@ -75,8 +76,20 @@ export async function addPinnedFunctionsToOnlyString( if (endpoint) { options.only = ensureTargeted(options.only, endpoint.codebase || "default", endpoint.id); } else { - // This endpoint is just being added in this push. We don't know what codebase it is. - options.only = ensureTargeted(options.only, r.function.functionId); + const functionsConfig = normalizeAndValidate(options.config.src.functions); + const codebasesFromConfig = [ + ...new Set(Object.values(functionsConfig).map((c) => c.codebase)), + ]; + if (codebasesFromConfig.length > 0) { + options.only = ensureTargeted( + options.only, + codebasesFromConfig[0], + r.function.functionId + ); + } else { + // This endpoint is just being added in this push. We don't know what codebase it is. + options.only = ensureTargeted(options.only, r.function.functionId); + } } addedFunctionsPerSite.push(r.function.functionId); } From c05d77f496aadee7d3966eff9098f6b3ec0c750a Mon Sep 17 00:00:00 2001 From: Christina Holland Date: Thu, 22 Jun 2023 17:09:45 -0700 Subject: [PATCH 2/2] Detect framework --- src/deploy/hosting/prepare.ts | 24 +++++++++--------------- src/frameworks/index.ts | 10 +++++++++- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/src/deploy/hosting/prepare.ts b/src/deploy/hosting/prepare.ts index dabb448243e..f5bfc1f151a 100644 --- a/src/deploy/hosting/prepare.ts +++ b/src/deploy/hosting/prepare.ts @@ -12,7 +12,7 @@ import * as utils from "../../utils"; import { HostingSource, RunRewrite } from "../../firebaseConfig"; import * as backend from "../functions/backend"; import { ensureTargeted } from "../../functions/ensureTargeted"; -import { normalizeAndValidate } from "../../functions/projectConfig"; +import { generateSSRCodebaseId } from "../../frameworks"; function handlePublicDirectoryFlag(options: HostingOptions & Options): void { // Allow the public directory to be overridden by the --public flag @@ -75,21 +75,15 @@ export async function addPinnedFunctionsToOnlyString( ]?.[r.function.functionId]; if (endpoint) { options.only = ensureTargeted(options.only, endpoint.codebase || "default", endpoint.id); + } else if (c.webFramework) { + options.only = ensureTargeted( + options.only, + generateSSRCodebaseId(c.site), + r.function.functionId + ); } else { - const functionsConfig = normalizeAndValidate(options.config.src.functions); - const codebasesFromConfig = [ - ...new Set(Object.values(functionsConfig).map((c) => c.codebase)), - ]; - if (codebasesFromConfig.length > 0) { - options.only = ensureTargeted( - options.only, - codebasesFromConfig[0], - r.function.functionId - ); - } else { - // This endpoint is just being added in this push. We don't know what codebase it is. - options.only = ensureTargeted(options.only, r.function.functionId); - } + // This endpoint is just being added in this push. We don't know what codebase it is. + options.only = ensureTargeted(options.only, r.function.functionId); } addedFunctionsPerSite.push(r.function.functionId); } diff --git a/src/frameworks/index.ts b/src/frameworks/index.ts index 8ac1b3bf9c8..b25bc4f49b3 100644 --- a/src/frameworks/index.ts +++ b/src/frameworks/index.ts @@ -104,6 +104,14 @@ function memoizeBuild( return value; } +/** + * Use a function to ensure the same codebase name is used here and + * during hosting deploy. + */ +export function generateSSRCodebaseId(site: string) { + return `firebase-frameworks-${site}`; +} + /** * */ @@ -330,7 +338,7 @@ export async function prepareFrameworks( ); } - const codebase = `firebase-frameworks-${site}`; + const codebase = generateSSRCodebaseId(site); const existingFunctionsConfig = options.config.get("functions") ? [].concat(options.config.get("functions")) : [];