Skip to content

Commit 4976ee2

Browse files
authored
Merge branch 'main' into feat/support-non-existent-next-configs
2 parents ece5dfd + 121558a commit 4976ee2

File tree

5 files changed

+60
-10
lines changed

5 files changed

+60
-10
lines changed

CODEOWNERS

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# Global reviewers
22
# TODO add group for global reviewers
3-
* @jamesdaniels @leoortizz @Yuangwang @tonyjhuang
3+
* @jamesdaniels @leoortizz @Yuangwang @annajowang
44

55
# App Hosting Platform Adapters code
66
# TODO add group for App Hosting
7-
/packages/@apphosting/adapter-*/ @Yuangwang @sjjj986 @jamesdaniels @tonyjhuang @blidd-google @taeold
8-
/packages/@apphosting/common/ @Yuangwang @sjjj986 @jamesdaniels @tonyjhuang @blidd-google @taeold
7+
/packages/@apphosting/adapter-*/ @Yuangwang @sjjj986 @jamesdaniels @annajowang @blidd-google @taeold
8+
/packages/@apphosting/common/ @Yuangwang @sjjj986 @jamesdaniels @annajowang @blidd-google @taeold
99

1010
# Web Frameworks code
1111
/packages/@apphosting/build/ @FirebaseExtended/firebase-full-time-employees @FirebaseExtended/monogram

README.md

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Any framework that can generate a build output in accordance with the App Hostin
1818
The output bundle primarily consists of a `bundle.yaml` file that sits inside of the `.apphosting` directory. This bundle.yaml contains all the ways that frameworks can configure App Hosting when users deploy their applications.
1919

2020
> [!NOTE]
21-
> App Hosting technically supports all all node applications, but no custom framework features will be enabled without the output bundle.
21+
> App Hosting technically supports all node applications, but no custom framework features will be enabled without the output bundle.
2222
2323
## Output bundle Schema
2424

@@ -37,6 +37,7 @@ interface OutputBundle {
3737
version: "v1"
3838
runConfig: RunConfig;
3939
metadata: Metadata;
40+
outputFiles?: OutputFiles;
4041
}
4142
```
4243

@@ -108,12 +109,44 @@ interface Metadata {
108109
| `framework` | `string` | Name of the framework that is being supported | y |
109110
| `frameworkVersion` | `string` |Version of the framework that is being supported | n |
110111

112+
### OutputFiles
113+
114+
OutputFiles is an optional field to configure outputFiles and optimize server files + static assets.
115+
116+
```typescript
117+
interface OutputFiles {
118+
serverApp: ServerApp
119+
}
120+
121+
```
122+
123+
| Field | Type | Description | Required? |
124+
| ---------- | ------- | - | - |
125+
| `serverApp` | `ServerApp` | ServerApp holds configurations related to the serving files at runtime from Cloud Run | y |
126+
127+
### ServerApp
128+
129+
OutputFiles is an optional field to configure outputFiles and optimize server files + static assets.
130+
131+
```typescript
132+
interface ServerApp {
133+
include: string[]
134+
}
135+
136+
```
137+
138+
| Field | Type | Description | Required? |
139+
| ---------- | ------- | - | - |
140+
| `include` | `string[]` | include holds a list of directories + files relative to the app root dir that frameworks need to deploy to the App Hosting server, generally this will be the output/dist directory (e.g. .output or dist). In the case that the framework wants to include all files they can use [“.”] | y |
141+
142+
## Sample
143+
111144
Here is a sample `.apphosting/bundle.yaml` file putting all this together:
112145

113146
```yaml
114147
version: v1
115148
runConfig:
116-
runCommand: 'node dist/index.js'
149+
runCommand: node dist/index.js
117150
environmentVariables:
118151
- variable: VAR
119152
value: 8080
@@ -123,6 +156,12 @@ runConfig:
123156
memoryMiB: 512
124157
minInstances: 0
125158
maxInstances: 14
159+
160+
outputFiles:
161+
serverApp:
162+
include:
163+
- dist
164+
- .output
126165

127166
metadata:
128167
adapterPackageName: npm-name

packages/@apphosting/adapter-nextjs/src/overrides.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,9 @@ export async function overrideNextConfig(projectRoot: string, nextConfigFileName
8787
* Current overrides include:
8888
* - images.unoptimized = true, unless user explicitly sets images.unoptimized to false or
8989
* is using a custom image loader.
90-
*
9190
* @param importStatement The import statement for the original config.
9291
* @param fileExtension The file extension of the original config. Use ".js", ".mjs", or ".ts"
93-
* @returns The custom Next.js config.
92+
* @return The custom Next.js config.
9493
*/
9594
function getCustomNextConfig(importStatement: string, fileExtension: string) {
9695
return `
@@ -176,7 +175,6 @@ export async function validateNextConfigOverride(
176175
* This function adds the following headers to all routes:
177176
* - x-fah-adapter: The Firebase App Hosting adapter version used to build the app.
178177
* - x-fah-middleware: When middleware is enabled.
179-
*
180178
* @param appPath The path to the app directory.
181179
* @param distDir The path to the dist directory.
182180
* @param adapterMetadata The adapter metadata.

packages/@apphosting/adapter-nextjs/src/utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export async function loadConfig(root: string, projectRoot: string): Promise<Nex
4242
* Loads the route manifest from the standalone directory.
4343
* @param standalonePath The path to the standalone directory.
4444
* @param distDir The path to the dist directory.
45-
* @returns The route manifest.
45+
* @return The route manifest.
4646
*/
4747
export function loadRouteManifest(standalonePath: string, distDir: string): RoutesManifest {
4848
const manifestPath = join(standalonePath, distDir, ROUTES_MANIFEST);
@@ -54,7 +54,7 @@ export function loadRouteManifest(standalonePath: string, distDir: string): Rout
5454
* Loads the middleware manifest from the standalone directory.
5555
* @param standalonePath The path to the standalone directory.
5656
* @param distDir The path to the dist directory.
57-
* @returns The middleware manifest.
57+
* @return The middleware manifest.
5858
*/
5959
export function loadMiddlewareManifest(
6060
standalonePath: string,

packages/@apphosting/common/src/index.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export interface OutputBundleConfig {
55
version: "v1";
66
runConfig: RunConfig;
77
metadata: Metadata;
8+
outputFiles?: OutputFiles;
89
}
910

1011
// Fields needed to configure the App Hosting server
@@ -38,6 +39,18 @@ export interface Metadata {
3839
frameworkVersion?: string;
3940
}
4041

42+
// Optional outputFiles to configure outputFiles and optimize server files + static assets.
43+
// If this is not set then all of the source code will be uploaded
44+
interface OutputFiles {
45+
serverApp: ServerApp;
46+
}
47+
48+
// ServerApp holds a list of directories + files relative to the app root dir that frameworks need to deploy to the App Hosting server,
49+
// generally this will be the output/dist directory (e.g. .output or dist). To include all files set this to [“.”]
50+
interface ServerApp {
51+
include: string[];
52+
}
53+
4154
// Represents a single environment variable.
4255
export interface EnvVarConfig {
4356
// Name of the variable

0 commit comments

Comments
 (0)