From d0c5d3e0f90347096ce33955b6d6c4b46bbdba48 Mon Sep 17 00:00:00 2001 From: yuangwang Date: Wed, 16 Jul 2025 14:30:09 -0400 Subject: [PATCH 1/3] round 2 filtering out node_modules, this time without breaking monorepos --- package-lock.json | 2 +- packages/@apphosting/adapter-nextjs/package.json | 2 +- .../@apphosting/adapter-nextjs/src/bin/build.spec.ts | 4 ++++ packages/@apphosting/adapter-nextjs/src/utils.ts | 12 +++++++++++- 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 5c247f46..a233c75e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -25618,7 +25618,7 @@ } }, "packages/@apphosting/adapter-nextjs": { - "version": "14.0.16", + "version": "14.0.17", "license": "Apache-2.0", "dependencies": { "@apphosting/common": "*", diff --git a/packages/@apphosting/adapter-nextjs/package.json b/packages/@apphosting/adapter-nextjs/package.json index dcbec9fb..54a6ad53 100644 --- a/packages/@apphosting/adapter-nextjs/package.json +++ b/packages/@apphosting/adapter-nextjs/package.json @@ -1,6 +1,6 @@ { "name": "@apphosting/adapter-nextjs", - "version": "14.0.16", + "version": "14.0.17", "main": "dist/index.js", "description": "Experimental addon to the Firebase CLI to add web framework support", "repository": { diff --git a/packages/@apphosting/adapter-nextjs/src/bin/build.spec.ts b/packages/@apphosting/adapter-nextjs/src/bin/build.spec.ts index bc969a8e..eb81b226 100644 --- a/packages/@apphosting/adapter-nextjs/src/bin/build.spec.ts +++ b/packages/@apphosting/adapter-nextjs/src/bin/build.spec.ts @@ -62,6 +62,10 @@ metadata: adapterVersion: ${adapterMetadata.adapterVersion} framework: nextjs frameworkVersion: ${defaultNextVersion} +outputFiles: + serverApp: + include: + - .next/standalone `, }; validateTestFiles(tmpDir, expectedFiles); diff --git a/packages/@apphosting/adapter-nextjs/src/utils.ts b/packages/@apphosting/adapter-nextjs/src/utils.ts index bc50afd3..1edc6e92 100644 --- a/packages/@apphosting/adapter-nextjs/src/utils.ts +++ b/packages/@apphosting/adapter-nextjs/src/utils.ts @@ -151,7 +151,9 @@ async function moveResources( for (const path of pathsToMove) { const isbundleYamlDir = join(appDir, path) === dirname(bundleYamlPath); const existsInOutputBundle = await exists(join(outputBundleAppDir, path)); - if (!isbundleYamlDir && !existsInOutputBundle) { + // Keep apphosting.yaml files in the root directory still, as later steps expect them to be there + const isApphostingYaml = path === "apphosting_preprocessed" || path === "apphosting.yaml"; + if (!isbundleYamlDir && !existsInOutputBundle && !isApphostingYaml) { await move(join(appDir, path), join(outputBundleAppDir, path)); } } @@ -191,6 +193,14 @@ async function generateBundleYaml( frameworkVersion: nextVersion, }, }; + if (!process.env.MONOREPO_COMMAND) { + outputBundle.outputFiles = { + serverApp: { + include: [opts.outputDirectoryAppPath], + }, + }; + } + await writeFile(opts.bundleYamlPath, yamlStringify(outputBundle)); return; } From 541ff31c88b51e973b3e8589bbc48abf52a1d3aa Mon Sep 17 00:00:00 2001 From: yuangwang Date: Wed, 16 Jul 2025 15:07:43 -0400 Subject: [PATCH 2/3] fix test and add bug --- packages/@apphosting/adapter-nextjs/src/bin/build.spec.ts | 2 +- packages/@apphosting/adapter-nextjs/src/utils.ts | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/@apphosting/adapter-nextjs/src/bin/build.spec.ts b/packages/@apphosting/adapter-nextjs/src/bin/build.spec.ts index eb81b226..b61780b3 100644 --- a/packages/@apphosting/adapter-nextjs/src/bin/build.spec.ts +++ b/packages/@apphosting/adapter-nextjs/src/bin/build.spec.ts @@ -65,7 +65,7 @@ metadata: outputFiles: serverApp: include: - - .next/standalone + - ${outputBundleOptions.outputDirectoryAppPath} `, }; validateTestFiles(tmpDir, expectedFiles); diff --git a/packages/@apphosting/adapter-nextjs/src/utils.ts b/packages/@apphosting/adapter-nextjs/src/utils.ts index 1edc6e92..e00e58b2 100644 --- a/packages/@apphosting/adapter-nextjs/src/utils.ts +++ b/packages/@apphosting/adapter-nextjs/src/utils.ts @@ -193,6 +193,7 @@ async function generateBundleYaml( frameworkVersion: nextVersion, }, }; + // TODO (b/432285470) See if there is a way to also delete files for apps using Nx monorepos if (!process.env.MONOREPO_COMMAND) { outputBundle.outputFiles = { serverApp: { From 36113913bb8a94c202befcfdd3c6e7f6ab2204c9 Mon Sep 17 00:00:00 2001 From: yuangwang Date: Fri, 18 Jul 2025 11:09:52 -0400 Subject: [PATCH 3/3] fix adapter --- packages/@apphosting/adapter-nextjs/src/bin/build.spec.ts | 2 +- packages/@apphosting/adapter-nextjs/src/utils.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/@apphosting/adapter-nextjs/src/bin/build.spec.ts b/packages/@apphosting/adapter-nextjs/src/bin/build.spec.ts index b61780b3..eb81b226 100644 --- a/packages/@apphosting/adapter-nextjs/src/bin/build.spec.ts +++ b/packages/@apphosting/adapter-nextjs/src/bin/build.spec.ts @@ -65,7 +65,7 @@ metadata: outputFiles: serverApp: include: - - ${outputBundleOptions.outputDirectoryAppPath} + - .next/standalone `, }; validateTestFiles(tmpDir, expectedFiles); diff --git a/packages/@apphosting/adapter-nextjs/src/utils.ts b/packages/@apphosting/adapter-nextjs/src/utils.ts index e00e58b2..aaf5ead8 100644 --- a/packages/@apphosting/adapter-nextjs/src/utils.ts +++ b/packages/@apphosting/adapter-nextjs/src/utils.ts @@ -197,7 +197,7 @@ async function generateBundleYaml( if (!process.env.MONOREPO_COMMAND) { outputBundle.outputFiles = { serverApp: { - include: [opts.outputDirectoryAppPath], + include: [normalize(relative(cwd, opts.outputDirectoryAppPath))], }, }; }