Skip to content

Upgrade to Astro 7 - #62

Merged
pierosavi merged 7 commits into
mainfrom
astro-7
Oct 12, 2026
Merged

pierosavi merged 7 commits into
mainfrom
astro-7

Conversation

@pierosavi

@pierosavi pierosavi commented Oct 9, 2026 •

Copy link
Copy Markdown
Member

Upgraded following the migration guide.
Also bumped the netlify and node adapters to their Astro 7 majors.

Changes:

  • experimental.cache is now top level cache
  • The netlify adapter now emulates the Netlify platform in astro dev, including edge functions via a Deno server. We don't have Deno and don't use edge functions (middleware runs as a normal function), so I turned that part off with devFeatures.edgeFunctions: false. It was throwing an unhandled rejection on every dev start. Dev only, the build output is the same.
  • The new compressHtml default removes spaces before inline links, the suggestion to add {" "} to existing and new links doesn't justify the tiny size improvements.
  • Regenerating the lockfile dropped @types/node (it was a transitive dep of vite/vitest) and bumped typescript-eslint, so I added @types/node explicitly and exported DeviceIntegration which the newer lint flagged.

@netlify

netlify Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for device-database-preview ready!

Name Link
🔨 Latest commit 9e2dcad
🔍 Latest deploy log https://app.netlify.com/projects/device-database-preview/deploys/6accead5bc788d7ad1c91c5f
😎 Deploy Preview https://deploy-preview-62--device-database-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

Comment thread src/types/device/index.ts
Comment thread astro.config.mjs Outdated
Comment on lines +12 to +21
: netlify({
// Dev only. The adapter emulates Netlify in `astro dev`, edge functions
// need Deno which we don't have and don't use (middleware runs as a
// normal function), so skip it.
devFeatures: {
edgeFunctions: false,
images: true,
environmentVariables: false,
},
});

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 didn't realize that we were emulating the netlify adapter when running in dev mode.
now that i know, i'd argue that we shouldn't, as it is our least important target
we should instead be "emulating" the node adapter

disabling { noExternal: true } in the astro config seems to be required in order for that to work, otherwise vite errors out when it encounters cjs

in turn this requires modifying the Dockerfile to include build and include node_modules somewhat like this:

FROM node:24-alpine AS deps
WORKDIR /app
RUN corepack enable
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml .npmrc ./
RUN pnpm install --frozen-lockfile --prod --ignore-scripts

aaaand then further down the copy:

COPY --from=deps /app/node_modules ./node_modules

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I wasn't sure why we needed it either so now it's gone!
In ae11786 I updated the adapter to depend on process.env.NETLIFY, removed noExternal: true, moved dependencies to dev so they don't get bundled (astro bundles its runtime into dist), updated Dockerfile based on your suggestion and the README

…eps to dev and update Dockerfile accordingly
Comment thread README.md
**Runtime config.** All app config is runtime-only: the server reads `API_AUTHORITY`, `CSR_API_AUTHORITY` and `NOINDEX` from the environment (`-e`), so a single image serves every environment — nothing is baked in at build time. `NOINDEX` defaults to `true` (no indexing) when unset; a flip takes effect on container restart (plus CDN cache TTL). Two consequences of prerendering: the client-side API authority is served by the `/config.js` endpoint rather than inlined into the HTML, and prerendered pages carry no `robots` meta tag or `X-Robots-Tag` header (they would freeze the build-time value) — `robots.txt`, which is server-rendered, remains the crawl gate for preview deploys.

The server listens on `HOST=0.0.0.0` and `PORT=4321` (both overridable via env vars). The runtime image ships only the bundled server output — the node build bundles all dependencies into `dist/` (`vite.ssr.noExternal`), so there is no `node_modules` in the final image. One consequence: Astro's sharp-backed `/_image` endpoint is unavailable in the container (the project doesn't use `astro:assets`, so nothing depends on it — revisit if that changes).
The server listens on `HOST=0.0.0.0` and `PORT=4321` (both overridable via env vars). The runtime image ships the server output in `dist/` plus a production-only `node_modules`. Astro and the adapter are bundled into `dist/`, so only packages the server imports at runtime belong in `dependencies`; everything else (including `astro` and build tooling) lives in `devDependencies` to keep the image small. Astro's sharp-backed `/_image` endpoint is unavailable in the container (the project doesn't use `astro:assets`, so nothing depends on it — revisit if that changes).

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.

thanks claude 😁

@pierosavi
pierosavi merged commit c54edf4 into main Oct 12, 2026
5 checks passed
@pierosavi
pierosavi deleted the astro-7 branch October 12, 2026 14:14
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.

2 participants