Skip to content

feat(astro): support Astro 6 and 7 - #670

Open
leoortizz wants to merge 19 commits into
firebase:mainfrom
leoortizz:astro-adapter
Open

feat(astro): support Astro 6 and 7#670
leoortizz wants to merge 19 commits into
firebase:mainfrom
leoortizz:astro-adapter

Conversation

@leoortizz

Copy link
Copy Markdown
Member

Add the App Hosting Astro adapter, with Astro 5, 6 and 7 support

Lands @apphosting/astro-adapter in packages/@apphosting/experimental/ and extends
it to Astro 6 and 7. Fixes #667.

The adapter has lived on this branch since 0.0.1 was published to npm, and that
release only works on Astro 5. @astrojs/node@10 (Astro 6) replaced the adapter
args config with a virtual:astro-node:config virtual module, so 0.0.1 fails to
build on Astro 6+.

How version support works

The installed @astrojs/node major selects the config mechanism, since this adapter
reuses that package's server entrypoint:

@astrojs/node Astro Mechanism
9 5 adapter args export (unchanged from 0.0.1)
10, 11 6, 7 virtual:astro-node:config module + entrypointResolution: "auto"

usesVirtualConfig() resolves the installed major from the app's own node_modules,
so no user configuration changes. UserOptions is untouched — still just mode.

Bug fixes

  • .apphosting was created with a non-recursive mkdir, so any second build in
    the same directory failed with EEXIST. Now uses ensureDir.
  • frameworkVersion came from npm view astro version, reporting npm's latest
    release rather than the installed one — every non-latest app was mislabelled, and it
    cost a network call per build. Now reads the installed package.json, matching how
    firebase-tools resolves Astro's version.

Testing

Verified against real App Hosting deployments on all three majors — no mocks or
synthetic fixtures. Each was deployed and exercised over HTTP:

v5 (@astrojs/node 9) v6 (10) v7 (11)
SSR renders per request
API routes
Middleware executes
frameworkVersion in bundle.yaml 5.18.2 6.4.8 7.1.3

Each adapter option was toggled on real deployments to confirm it was load-bearing;
anything that worked without it was dropped. createConfigPlugin also supplies
@astrojs/node's own defaults for staticHeaders, bodySizeLimit and
experimentalDisableStreaming — without them its server imports resolved to
undefined, silently removing the 1 GiB request body limit and emitting build
warnings in every user's project.

Also adds unit tests (npm test) covering the virtual config plugin.

Notes

  • Ships under experimental/; the community/ workspace glob is dropped since this
    was its only member.
  • astro and @astrojs/node are optional peer dependencies, matching the other
    adapters.

Yuangwang and others added 14 commits January 22, 2025 12:33
@astrojs/node@10 replaced the adapter `args` config with a
`virtual:astro-node:config` module, so the installed major now selects
the
mechanism: v10+ gets a vendored config plugin and `entrypointResolution:
"auto"`,
v9 keeps the existing `args` export. Astro 5 support is unchanged.

Also fixes two bugs that block repeat and multi-version use:
- `.apphosting` was created with a non-recursive mkdir, so any second
  build in
  the same directory failed with EEXIST.
- `frameworkVersion` came from `npm view astro version`, reporting the
  latest
  published release rather than the one installed. It now reads the
  installed
  package.json, which also drops a network call from the build.

Verified against real App Hosting deployments on Astro 5, 6 and 7: SSR
rendering, API routes and middleware all serve per-request.
Relocates @apphosting/astro-adapter to
packages/@apphosting/experimental/,
registering the new workspace glob and adding the directory to the CI
build
artifact paths. The community/ glob is dropped since adapter-astro was
its only
member. Pure rename, no source changes.
@wiz-9635d3485b

wiz-9635d3485b Bot commented Jul 28, 2026

Copy link
Copy Markdown

Wiz Scan Summary

Scanner Findings
Vulnerability Finding Vulnerabilities 1 Low
Data Finding Sensitive Data -
Secret Finding Secrets -
IaC Misconfiguration IaC Misconfigurations -
SAST Finding SAST Findings 1 Medium
Software Management Finding Software Management Findings -
Total 1 Medium 1 Low

View scan details in Wiz

To detect these findings earlier in the dev lifecycle, try the Wiz Code extension for VS Code, JetBrains, or Visual Studio.

@leoortizz
leoortizz marked this pull request as ready for review July 28, 2026 17:02

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces experimental support for Astro (versions 5, 6, and 7) on Firebase App Hosting by adding a new @apphosting/astro-adapter package under packages/@apphosting/experimental/adapter-astro, along with integration updates in lerna.json, package.json, and the publishing scripts. The review feedback highlights several key improvements: resolving a critical syntax error in the virtual config generator when handling undefined values, adding the new package path to lerna.json for proper Lerna management, removing an invalid trailing comma in tsconfig.json, adopting optional chaining for safer configuration access, ensuring cross-platform path compatibility using path.join, refactoring synchronous file operations to asynchronous ones, and removing a redundant node:fs/promises import.

Comment thread packages/@apphosting/experimental/adapter-astro/src/utils.ts
Comment thread lerna.json
Comment thread packages/@apphosting/experimental/adapter-astro/tsconfig.json Outdated
Comment thread packages/@apphosting/experimental/adapter-astro/src/index.ts
Comment thread packages/@apphosting/experimental/adapter-astro/src/index.ts Outdated
Comment thread packages/@apphosting/experimental/adapter-astro/src/index.ts
Comment thread packages/@apphosting/experimental/adapter-astro/src/index.ts Outdated
The move to packages/@apphosting/experimental/ updated the npm workspaces
glob but not lerna.json, so lerna managed 8 packages and skipped the astro
adapter entirely — `npm run build` never built it. The community/ glob is
replaced rather than added to, since that directory no longer exists.
env:
ADAPTER_NEXTJS_NPM_TOKEN: ${{ secrets.ADAPTER_NEXTJS_NPM_TOKEN }}
ADAPTER_ANGULAR_NPM_TOKEN: ${{ secrets.ADAPTER_ANGULAR_NPM_TOKEN }}
ADAPTER_COMMON_NPM_TOKEN: ${{ secrets.ADAPTER_COMMON_NPM_TOKEN }}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you need to define ADAPTER_ASTRO_NPM_TOKEN: ${{ secrets.ADAPTER_ASTRO_NPM_TOKEN }} here too and we need to set this up in the github as well

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can help with setting it up on github

const require = createRequire(import.meta.url);

try {
const packageJsonPath = require.resolve(join(packageName, "package.json"), {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this might cause some issues in windows with how the slashes are, probably want it to be const packageJsonPath = require.resolve(${packageName}/package.json) instead

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support Astro v6 in @apphosting/astro-adapter

2 participants