diff --git a/.changeset/chubby-tips-change.md b/.changeset/chubby-tips-change.md new file mode 100644 index 000000000000..a9547317e251 --- /dev/null +++ b/.changeset/chubby-tips-change.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Removes types for the `astro:ssr-manifest` module, which was removed diff --git a/.changeset/cloudflare-image-component.md b/.changeset/cloudflare-image-component.md new file mode 100644 index 000000000000..c9fc47c8ae34 --- /dev/null +++ b/.changeset/cloudflare-image-component.md @@ -0,0 +1,5 @@ +--- +"@astrojs/cloudflare": major +--- + +Changes the default image service from `compile` to `cloudflare-binding`. Image services options that resulted in broken images in development due to Node JS incompatiblities have now been updated to use the noop passthrough image service in dev mode. - ([Cloudflare v13 and Astro6 upgrade guidance](https://v6.docs.astro.build/en/guides/integrations-guide/cloudflare/#changed-imageservice-default)) diff --git a/.changeset/cloudflare-image-dev-fix.md b/.changeset/cloudflare-image-dev-fix.md new file mode 100644 index 000000000000..d199034787fb --- /dev/null +++ b/.changeset/cloudflare-image-dev-fix.md @@ -0,0 +1,5 @@ +--- +"astro": patch +--- + +Improves compatibility of the built-in image endpoint with runtimes that don't support CJS dependencies correctly diff --git a/.changeset/cloudflare-image-service-object.md b/.changeset/cloudflare-image-service-object.md new file mode 100644 index 000000000000..b17d655d4ab7 --- /dev/null +++ b/.changeset/cloudflare-image-service-object.md @@ -0,0 +1,20 @@ +--- +"@astrojs/cloudflare": minor +--- + +Adds support for configuring the image service as an object with separate `build` and `runtime` options + +It is now possible to set both a build-time and runtime service independently. Currently, `'compile'` is the only available build time option. The supported runtime options are `'passthrough'` (default) and `'cloudflare-binding'`: + +```js title="astro.config.mjs" ins={6} +import { defineConfig } from 'astro/config'; +import cloudflare from '@astrojs/cloudflare'; + +export default defineConfig({ + adapter: cloudflare({ + imageService: { build: 'compile', runtime: 'cloudflare-binding' } + }), +}); +``` + +See the [Cloudflare adapter `imageService` docs](https://v6.docs.astro.build/en/guides/integrations-guide/cloudflare/#imageservice) for more information about configuring your image service. diff --git a/.changeset/cute-suns-check.md b/.changeset/cute-suns-check.md new file mode 100644 index 000000000000..f2af230aa9ed --- /dev/null +++ b/.changeset/cute-suns-check.md @@ -0,0 +1,5 @@ +--- +'@astrojs/node': patch +--- + +Updates to new Adapter API introduced in v6 diff --git a/.changeset/ten-numbers-rush.md b/.changeset/ten-numbers-rush.md new file mode 100644 index 000000000000..2b332b6c9157 --- /dev/null +++ b/.changeset/ten-numbers-rush.md @@ -0,0 +1,5 @@ +--- +'@astrojs/cloudflare': patch +--- + +Adds an error when running on Stackblitz, since `workerd` doesn't support it diff --git a/.changeset/twenty-signs-brush.md b/.changeset/twenty-signs-brush.md new file mode 100644 index 000000000000..a18ed3f1991c --- /dev/null +++ b/.changeset/twenty-signs-brush.md @@ -0,0 +1,28 @@ +--- +'@astrojs/cloudflare': minor +--- + +Adds support for more `@cloudflare/vite-plugin` options + +The adapter now accepts the following [options from Cloudflare's Vite plugin](https://developers.cloudflare.com/workers/vite-plugin/reference/api/): + +- `auxiliaryWorkers` +- `configPath` +- `inspectorPort` +- `persistState` +- `remoteBindings` +- `experimental.headersAndRedirectsDevModeSupport` + +For example, you can now set `inspectorPort` to provide a custom port for debugging your Workers: + +```js +// astro.config.mjs +import { defineConfig } from 'astro/config' +import cloudflare from '@astrojs/cloudflare' + +export default defineConfig({ + adapter: cloudflare({ + inspectorPort: 3456 + }) +}) +``` \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/---01-bug-report.yml b/.github/ISSUE_TEMPLATE/---01-bug-report.yml index 5184530e0065..8999cbe4da18 100644 --- a/.github/ISSUE_TEMPLATE/---01-bug-report.yml +++ b/.github/ISSUE_TEMPLATE/---01-bug-report.yml @@ -42,7 +42,7 @@ body: id: bug-reproduction attributes: label: Link to Minimal Reproducible Example - description: 'Use [StackBlitz](https://astro.new/repro) to create a minimal reproduction of the problem. **A minimal reproduction is required** so that others can help debug your issue. If a report is vague (e.g. just a generic error message) and has no reproduction, it may be auto-closed. Not sure how to create a minimal example? [Read our guide](https://docs.astro.build/en/guides/troubleshooting/#creating-minimal-reproductions)' + description: 'Use [StackBlitz](https://astro.new/repro) (does not support `@astrojs/cloudflare`) or [GitHub](https://astro.new/minimal?on=github) to create a minimal reproduction of the problem. **A minimal reproduction is required** so that others can help debug your issue. If a report is vague (e.g. just a generic error message) and has no reproduction, it may be auto-closed. Not sure how to create a minimal example? [Read our guide](https://docs.astro.build/en/guides/troubleshooting/#creating-minimal-reproductions).' placeholder: 'https://stackblitz.com/abcd1234' validations: required: true diff --git a/.github/workflows/continuous_benchmark.yml b/.github/workflows/continuous_benchmark.yml index d761fbee6817..df4ff740b8de 100644 --- a/.github/workflows/continuous_benchmark.yml +++ b/.github/workflows/continuous_benchmark.yml @@ -56,7 +56,7 @@ jobs: timeout-minutes: 15 - name: Run the benchmarks - uses: CodSpeedHQ/action@4deb3275dd364fb96fb074c953133d29ec96f80f # v4.10.6 + uses: CodSpeedHQ/action@2ac572851726409c88c02a307f1ea2632a9ea59b # v4.11.0 timeout-minutes: 30 with: working-directory: ./benchmark diff --git a/packages/astro/client.d.ts b/packages/astro/client.d.ts index 77f3a71c1511..0ef4eb8797f5 100644 --- a/packages/astro/client.d.ts +++ b/packages/astro/client.d.ts @@ -287,10 +287,6 @@ declare module '*.mdx' { export default load; } -declare module 'astro:ssr-manifest' { - export const manifest: import('./dist/types/public/internal.js').SSRManifest; -} - declare module 'astro:static-paths' { export const StaticPaths: typeof import('./dist/runtime/prerender/static-paths.js').StaticPaths; } diff --git a/packages/astro/e2e/fixtures/actions-blog/package.json b/packages/astro/e2e/fixtures/actions-blog/package.json index c5ee22becbec..4d3cecc5bb25 100644 --- a/packages/astro/e2e/fixtures/actions-blog/package.json +++ b/packages/astro/e2e/fixtures/actions-blog/package.json @@ -10,7 +10,7 @@ "astro": "astro" }, "dependencies": { - "@astrojs/check": "^0.9.6", + "@astrojs/check": "workspace:*", "@astrojs/db": "workspace:*", "@astrojs/node": "workspace:*", "@astrojs/react": "workspace:*", diff --git a/packages/astro/e2e/fixtures/actions-react-19/package.json b/packages/astro/e2e/fixtures/actions-react-19/package.json index 6b82811c93b4..2650dfba9b6d 100644 --- a/packages/astro/e2e/fixtures/actions-react-19/package.json +++ b/packages/astro/e2e/fixtures/actions-react-19/package.json @@ -10,7 +10,7 @@ "astro": "astro" }, "dependencies": { - "@astrojs/check": "^0.9.6", + "@astrojs/check": "workspace:*", "@astrojs/db": "workspace:*", "@astrojs/node": "workspace:*", "@astrojs/react": "workspace:*", diff --git a/packages/astro/e2e/fixtures/astro-component/package.json b/packages/astro/e2e/fixtures/astro-component/package.json index 3f147f6de4ee..d6a66bb872bb 100644 --- a/packages/astro/e2e/fixtures/astro-component/package.json +++ b/packages/astro/e2e/fixtures/astro-component/package.json @@ -6,6 +6,6 @@ "@astrojs/preact": "workspace:*", "@e2e/astro-linked-lib": "link:../_deps/astro-linked-lib", "astro": "workspace:*", - "preact": "^10.28.3" + "preact": "^10.28.4" } } diff --git a/packages/astro/e2e/fixtures/client-only/package.json b/packages/astro/e2e/fixtures/client-only/package.json index c6ad3b2bb1ce..613f60c98966 100644 --- a/packages/astro/e2e/fixtures/client-only/package.json +++ b/packages/astro/e2e/fixtures/client-only/package.json @@ -11,11 +11,11 @@ "astro": "workspace:*" }, "dependencies": { - "preact": "^10.28.3", + "preact": "^10.28.4", "react": "^18.3.1", "react-dom": "^18.3.1", "solid-js": "^1.9.11", - "svelte": "^5.51.5", + "svelte": "^5.53.1", "vue": "^3.5.28" } } diff --git a/packages/astro/e2e/fixtures/cloudflare/package.json b/packages/astro/e2e/fixtures/cloudflare/package.json index e722a46d90eb..0a66a112a96e 100644 --- a/packages/astro/e2e/fixtures/cloudflare/package.json +++ b/packages/astro/e2e/fixtures/cloudflare/package.json @@ -12,7 +12,7 @@ "@astrojs/preact": "workspace:*", "@astrojs/react": "workspace:*", "@astrojs/vue": "workspace:*", - "preact": "^10.28.3", + "preact": "^10.28.4", "@test/e2e-my-lib": "workspace:*", "vue": "^3.5.28", "@vitejs/plugin-vue": "^6.0.4", diff --git a/packages/astro/e2e/fixtures/dev-toolbar/package.json b/packages/astro/e2e/fixtures/dev-toolbar/package.json index f5436b750eb1..7c1f24318527 100644 --- a/packages/astro/e2e/fixtures/dev-toolbar/package.json +++ b/packages/astro/e2e/fixtures/dev-toolbar/package.json @@ -5,6 +5,6 @@ "dependencies": { "@astrojs/preact": "workspace:*", "astro": "workspace:*", - "preact": "^10.28.3" + "preact": "^10.28.4" } } diff --git a/packages/astro/e2e/fixtures/error-cyclic/package.json b/packages/astro/e2e/fixtures/error-cyclic/package.json index 5db7c4c9cea7..d7c5c1de6ac0 100644 --- a/packages/astro/e2e/fixtures/error-cyclic/package.json +++ b/packages/astro/e2e/fixtures/error-cyclic/package.json @@ -5,6 +5,6 @@ "dependencies": { "@astrojs/preact": "workspace:*", "astro": "workspace:*", - "preact": "^10.28.3" + "preact": "^10.28.4" } } diff --git a/packages/astro/e2e/fixtures/errors/package.json b/packages/astro/e2e/fixtures/errors/package.json index 9f10228c4e73..d29b5d1f4379 100644 --- a/packages/astro/e2e/fixtures/errors/package.json +++ b/packages/astro/e2e/fixtures/errors/package.json @@ -9,12 +9,12 @@ "@astrojs/svelte": "workspace:*", "@astrojs/vue": "workspace:*", "astro": "workspace:*", - "preact": "^10.28.3", + "preact": "^10.28.4", "react": "^18.3.1", "react-dom": "^18.3.1", "sass": "^1.97.3", "solid-js": "^1.9.11", - "svelte": "^5.51.5", + "svelte": "^5.53.1", "vue": "^3.5.28" } } diff --git a/packages/astro/e2e/fixtures/hydration-race/package.json b/packages/astro/e2e/fixtures/hydration-race/package.json index 69cdf7d9688c..1d55a24d6043 100644 --- a/packages/astro/e2e/fixtures/hydration-race/package.json +++ b/packages/astro/e2e/fixtures/hydration-race/package.json @@ -9,6 +9,6 @@ "dependencies": { "@astrojs/preact": "workspace:*", "astro": "workspace:*", - "preact": "^10.28.3" + "preact": "^10.28.4" } } diff --git a/packages/astro/e2e/fixtures/multiple-frameworks/package.json b/packages/astro/e2e/fixtures/multiple-frameworks/package.json index d072aba1b59f..69b67ec0d96a 100644 --- a/packages/astro/e2e/fixtures/multiple-frameworks/package.json +++ b/packages/astro/e2e/fixtures/multiple-frameworks/package.json @@ -13,11 +13,11 @@ "dependencies": { "@webcomponents/template-shadowroot": "^0.2.1", "lit": "^3.3.2", - "preact": "^10.28.3", + "preact": "^10.28.4", "react": "^18.3.1", "react-dom": "^18.3.1", "solid-js": "^1.9.11", - "svelte": "^5.51.5", + "svelte": "^5.53.1", "vue": "^3.5.28" } } diff --git a/packages/astro/e2e/fixtures/namespaced-component/package.json b/packages/astro/e2e/fixtures/namespaced-component/package.json index a6acfebf5014..baacbf187677 100644 --- a/packages/astro/e2e/fixtures/namespaced-component/package.json +++ b/packages/astro/e2e/fixtures/namespaced-component/package.json @@ -8,6 +8,6 @@ "astro": "workspace:*" }, "dependencies": { - "preact": "^10.28.3" + "preact": "^10.28.4" } } diff --git a/packages/astro/e2e/fixtures/nested-in-preact/package.json b/packages/astro/e2e/fixtures/nested-in-preact/package.json index 3872a02b82b0..f643da96c84c 100644 --- a/packages/astro/e2e/fixtures/nested-in-preact/package.json +++ b/packages/astro/e2e/fixtures/nested-in-preact/package.json @@ -11,11 +11,11 @@ "astro": "workspace:*" }, "dependencies": { - "preact": "^10.28.3", + "preact": "^10.28.4", "react": "^18.3.1", "react-dom": "^18.3.1", "solid-js": "^1.9.11", - "svelte": "^5.51.5", + "svelte": "^5.53.1", "vue": "^3.5.28" } } diff --git a/packages/astro/e2e/fixtures/nested-in-react/package.json b/packages/astro/e2e/fixtures/nested-in-react/package.json index ea68b9dda500..16f8cf23e969 100644 --- a/packages/astro/e2e/fixtures/nested-in-react/package.json +++ b/packages/astro/e2e/fixtures/nested-in-react/package.json @@ -11,11 +11,11 @@ "astro": "workspace:*" }, "dependencies": { - "preact": "^10.28.3", + "preact": "^10.28.4", "react": "^18.3.1", "react-dom": "^18.3.1", "solid-js": "^1.9.11", - "svelte": "^5.51.5", + "svelte": "^5.53.1", "vue": "^3.5.28" } } diff --git a/packages/astro/e2e/fixtures/nested-in-solid/package.json b/packages/astro/e2e/fixtures/nested-in-solid/package.json index b119a2ab4c4b..9d76bd65676e 100644 --- a/packages/astro/e2e/fixtures/nested-in-solid/package.json +++ b/packages/astro/e2e/fixtures/nested-in-solid/package.json @@ -11,11 +11,11 @@ "astro": "workspace:*" }, "dependencies": { - "preact": "^10.28.3", + "preact": "^10.28.4", "react": "^18.3.1", "react-dom": "^18.3.1", "solid-js": "^1.9.11", - "svelte": "^5.51.5", + "svelte": "^5.53.1", "vue": "^3.5.28" } } diff --git a/packages/astro/e2e/fixtures/nested-in-svelte/package.json b/packages/astro/e2e/fixtures/nested-in-svelte/package.json index fff8b2613f8b..4ef0ed3897ca 100644 --- a/packages/astro/e2e/fixtures/nested-in-svelte/package.json +++ b/packages/astro/e2e/fixtures/nested-in-svelte/package.json @@ -11,11 +11,11 @@ "astro": "workspace:*" }, "dependencies": { - "preact": "^10.28.3", + "preact": "^10.28.4", "react": "^18.3.1", "react-dom": "^18.3.1", "solid-js": "^1.9.11", - "svelte": "^5.51.5", + "svelte": "^5.53.1", "vue": "^3.5.28" } } diff --git a/packages/astro/e2e/fixtures/nested-in-vue/package.json b/packages/astro/e2e/fixtures/nested-in-vue/package.json index 209a74e077b9..15a5c332caad 100644 --- a/packages/astro/e2e/fixtures/nested-in-vue/package.json +++ b/packages/astro/e2e/fixtures/nested-in-vue/package.json @@ -11,11 +11,11 @@ "astro": "workspace:*" }, "dependencies": { - "preact": "^10.28.3", + "preact": "^10.28.4", "react": "^18.3.1", "react-dom": "^18.3.1", "solid-js": "^1.9.11", - "svelte": "^5.51.5", + "svelte": "^5.53.1", "vue": "^3.5.28" } } diff --git a/packages/astro/e2e/fixtures/nested-recursive/package.json b/packages/astro/e2e/fixtures/nested-recursive/package.json index 8141e0cea63c..9249d390d6ef 100644 --- a/packages/astro/e2e/fixtures/nested-recursive/package.json +++ b/packages/astro/e2e/fixtures/nested-recursive/package.json @@ -11,11 +11,11 @@ "astro": "workspace:*" }, "dependencies": { - "preact": "^10.28.3", + "preact": "^10.28.4", "react": "^18.3.1", "react-dom": "^18.3.1", "solid-js": "^1.9.11", - "svelte": "^5.51.5", + "svelte": "^5.53.1", "vue": "^3.5.28" }, "scripts": { diff --git a/packages/astro/e2e/fixtures/preact-compat-component/package.json b/packages/astro/e2e/fixtures/preact-compat-component/package.json index c263ea903d14..8b18eb7f74c1 100644 --- a/packages/astro/e2e/fixtures/preact-compat-component/package.json +++ b/packages/astro/e2e/fixtures/preact-compat-component/package.json @@ -5,6 +5,6 @@ "dependencies": { "@astrojs/preact": "workspace:*", "astro": "workspace:*", - "preact": "^10.28.3" + "preact": "^10.28.4" } } diff --git a/packages/astro/e2e/fixtures/preact-component/package.json b/packages/astro/e2e/fixtures/preact-component/package.json index e9f7a7d4065e..970c0cd9e524 100644 --- a/packages/astro/e2e/fixtures/preact-component/package.json +++ b/packages/astro/e2e/fixtures/preact-component/package.json @@ -6,6 +6,6 @@ "@astrojs/mdx": "workspace:*", "@astrojs/preact": "workspace:*", "astro": "workspace:*", - "preact": "^10.28.3" + "preact": "^10.28.4" } } diff --git a/packages/astro/e2e/fixtures/preact-lazy-component/package.json b/packages/astro/e2e/fixtures/preact-lazy-component/package.json index 1c7881f89726..e8bf6e9f2b4c 100644 --- a/packages/astro/e2e/fixtures/preact-lazy-component/package.json +++ b/packages/astro/e2e/fixtures/preact-lazy-component/package.json @@ -6,6 +6,6 @@ "@astrojs/mdx": "workspace:*", "@astrojs/preact": "workspace:*", "astro": "workspace:*", - "preact": "^10.28.3" + "preact": "^10.28.4" } } diff --git a/packages/astro/e2e/fixtures/react19-preact-hook-error/package.json b/packages/astro/e2e/fixtures/react19-preact-hook-error/package.json index 3b1fc64a4d6e..3d5a729c84e6 100644 --- a/packages/astro/e2e/fixtures/react19-preact-hook-error/package.json +++ b/packages/astro/e2e/fixtures/react19-preact-hook-error/package.json @@ -8,7 +8,7 @@ "astro": "workspace:*" }, "dependencies": { - "preact": "^10.28.3", + "preact": "^10.28.4", "react": "^19.2.4", "react-dom": "^19.2.4" } diff --git a/packages/astro/e2e/fixtures/svelte-component/package.json b/packages/astro/e2e/fixtures/svelte-component/package.json index 17fe94c9dca3..158bb742bc97 100644 --- a/packages/astro/e2e/fixtures/svelte-component/package.json +++ b/packages/astro/e2e/fixtures/svelte-component/package.json @@ -6,6 +6,6 @@ "@astrojs/mdx": "workspace:*", "@astrojs/svelte": "workspace:*", "astro": "workspace:*", - "svelte": "^5.51.5" + "svelte": "^5.53.1" } } diff --git a/packages/astro/e2e/fixtures/tailwindcss/package.json b/packages/astro/e2e/fixtures/tailwindcss/package.json index bdd3f0ecef12..707debea57ad 100644 --- a/packages/astro/e2e/fixtures/tailwindcss/package.json +++ b/packages/astro/e2e/fixtures/tailwindcss/package.json @@ -3,8 +3,8 @@ "version": "0.0.0", "private": true, "dependencies": { - "@tailwindcss/vite": "^4.1.18", + "@tailwindcss/vite": "^4.2.0", "astro": "workspace:*", - "tailwindcss": "^4.1.18" + "tailwindcss": "^4.2.0" } } diff --git a/packages/astro/e2e/fixtures/view-transitions/package.json b/packages/astro/e2e/fixtures/view-transitions/package.json index d1643a15ba71..81ecf850d5cb 100644 --- a/packages/astro/e2e/fixtures/view-transitions/package.json +++ b/packages/astro/e2e/fixtures/view-transitions/package.json @@ -12,7 +12,7 @@ "react": "^18.3.1", "react-dom": "^18.3.1", "solid-js": "^1.9.11", - "svelte": "^5.51.5", + "svelte": "^5.53.1", "vue": "^3.5.28" } } diff --git a/packages/astro/package.json b/packages/astro/package.json index 3d8945f7d2cc..ae4fea6eb1df 100644 --- a/packages/astro/package.json +++ b/packages/astro/package.json @@ -116,7 +116,7 @@ "test:integration": "astro-scripts test \"test/*.test.js\"" }, "dependencies": { - "@astrojs/compiler": "^3.0.0-beta.0", + "@astrojs/compiler": "^3.0.0-beta.1", "@astrojs/internal-helpers": "workspace:*", "@astrojs/markdown-remark": "workspace:*", "@astrojs/telemetry": "workspace:*", @@ -131,7 +131,6 @@ "common-ancestor-path": "^2.0.0", "cookie": "^1.1.1", "cssesc": "^3.0.0", - "deterministic-object-hash": "^2.0.2", "devalue": "^5.6.3", "diff": "^8.0.3", "dlv": "^1.1.3", @@ -203,10 +202,10 @@ "rehype-slug": "^6.0.0", "rehype-toc": "^3.0.2", "remark-code-titles": "^0.1.2", - "rollup": "^4.57.1", + "rollup": "^4.58.0", "sass": "^1.97.3", "typescript": "^5.9.3", - "undici": "^7.21.0", + "undici": "^7.22.0", "unified": "^11.0.5", "vitest": "^3.2.4" }, diff --git a/packages/astro/src/assets/build/generate.ts b/packages/astro/src/assets/build/generate.ts index a7e798057f3f..c275aa50ec4a 100644 --- a/packages/astro/src/assets/build/generate.ts +++ b/packages/astro/src/assets/build/generate.ts @@ -1,8 +1,8 @@ import fs, { readFileSync } from 'node:fs'; import { basename } from 'node:path/posix'; import colors from 'piccolore'; -import type { BuildApp } from '../../core/build/app.js'; import { getOutDirWithinCwd } from '../../core/build/common.js'; +import type { StaticBuildOptions } from '../../core/build/types.js'; import { getTimeStat } from '../../core/build/util.js'; import { AstroError } from '../../core/errors/errors.js'; import { AstroErrorData } from '../../core/errors/index.js'; @@ -50,14 +50,12 @@ type ImageData = { }; export async function prepareAssetsGenerationEnv( - app: BuildApp, + options: StaticBuildOptions, totalCount: number, ): Promise { - const settings = app.getSettings(); - const logger = app.logger; - const manifest = app.getManifest(); + const { settings, logger } = options; let useCache = true; - const assetsCacheDir = new URL('assets/', app.manifest.cacheDir); + const assetsCacheDir = new URL('assets/', settings.config.cacheDir); const count = { total: totalCount, current: 1 }; // Ensure that the cache directory exists @@ -75,11 +73,11 @@ export async function prepareAssetsGenerationEnv( let serverRoot: URL, clientRoot: URL; if (isServerOutput) { // Images are collected during prerender, which outputs to .prerender/ subdirectory - serverRoot = new URL('.prerender/', manifest.buildServerDir); - clientRoot = manifest.buildClientDir; + serverRoot = new URL('.prerender/', settings.config.build.server); + clientRoot = settings.config.build.client; } else { - serverRoot = getOutDirWithinCwd(manifest.outDir); - clientRoot = manifest.outDir; + serverRoot = getOutDirWithinCwd(settings.config.outDir); + clientRoot = settings.config.outDir; } return { @@ -91,7 +89,7 @@ export async function prepareAssetsGenerationEnv( serverRoot, clientRoot, imageConfig: settings.config.image, - assetsFolder: manifest.assetsDir, + assetsFolder: settings.config.build.assets, }; } diff --git a/packages/astro/src/assets/endpoint/dev.ts b/packages/astro/src/assets/endpoint/dev.ts index c13dddd74b51..bbc466ee3514 100644 --- a/packages/astro/src/assets/endpoint/dev.ts +++ b/packages/astro/src/assets/endpoint/dev.ts @@ -1,8 +1,7 @@ // @ts-expect-error -import { safeModulePaths, viteFSConfig } from 'astro:assets'; +import { fsDenyGlob, safeModulePaths, viteFSConfig } from 'astro:assets'; import { readFile } from 'node:fs/promises'; import os from 'node:os'; -import picomatch from 'picomatch'; import { type AnymatchFn, isFileLoadingAllowed, type ResolvedConfig } from 'vite'; import type { APIRoute } from '../../types/public/common.js'; import { handleImageRequest, loadRemoteImage } from './shared.js'; @@ -21,24 +20,12 @@ async function loadLocalImage(src: string, url: URL) { } // Vite only uses the fs config, but the types ask for the full config - // fsDenyGlob's implementation is internal from https://github.com/vitejs/vite/blob/e6156f71f0e21f4068941b63bcc17b0e9b0a7455/packages/vite/src/node/config.ts#L1931 + if ( fsPath && isFileLoadingAllowed( { - fsDenyGlob: picomatch( - // matchBase: true does not work as it's documented - // https://github.com/micromatch/picomatch/issues/89 - // convert patterns without `/` on our side for now - viteFSConfig.deny.map((pattern: string) => - pattern.includes('/') ? pattern : `**/${pattern}`, - ), - { - matchBase: false, - nocase: true, - dot: true, - }, - ), + fsDenyGlob, server: { fs: viteFSConfig }, safeModulePaths, } as unknown as ResolvedConfig & { fsDenyGlob: AnymatchFn; safeModulePaths: Set }, diff --git a/packages/astro/src/assets/index.ts b/packages/astro/src/assets/index.ts index 6273c9cdc033..ae8cf46316ba 100644 --- a/packages/astro/src/assets/index.ts +++ b/packages/astro/src/assets/index.ts @@ -1,3 +1,4 @@ export { getConfiguredImageService, getImage } from './internal.js'; export { baseService, isLocalService } from './services/service.js'; +export { hashTransform, propsToFilename } from './utils/hash.js'; export type { LocalImageProps, RemoteImageProps } from './types.js'; diff --git a/packages/astro/src/assets/utils/deterministic-string.ts b/packages/astro/src/assets/utils/deterministic-string.ts new file mode 100644 index 000000000000..39043bb2a3c2 --- /dev/null +++ b/packages/astro/src/assets/utils/deterministic-string.ts @@ -0,0 +1,149 @@ +/** + * Vendored from deterministic-object-hash@2.0.2 (MIT) + * https://github.com/nicholasgasior/deterministic-object-hash + * + * Only `deterministicString` is needed - the async `deterministicHash` (which + * pulls in `node:crypto`) is intentionally excluded so this module stays + * runtime-agnostic (works in Node, workerd, browsers, etc.). + */ + +const objConstructorString = Function.prototype.toString.call(Object); + +function isPlainObject(value: unknown): value is Record { + if ( + typeof value !== 'object' || + value === null || + Object.prototype.toString.call(value) !== '[object Object]' + ) { + return false; + } + const proto = Object.getPrototypeOf(value); + if (proto === null) { + return true; + } + if (!Object.prototype.hasOwnProperty.call(proto, 'constructor')) { + return false; + } + return ( + typeof proto.constructor === 'function' && + proto.constructor instanceof proto.constructor && + Function.prototype.toString.call(proto.constructor) === objConstructorString + ); +} + +/** Recursively serializes any JS value into a deterministic string. */ +export function deterministicString(input: unknown): string { + if (typeof input === 'string') { + return JSON.stringify(input); + } else if (typeof input === 'symbol' || typeof input === 'function') { + return input.toString(); + } else if (typeof input === 'bigint') { + return `${input}n`; + } else if ( + input === globalThis || + input === undefined || + input === null || + typeof input === 'boolean' || + typeof input === 'number' || + typeof input !== 'object' + ) { + return `${input}`; + } else if (input instanceof Date) { + return `(${input.constructor.name}:${input.getTime()})`; + } else if ( + input instanceof RegExp || + input instanceof Error || + input instanceof WeakMap || + input instanceof WeakSet + ) { + return `(${input.constructor.name}:${input.toString()})`; + } else if (input instanceof Set) { + let ret = `(${input.constructor.name}:[`; + for (const val of input.values()) { + ret += `${deterministicString(val)},`; + } + ret += '])'; + return ret; + } else if ( + Array.isArray(input) || + input instanceof Int8Array || + input instanceof Uint8Array || + input instanceof Uint8ClampedArray || + input instanceof Int16Array || + input instanceof Uint16Array || + input instanceof Int32Array || + input instanceof Uint32Array || + input instanceof Float32Array || + input instanceof Float64Array || + input instanceof BigInt64Array || + input instanceof BigUint64Array + ) { + let ret = `(${input.constructor.name}:[`; + for (const [k, v] of input.entries()) { + ret += `(${k}:${deterministicString(v)}),`; + } + ret += '])'; + return ret; + } else if (input instanceof ArrayBuffer || input instanceof SharedArrayBuffer) { + if (input.byteLength % 8 === 0) { + return deterministicString(new BigUint64Array(input)); + } else if (input.byteLength % 4 === 0) { + return deterministicString(new Uint32Array(input)); + } else if (input.byteLength % 2 === 0) { + return deterministicString(new Uint16Array(input)); + } else { + let ret = '('; + for (let i = 0; i < input.byteLength; i++) { + ret += `${deterministicString(new Uint8Array(input.slice(i, i + 1)))},`; + } + ret += ')'; + return ret; + } + } else if (input instanceof Map || isPlainObject(input)) { + const sortable: [string, string][] = []; + const entries = input instanceof Map ? input.entries() : Object.entries(input); + for (const [k, v] of entries) { + sortable.push([deterministicString(k), deterministicString(v)]); + } + if (!(input instanceof Map)) { + const symbolKeys = Object.getOwnPropertySymbols(input); + // eslint-disable-next-line @typescript-eslint/prefer-for-of + for (let i = 0; i < symbolKeys.length; i++) { + sortable.push([ + deterministicString(symbolKeys[i]!), + deterministicString((input as Record)[symbolKeys[i]!]), + ]); + } + } + sortable.sort(([a], [b]) => a.localeCompare(b)); + let ret = `(${input.constructor.name}:[`; + for (const [k, v] of sortable) { + ret += `(${k}:${v}),`; + } + ret += '])'; + return ret; + } + + const allEntries: [string, string][] = []; + for (const k in input) { + allEntries.push([ + deterministicString(k), + deterministicString((input as Record)[k]), + ]); + } + const symbolKeys = Object.getOwnPropertySymbols(input); + // eslint-disable-next-line @typescript-eslint/prefer-for-of + for (let i = 0; i < symbolKeys.length; i++) { + allEntries.push([ + deterministicString(symbolKeys[i]!), + deterministicString((input as Record)[symbolKeys[i]!]), + ]); + } + allEntries.sort(([a], [b]) => a.localeCompare(b)); + let ret = `(${input.constructor.name}:[`; + for (const [k, v] of allEntries) { + ret += `(${k}:${v}),`; + } + ret += '])'; + return ret; +} diff --git a/packages/astro/src/assets/utils/hash.ts b/packages/astro/src/assets/utils/hash.ts new file mode 100644 index 000000000000..63f5dc27f015 --- /dev/null +++ b/packages/astro/src/assets/utils/hash.ts @@ -0,0 +1,75 @@ +import { deterministicString } from './deterministic-string.js'; +import { removeQueryString } from '@astrojs/internal-helpers/path'; +import { shorthash } from '../../runtime/server/shorthash.js'; +import type { ImageTransform } from '../types.js'; +import { isESMImportedImage } from './imageKind.js'; + +// Taken from https://github.com/rollup/rollup/blob/a8647dac0fe46c86183be8596ef7de25bc5b4e4b/src/utils/sanitizeFileName.ts +// eslint-disable-next-line no-control-regex +const INVALID_CHAR_REGEX = /[\u0000-\u001F"#$%&*+,:;<=>?[\]^`{|}\u007F]/g; + +/** Pure-string replacement for `path.posix.basename` (no node: import). */ +function basename(filePath: string, ext?: string): string { + let end = filePath.length; + while (end > 0 && filePath[end - 1] === '/') end--; + const stripped = filePath.slice(0, end); + + const lastSlash = stripped.lastIndexOf('/'); + const base = lastSlash === -1 ? stripped : stripped.slice(lastSlash + 1); + + if (ext && base.endsWith(ext)) { + return base.slice(0, base.length - ext.length); + } + return base; +} + +/** Pure-string replacement for `path.posix.dirname` (no node: import). */ +function dirname(filePath: string): string { + const lastSlash = filePath.lastIndexOf('/'); + if (lastSlash === -1) return '.'; + if (lastSlash === 0) return '/'; + return filePath.slice(0, lastSlash); +} + +/** Pure-string replacement for `path.posix.extname` (no node: import). */ +function extname(filePath: string): string { + const base = basename(filePath); + const dotIndex = base.lastIndexOf('.'); + if (dotIndex <= 0) return ''; + return base.slice(dotIndex); +} + +/** + * Converts a file path and transformation properties into a formatted filename. + * + * `/_` + */ +export function propsToFilename(filePath: string, transform: ImageTransform, hash: string): string { + let filename = decodeURIComponent(removeQueryString(filePath)); + const ext = extname(filename); + if (filePath.startsWith('data:')) { + filename = shorthash(filePath); + } else { + filename = basename(filename, ext).replace(INVALID_CHAR_REGEX, '_'); + } + const prefixDirname = isESMImportedImage(transform.src) ? dirname(filePath) : ''; + + let outputExt = transform.format ? `.${transform.format}` : ext; + return `${prefixDirname}/${filename}_${hash}${outputExt}`; +} + +/** Hashes the subset of transform properties that affect the output image. */ +export function hashTransform( + transform: ImageTransform, + imageService: string, + propertiesToHash: string[], +): string { + const hashFields = propertiesToHash.reduce( + (acc, prop) => { + acc[prop] = transform[prop]; + return acc; + }, + { imageService } as Record, + ); + return shorthash(deterministicString(hashFields)); +} diff --git a/packages/astro/src/assets/utils/node.ts b/packages/astro/src/assets/utils/node.ts index a95bf20daa2b..4b27a83ea148 100644 --- a/packages/astro/src/assets/utils/node.ts +++ b/packages/astro/src/assets/utils/node.ts @@ -1,15 +1,14 @@ import fs from 'node:fs/promises'; -import path, { basename, dirname, extname } from 'node:path'; +import path from 'node:path'; import { fileURLToPath, pathToFileURL } from 'node:url'; -import { deterministicString } from 'deterministic-object-hash'; import type * as vite from 'vite'; import { generateContentHash } from '../../core/encryption.js'; -import { prependForwardSlash, removeQueryString, slash } from '../../core/path.js'; -import { shorthash } from '../../runtime/server/shorthash.js'; -import type { ImageMetadata, ImageTransform } from '../types.js'; -import { isESMImportedImage } from './imageKind.js'; +import { prependForwardSlash, slash } from '../../core/path.js'; +import type { ImageMetadata } from '../types.js'; import { imageMetadata } from './metadata.js'; +export { hashTransform, propsToFilename } from './hash.js'; + type FileEmitter = vite.Rollup.EmitFile; type ImageMetadataWithContents = ImageMetadata & { contents?: Buffer }; @@ -142,70 +141,3 @@ function fileURLToNormalizedPath(filePath: URL): string { // Uses `slash` instead of Vite's `normalizePath` to avoid CJS bundling issues. return slash(fileURLToPath(filePath) + filePath.search).replace(/\\/g, '/'); } - -// Taken from https://github.com/rollup/rollup/blob/a8647dac0fe46c86183be8596ef7de25bc5b4e4b/src/utils/sanitizeFileName.ts -// eslint-disable-next-line no-control-regex -const INVALID_CHAR_REGEX = /[\u0000-\u001F"#$%&*+,:;<=>?[\]^`{|}\u007F]/g; - -/** - * Converts a file path and transformation properties of the transformation image service, into a formatted filename. - * - * The formatted filename follows this structure: - * - * `/_` - * - * - `prefixDirname`: If the image is an ESM imported image, this is the directory name of the original file path; otherwise, it will be an empty string. - * - `baseFilename`: The base name of the file or a hashed short name if the file is a `data:` URI. - * - `hash`: A unique hash string generated to distinguish the transformed file. - * - `outputExtension`: The desired output file extension derived from the `transform.format` or the original file extension. - * - * ## Example - * - Input: `filePath = '/images/photo.jpg'`, `transform = { format: 'png', src: '/images/photo.jpg' }`, `hash = 'abcd1234'`. - * - Output: `/images/photo_abcd1234.png` - * - * @param {string} filePath - The original file path or data URI of the source image. - * @param {ImageTransform} transform - An object representing the transformation properties, including format and source. - * @param {string} hash - A unique hash used to differentiate the transformed file. - * @return {string} The generated filename based on the provided input, transformations, and hash. - */ - -export function propsToFilename(filePath: string, transform: ImageTransform, hash: string): string { - let filename = decodeURIComponent(removeQueryString(filePath)); - const ext = extname(filename); - if (filePath.startsWith('data:')) { - filename = shorthash(filePath); - } else { - filename = basename(filename, ext).replace(INVALID_CHAR_REGEX, '_'); - } - const prefixDirname = isESMImportedImage(transform.src) ? dirname(filePath) : ''; - - let outputExt = transform.format ? `.${transform.format}` : ext; - return `${prefixDirname}/${filename}_${hash}${outputExt}`; -} - -/** - * Transforms the provided `transform` object into a hash string based on selected properties - * and the specified `imageService`. - * - * @param {ImageTransform} transform - The transform object containing various image transformation properties. - * @param {string} imageService - The name of the image service related to the transform. - * @param {string[]} propertiesToHash - An array of property names from the `transform` object that should be used to generate the hash. - * @return {string} A hashed string created from the specified properties of the `transform` object and the image service. - */ -export function hashTransform( - transform: ImageTransform, - imageService: string, - propertiesToHash: string[], -): string { - // Extract the fields we want to hash - const hashFields = propertiesToHash.reduce( - (acc, prop) => { - // It's possible for `transform[prop]` here to be undefined, or null, but that's fine because it's still consistent - // between different transforms. (ex: every transform without a height will explicitly have a `height: undefined` property) - acc[prop] = transform[prop]; - return acc; - }, - { imageService } as Record, - ); - return shorthash(deterministicString(hashFields)); -} diff --git a/packages/astro/src/assets/vite-plugin-assets.ts b/packages/astro/src/assets/vite-plugin-assets.ts index 540d491335fd..14d329900d0a 100644 --- a/packages/astro/src/assets/vite-plugin-assets.ts +++ b/packages/astro/src/assets/vite-plugin-assets.ts @@ -1,6 +1,7 @@ import type * as fsMod from 'node:fs'; import { extname } from 'node:path'; import MagicString from 'magic-string'; +import picomatch from 'picomatch'; import type * as vite from 'vite'; import { AstroError, AstroErrorData } from '../core/errors/index.js'; import type { Logger } from '../core/logger/core.js'; @@ -28,7 +29,8 @@ import type { ImageTransform } from './types.js'; import { getAssetsPrefix } from './utils/getAssetsPrefix.js'; import { isESMImportedImage } from './utils/index.js'; import { emitClientAsset } from './utils/assets.js'; -import { emitImageMetadata, hashTransform, propsToFilename } from './utils/node.js'; +import { hashTransform, propsToFilename } from './utils/hash.js'; +import { emitImageMetadata } from './utils/node.js'; import { getProxyCode } from './utils/proxy.js'; import { makeSvgComponent } from './utils/svg.js'; import { createPlaceholderURL, stringifyPlaceholderURL } from './utils/url.js'; @@ -177,6 +179,8 @@ export default function assets({ fs, settings, sync, logger }: Options): vite.Pl Array.from(resolvedConfig.safeModulePaths ?? []), )}); + export const fsDenyGlob = ${serializeFsDenyGlob(resolvedConfig.server.fs?.deny ?? [])}; + const assetQueryParams = ${ settings.adapter?.client?.assetQueryParams ? `new URLSearchParams(${JSON.stringify( @@ -349,3 +353,29 @@ export default function assets({ fs, settings, sync, logger }: Options): vite.Pl }, ]; } + +// Precompile the denies patterns to avoid using a CJS package in the runtime +function serializeFsDenyGlob(denyPatterns: string[]): string { + // Replicate the same pattern transformation that Vite does internally: + // https://github.com/vitejs/vite/blob/e6156f71f0e21f4068941b63bcc17b0e9b0a7455/packages/vite/src/node/config.ts#L1931 + const expandedPatterns = denyPatterns.map((pattern) => + pattern.includes('/') ? pattern : `**/${pattern}`, + ); + + const regexes = expandedPatterns.map((pattern) => + picomatch.makeRe(pattern, { + matchBase: false, + nocase: true, + dot: true, + }), + ); + + // Serialize the regexes as a function that tests a path against all patterns + const serializedRegexes = regexes.map((re) => re.toString()).join(', '); + return `(function() { + const regexes = [${serializedRegexes}]; + return function fsDenyGlob(testPath) { + return regexes.some(re => re.test(testPath)); + }; + })()`; +} diff --git a/packages/astro/src/cli/definitions.ts b/packages/astro/src/cli/definitions.ts index d20bf10e461c..76a78987db11 100644 --- a/packages/astro/src/cli/definitions.ts +++ b/packages/astro/src/cli/definitions.ts @@ -14,6 +14,7 @@ export interface TextStyler { green: (msg: string) => string; bold: (msg: string) => string; bgGreen: (msg: string) => string; + cyan: (msg: string) => string; } export interface AstroVersionProvider { diff --git a/packages/astro/src/cli/infra/passthrough-text-styler.ts b/packages/astro/src/cli/infra/passthrough-text-styler.ts index 6f4fa328c8c6..fb2ab51bfe61 100644 --- a/packages/astro/src/cli/infra/passthrough-text-styler.ts +++ b/packages/astro/src/cli/infra/passthrough-text-styler.ts @@ -19,4 +19,7 @@ export class PassthroughTextStyler implements TextStyler { bgGreen(msg: string): string { return msg; } + cyan(msg: string): string { + return msg; + } } diff --git a/packages/astro/src/core/build/generate.ts b/packages/astro/src/core/build/generate.ts index aee969cf4c5d..8e646446f2ca 100644 --- a/packages/astro/src/core/build/generate.ts +++ b/packages/astro/src/core/build/generate.ts @@ -29,7 +29,7 @@ import { routeIsRedirect } from '../routing/helpers.js'; import { matchRoute } from '../routing/match.js'; import { getOutputFilename } from '../util.js'; import { getOutFile, getOutFolder } from './common.js'; -import { createDefaultPrerenderer, type DefaultPrerenderer } from './default-prerenderer.js'; +import { createDefaultPrerenderer } from './default-prerenderer.js'; import { type BuildInternals, hasPrerenderedPages } from './internal.js'; import type { StaticBuildOptions } from './types.js'; import type { AstroSettings } from '../../types/astro.js'; @@ -182,6 +182,16 @@ export async function generatePages( } } + const staticImageList = getStaticImageList(); + + // Must happen before teardown since collectStaticImages fetches from the prerender server + if (prerenderer.collectStaticImages) { + const adapterImages = await prerenderer.collectStaticImages(); + for (const [path, entry] of adapterImages) { + staticImageList.set(path, entry); + } + } + // Teardown the prerenderer await prerenderer.teardown?.(); logger.info( @@ -189,17 +199,15 @@ export async function generatePages( colors.green(`✓ Completed in ${getTimeStat(generatePagesTimer, performance.now())}.\n`), ); - const staticImageList = getStaticImageList(); - // Get app from default prerenderer for assets generation (custom prerenderers handle assets differently) - const app = (prerenderer as DefaultPrerenderer).app; - if (staticImageList.size && app) { + // Default pipeline always runs + if (staticImageList.size) { logger.info('SKIP_FORMAT', `${colors.bgGreen(colors.black(` generating optimized images `))}`); const totalCount = Array.from(staticImageList.values()) .map((x) => x.transforms.size) .reduce((a, b) => a + b, 0); const cpuCount = os.cpus().length; - const assetsCreationPipeline = await prepareAssetsGenerationEnv(app, totalCount); + const assetsCreationPipeline = await prepareAssetsGenerationEnv(options, totalCount); const queue = new PQueue({ concurrency: Math.max(cpuCount, 1) }); const assetsTimer = performance.now(); diff --git a/packages/astro/src/core/dev/dev.ts b/packages/astro/src/core/dev/dev.ts index fa3bbd8f6624..9e11aa70c04f 100644 --- a/packages/astro/src/core/dev/dev.ts +++ b/packages/astro/src/core/dev/dev.ts @@ -21,6 +21,8 @@ import { MAX_PATCH_DISTANCE, shouldCheckForUpdates, } from './update-check.js'; +import { BuildTimeAstroVersionProvider } from '../../cli/infra/build-time-astro-version-provider.js'; +import { piccoloreTextStyler } from '../../cli/infra/piccolore-text-styler.js'; export interface DevServer { address: AddressInfo; @@ -125,6 +127,8 @@ export default async function dev(inlineConfig: AstroInlineConfig): Promise { - return `${i === 0 ? localPrefix : emptyPrefix}${cyan(new URL(url).origin + base)}`; + return `${i === 0 ? localPrefix : emptyPrefix}${textStyler.cyan(new URL(url).origin + base)}`; }); const networkUrlMessages = resolvedUrls.network.map((url, i) => { - return `${i === 0 ? networkPrefix : emptyPrefix}${cyan(new URL(url).origin + base)}`; + return `${i === 0 ? networkPrefix : emptyPrefix}${textStyler.cyan(new URL(url).origin + base)}`; }); if (networkUrlMessages.length === 0) { const networkLogging = getNetworkLogging(host); if (networkLogging === 'host-to-expose') { - networkUrlMessages.push(`${networkPrefix}${dim('use --host to expose')}`); + networkUrlMessages.push(`${networkPrefix}${textStyler.dim('use --host to expose')}`); } else if (networkLogging === 'visible') { - networkUrlMessages.push(`${networkPrefix}${dim('unable to find network to expose')}`); + networkUrlMessages.push( + `${networkPrefix}${textStyler.dim('unable to find network to expose')}`, + ); } } const messages = [ '', - `${bgGreen(bold(` astro `))} ${green(`v${version}`)} ${dim(`ready in`)} ${Math.round( + `${textStyler.bgGreen(textStyler.bold(` astro `))} ${textStyler.green(`v${astroVersionProvider.version}`)} ${textStyler.dim(`ready in`)} ${Math.round( startupTime, - )} ${dim('ms')}`, + )} ${textStyler.dim('ms')}`, '', ...localUrlMessages, ...networkUrlMessages, '', ]; - return messages.filter((msg) => typeof msg === 'string').join('\n'); + return messages.filter(Boolean).join('\n'); } /** Display custom dev server shortcuts */ diff --git a/packages/astro/src/core/preview/static-preview-server.ts b/packages/astro/src/core/preview/static-preview-server.ts index 04cd1a4a6eac..5e5cce1e4665 100644 --- a/packages/astro/src/core/preview/static-preview-server.ts +++ b/packages/astro/src/core/preview/static-preview-server.ts @@ -8,6 +8,8 @@ import type { Logger } from '../logger/core.js'; import * as msg from '../messages/runtime.js'; import { getResolvedHostForHttpServer } from './util.js'; import { vitePluginAstroPreview } from './vite-plugin-astro-preview.js'; +import { BuildTimeAstroVersionProvider } from '../../cli/infra/build-time-astro-version-provider.js'; +import { piccoloreTextStyler } from '../../cli/infra/piccolore-text-styler.js'; interface PreviewServer { host?: string; @@ -71,6 +73,8 @@ export default async function createStaticPreviewServer( resolvedUrls: previewServer.resolvedUrls ?? { local: [], network: [] }, host: settings.config.server.host, base: settings.config.base, + astroVersionProvider: new BuildTimeAstroVersionProvider(), + textStyler: piccoloreTextStyler, }), ); diff --git a/packages/astro/src/types/public/index.ts b/packages/astro/src/types/public/index.ts index b7fb70bba249..59bd635408be 100644 --- a/packages/astro/src/types/public/index.ts +++ b/packages/astro/src/types/public/index.ts @@ -11,6 +11,7 @@ export type { LocalImageService, } from '../../assets/services/service.js'; export type { + AssetsGlobalStaticImagesList, GetImageResult, ImageInputFormat, ImageMetadata, diff --git a/packages/astro/src/types/public/integrations.ts b/packages/astro/src/types/public/integrations.ts index 994fa7699257..eb428f6465e4 100644 --- a/packages/astro/src/types/public/integrations.ts +++ b/packages/astro/src/types/public/integrations.ts @@ -1,6 +1,7 @@ import type { AddressInfo } from 'node:net'; import type { ViteDevServer, InlineConfig as ViteInlineConfig } from 'vite'; import type { SerializedSSRManifest } from '../../core/app/types.js'; +import type { AssetsGlobalStaticImagesList } from '../../assets/types.js'; import type { PageBuildData } from '../../core/build/types.js'; import type { AstroIntegrationLogger } from '../../core/logger/core.js'; import type { AdapterFeatureStability } from '../../integrations/features-validation.js'; @@ -239,6 +240,11 @@ export interface AstroPrerenderer { * @param options - Render options including routeData */ render: (request: Request, options: { routeData: RouteData }) => Promise; + /** + * Returns images collected in the adapter's runtime (e.g. workerd) to be merged + * into the Node-side static image list. The default Sharp pipeline runs after. + */ + collectStaticImages?: () => Promise; /** * Called after all pages are prerendered. Use for cleanup like stopping a preview server. */ diff --git a/packages/astro/test/cli.test.js b/packages/astro/test/cli.test.js index bd80eb735c75..8eba27374681 100644 --- a/packages/astro/test/cli.test.js +++ b/packages/astro/test/cli.test.js @@ -1,19 +1,13 @@ import assert from 'node:assert/strict'; import { promises as fs, readFileSync } from 'node:fs'; -import { isIPv4 } from 'node:net'; import { join } from 'node:path'; import { Writable } from 'node:stream'; import { describe, it } from 'node:test'; import { fileURLToPath } from 'node:url'; import { stripVTControlCharacters } from 'node:util'; -import { cli, cliServerLogSetup, loadFixture, parseCliDevStart } from './test-utils.js'; +import { cli, loadFixture } from './test-utils.js'; describe('astro cli', () => { - const cliServerLogSetupWithFixture = (flags, cmd) => { - const projectRootURL = new URL('./fixtures/astro-basic/', import.meta.url); - return cliServerLogSetup(['--root', fileURLToPath(projectRootURL), ...flags], cmd); - }; - it('astro', async () => { const result = await cli().getResult(); assert.equal(result.exitCode, 0); @@ -85,7 +79,12 @@ describe('astro cli', () => { }, async () => { const projectRootURL = new URL('./fixtures/astro-check-no-errors/', import.meta.url); - const result = await cli('check', '--root', fileURLToPath(projectRootURL)).getResult(); + const result = await cli( + 'check', + '--root', + fileURLToPath(projectRootURL), + '--noSync', + ).getResult(); assert.equal(result.stdout.includes('0 errors'), true); }, @@ -98,97 +97,14 @@ describe('astro cli', () => { }, async () => { const projectRootURL = new URL('./fixtures/astro-check-errors/', import.meta.url); - const result = await cli('check', '--root', fileURLToPath(projectRootURL)).getResult(); + const result = await cli( + 'check', + '--root', + fileURLToPath(projectRootURL), + '--noSync', + ).getResult(); assert.equal(result.stdout.includes('1 error'), true); }, ); - - it('astro dev welcome', async () => { - const pkgURL = new URL('../package.json', import.meta.url); - const pkgVersion = await fs.readFile(pkgURL, 'utf8').then((data) => JSON.parse(data).version); - - const projectRootURL = new URL('./fixtures/astro-basic/', import.meta.url); - const { proc } = cli('dev', '--root', fileURLToPath(projectRootURL)); - const { messages } = await parseCliDevStart(proc); - - const message = messages.join('\n'); - - assert.equal(message.includes('astro'), true); - assert.equal(message.includes(pkgVersion), true); - assert.equal(message.includes('ready in'), true); - }); - - ['dev', 'preview'].forEach((cmd) => { - const networkLogFlags = [['--host'], ['--host', '0.0.0.0']]; - networkLogFlags.forEach(([flag, flagValue]) => { - it(`astro ${cmd} ${flag} ${flagValue ?? ''} - network log`, async () => { - const { local, network } = await cliServerLogSetupWithFixture( - flagValue ? [flag, flagValue] : [flag], - cmd, - ); - - assert.notEqual(local, undefined); - assert.notEqual(network, undefined); - - const localURL = new URL(local); - const networkURL = new URL(network); - - assert.equal(['localhost', '127.0.0.1'].includes(localURL.hostname), true), - `Expected local URL to be on localhost`; - - // Note: our tests run in parallel so this could be 3000+! - assert.equal(Number.parseInt(localURL.port) >= 4321, true, `Expected Port to be >= 4321`); - assert.equal( - networkURL.port, - localURL.port, - `Expected local and network ports to be equal`, - ); - assert.equal( - isIPv4(networkURL.hostname), - true, - `Expected network URL to respect --host flag`, - ); - }); - }); - - const hostToExposeFlags = [['', '']]; - hostToExposeFlags.forEach(([flag, flagValue]) => { - it(`astro ${cmd} ${flag} ${flagValue} - host to expose`, async () => { - const { local, network } = await cliServerLogSetupWithFixture([flag, flagValue], cmd); - - assert.notEqual(local, undefined); - assert.notEqual(network, undefined); - const localURL = new URL(local); - - assert.equal( - ['localhost', '127.0.0.1'].includes(localURL.hostname), - true, - `Expected local URL to be on localhost`, - ); - - assert.throws(() => new URL(networkURL)); - }); - }); - - const noNetworkLogFlags = [ - ['--host', 'localhost'], - ['--host', '127.0.0.1'], - ]; - noNetworkLogFlags.forEach(([flag, flagValue]) => { - it(`astro ${cmd} ${flag} ${flagValue} - no network log`, async () => { - const { local, network } = await cliServerLogSetupWithFixture([flag, flagValue], cmd); - - assert.notEqual(local, undefined); - assert.equal(network, undefined); - - const localURL = new URL(local); - assert.equal( - ['localhost', '127.0.0.1'].includes(localURL.hostname), - true, - `Expected local URL to be on localhost`, - ); - }); - }); - }); }); diff --git a/packages/astro/test/fixtures/0-css/package.json b/packages/astro/test/fixtures/0-css/package.json index 9d6cf2319f37..183f47fe8283 100644 --- a/packages/astro/test/fixtures/0-css/package.json +++ b/packages/astro/test/fixtures/0-css/package.json @@ -9,7 +9,7 @@ "astro": "workspace:*", "react": "^18.3.1", "react-dom": "^18.3.1", - "svelte": "^5.51.5", + "svelte": "^5.53.1", "vue": "^3.5.28" } } diff --git a/packages/astro/test/fixtures/alias-tsconfig-baseurl-only/package.json b/packages/astro/test/fixtures/alias-tsconfig-baseurl-only/package.json index 4b99e162b469..407f8c5138ac 100644 --- a/packages/astro/test/fixtures/alias-tsconfig-baseurl-only/package.json +++ b/packages/astro/test/fixtures/alias-tsconfig-baseurl-only/package.json @@ -5,6 +5,6 @@ "dependencies": { "@astrojs/svelte": "workspace:*", "astro": "workspace:*", - "svelte": "^5.51.5" + "svelte": "^5.53.1" } } diff --git a/packages/astro/test/fixtures/alias-tsconfig/package.json b/packages/astro/test/fixtures/alias-tsconfig/package.json index 0600019cdb29..2cb4270c012c 100644 --- a/packages/astro/test/fixtures/alias-tsconfig/package.json +++ b/packages/astro/test/fixtures/alias-tsconfig/package.json @@ -6,6 +6,6 @@ "@astrojs/svelte": "workspace:*", "@test/namespace-package": "workspace:*", "astro": "workspace:*", - "svelte": "^5.51.5" + "svelte": "^5.53.1" } } diff --git a/packages/astro/test/fixtures/alias/package.json b/packages/astro/test/fixtures/alias/package.json index 6db7f0afb555..9be9f4ae16d2 100644 --- a/packages/astro/test/fixtures/alias/package.json +++ b/packages/astro/test/fixtures/alias/package.json @@ -5,6 +5,6 @@ "dependencies": { "@astrojs/svelte": "workspace:*", "astro": "workspace:*", - "svelte": "^5.51.5" + "svelte": "^5.53.1" } } diff --git a/packages/astro/test/fixtures/astro-basic/package.json b/packages/astro/test/fixtures/astro-basic/package.json index 71356233e140..568028dce239 100644 --- a/packages/astro/test/fixtures/astro-basic/package.json +++ b/packages/astro/test/fixtures/astro-basic/package.json @@ -6,6 +6,6 @@ "@astrojs/mdx": "workspace:*", "@astrojs/preact": "workspace:*", "astro": "workspace:*", - "preact": "^10.28.3" + "preact": "^10.28.4" } } diff --git a/packages/astro/test/fixtures/astro-check-errors/astro.config.mjs b/packages/astro/test/fixtures/astro-check-errors/astro.config.mjs deleted file mode 100644 index db9a6db87e38..000000000000 --- a/packages/astro/test/fixtures/astro-check-errors/astro.config.mjs +++ /dev/null @@ -1,6 +0,0 @@ -import { defineConfig } from 'astro/config'; - -// https://astro.build/config -export default defineConfig({ - integrations: [], -}); diff --git a/packages/astro/test/fixtures/astro-check-errors/package.json b/packages/astro/test/fixtures/astro-check-errors/package.json index 5d47e7954a91..4f9bea71fd40 100644 --- a/packages/astro/test/fixtures/astro-check-errors/package.json +++ b/packages/astro/test/fixtures/astro-check-errors/package.json @@ -4,7 +4,7 @@ "private": true, "dependencies": { "astro": "workspace:*", - "@astrojs/check": "^0.9.6", + "@astrojs/check": "workspace:*", "typescript": "^5.9.3" } } diff --git a/packages/astro/test/fixtures/astro-check-errors/src/pages/index.astro b/packages/astro/test/fixtures/astro-check-errors/src/pages/index.astro index 4521e6f25bcc..19a6382503e7 100644 --- a/packages/astro/test/fixtures/astro-check-errors/src/pages/index.astro +++ b/packages/astro/test/fixtures/astro-check-errors/src/pages/index.astro @@ -1,15 +1,3 @@ --- console.log(doesntExist) --- - - - - - - - Document - - -
Hello, Astro!
- - diff --git a/packages/astro/test/fixtures/astro-check-no-errors/astro.config.mjs b/packages/astro/test/fixtures/astro-check-no-errors/astro.config.mjs deleted file mode 100644 index db9a6db87e38..000000000000 --- a/packages/astro/test/fixtures/astro-check-no-errors/astro.config.mjs +++ /dev/null @@ -1,6 +0,0 @@ -import { defineConfig } from 'astro/config'; - -// https://astro.build/config -export default defineConfig({ - integrations: [], -}); diff --git a/packages/astro/test/fixtures/astro-check-no-errors/package.json b/packages/astro/test/fixtures/astro-check-no-errors/package.json index a9bc682fde65..df6a4a9312ab 100644 --- a/packages/astro/test/fixtures/astro-check-no-errors/package.json +++ b/packages/astro/test/fixtures/astro-check-no-errors/package.json @@ -4,7 +4,7 @@ "private": true, "dependencies": { "astro": "workspace:*", - "@astrojs/check": "^0.9.6", + "@astrojs/check": "workspace:*", "typescript": "^5.9.3" } } diff --git a/packages/astro/test/fixtures/astro-check-no-errors/src/pages/index.astro b/packages/astro/test/fixtures/astro-check-no-errors/src/pages/index.astro index 49d10645690e..7bcb4ba3939d 100644 --- a/packages/astro/test/fixtures/astro-check-no-errors/src/pages/index.astro +++ b/packages/astro/test/fixtures/astro-check-no-errors/src/pages/index.astro @@ -1,11 +1,4 @@ - - - - - - Document - - -
Hello, Astro!
- - +--- +const foo = 'bar' +--- + diff --git a/packages/astro/test/fixtures/astro-children/package.json b/packages/astro/test/fixtures/astro-children/package.json index 7c0dff8dba68..2893c5c1bbbd 100644 --- a/packages/astro/test/fixtures/astro-children/package.json +++ b/packages/astro/test/fixtures/astro-children/package.json @@ -7,8 +7,8 @@ "@astrojs/svelte": "workspace:*", "@astrojs/vue": "workspace:*", "astro": "workspace:*", - "preact": "^10.28.3", - "svelte": "^5.51.5", + "preact": "^10.28.4", + "svelte": "^5.53.1", "vue": "^3.5.28" } } diff --git a/packages/astro/test/fixtures/astro-client-only/package.json b/packages/astro/test/fixtures/astro-client-only/package.json index 49022bd66008..aa053cc017db 100644 --- a/packages/astro/test/fixtures/astro-client-only/package.json +++ b/packages/astro/test/fixtures/astro-client-only/package.json @@ -9,6 +9,6 @@ "astro": "workspace:*", "react": "^18.3.1", "react-dom": "^18.3.1", - "svelte": "^5.51.5" + "svelte": "^5.53.1" } } diff --git a/packages/astro/test/fixtures/astro-dynamic/package.json b/packages/astro/test/fixtures/astro-dynamic/package.json index eeac27efe3bf..926f2e41a0f8 100644 --- a/packages/astro/test/fixtures/astro-dynamic/package.json +++ b/packages/astro/test/fixtures/astro-dynamic/package.json @@ -8,6 +8,6 @@ "astro": "workspace:*", "react": "^18.3.1", "react-dom": "^18.3.1", - "svelte": "^5.51.5" + "svelte": "^5.53.1" } } diff --git a/packages/astro/test/fixtures/astro-expr/package.json b/packages/astro/test/fixtures/astro-expr/package.json index 6f009d75a864..2a41c18fad48 100644 --- a/packages/astro/test/fixtures/astro-expr/package.json +++ b/packages/astro/test/fixtures/astro-expr/package.json @@ -5,6 +5,6 @@ "dependencies": { "@astrojs/preact": "workspace:*", "astro": "workspace:*", - "preact": "^10.28.3" + "preact": "^10.28.4" } } diff --git a/packages/astro/test/fixtures/astro-fallback/package.json b/packages/astro/test/fixtures/astro-fallback/package.json index 5ddce795f065..c3911fd0724d 100644 --- a/packages/astro/test/fixtures/astro-fallback/package.json +++ b/packages/astro/test/fixtures/astro-fallback/package.json @@ -5,6 +5,6 @@ "dependencies": { "@astrojs/preact": "workspace:*", "astro": "workspace:*", - "preact": "^10.28.3" + "preact": "^10.28.4" } } diff --git a/packages/astro/test/fixtures/astro-scripts/package.json b/packages/astro/test/fixtures/astro-scripts/package.json index eb1a66b09636..14c5bd34122e 100644 --- a/packages/astro/test/fixtures/astro-scripts/package.json +++ b/packages/astro/test/fixtures/astro-scripts/package.json @@ -4,7 +4,7 @@ "private": true, "dependencies": { "astro": "workspace:*", - "@tailwindcss/vite": "^4.1.18", - "tailwindcss": "^4.1.18" + "@tailwindcss/vite": "^4.2.0", + "tailwindcss": "^4.2.0" } } diff --git a/packages/astro/test/fixtures/astro-slot-with-client/package.json b/packages/astro/test/fixtures/astro-slot-with-client/package.json index 87647f1082ae..b37100ee2984 100644 --- a/packages/astro/test/fixtures/astro-slot-with-client/package.json +++ b/packages/astro/test/fixtures/astro-slot-with-client/package.json @@ -4,6 +4,6 @@ "dependencies": { "@astrojs/preact": "workspace:*", "astro": "workspace:*", - "preact": "^10.28.3" + "preact": "^10.28.4" } } diff --git a/packages/astro/test/fixtures/astro-slots-nested/package.json b/packages/astro/test/fixtures/astro-slots-nested/package.json index 5cc80a61928a..5e7066bde154 100644 --- a/packages/astro/test/fixtures/astro-slots-nested/package.json +++ b/packages/astro/test/fixtures/astro-slots-nested/package.json @@ -9,11 +9,11 @@ "@astrojs/svelte": "workspace:*", "@astrojs/vue": "workspace:*", "astro": "workspace:*", - "preact": "^10.28.3", + "preact": "^10.28.4", "react": "^18.3.1", "react-dom": "^18.3.1", "solid-js": "^1.9.11", - "svelte": "^5.51.5", + "svelte": "^5.53.1", "vue": "^3.5.28" } } diff --git a/packages/astro/test/fixtures/before-hydration/package.json b/packages/astro/test/fixtures/before-hydration/package.json index 97daa99acb03..a2b77530f467 100644 --- a/packages/astro/test/fixtures/before-hydration/package.json +++ b/packages/astro/test/fixtures/before-hydration/package.json @@ -4,6 +4,6 @@ "dependencies": { "@astrojs/preact": "workspace:*", "astro": "workspace:*", - "preact": "^10.28.3" + "preact": "^10.28.4" } } diff --git a/packages/astro/test/fixtures/build-assets/package.json b/packages/astro/test/fixtures/build-assets/package.json index fb08d666b8e9..b7917267a1a5 100644 --- a/packages/astro/test/fixtures/build-assets/package.json +++ b/packages/astro/test/fixtures/build-assets/package.json @@ -4,6 +4,6 @@ "dependencies": { "@astrojs/preact": "workspace:*", "astro": "workspace:*", - "preact": "^10.28.3" + "preact": "^10.28.4" } } diff --git a/packages/astro/test/fixtures/component-library-shared/package.json b/packages/astro/test/fixtures/component-library-shared/package.json index 1dc3cff3bdc2..2ea3abf3c8ca 100644 --- a/packages/astro/test/fixtures/component-library-shared/package.json +++ b/packages/astro/test/fixtures/component-library-shared/package.json @@ -18,7 +18,7 @@ "astro": "workspace:*" }, "dependencies": { - "preact": "^10.28.3", + "preact": "^10.28.4", "react": "^18.3.1" } } diff --git a/packages/astro/test/fixtures/component-library/package.json b/packages/astro/test/fixtures/component-library/package.json index 741bffcb966a..f7b5c140a3a6 100644 --- a/packages/astro/test/fixtures/component-library/package.json +++ b/packages/astro/test/fixtures/component-library/package.json @@ -8,9 +8,9 @@ "@astrojs/svelte": "workspace:*", "@test/component-library-shared": "workspace:*", "astro": "workspace:*", - "preact": "^10.28.3", + "preact": "^10.28.4", "react": "^18.3.1", "react-dom": "^18.3.1", - "svelte": "^5.51.5" + "svelte": "^5.53.1" } } diff --git a/packages/astro/test/fixtures/content-layer-markdoc/package.json b/packages/astro/test/fixtures/content-layer-markdoc/package.json index e3b81efc319e..c2d06a3afe99 100644 --- a/packages/astro/test/fixtures/content-layer-markdoc/package.json +++ b/packages/astro/test/fixtures/content-layer-markdoc/package.json @@ -6,6 +6,6 @@ "@astrojs/markdoc": "workspace:*", "@astrojs/preact": "workspace:*", "astro": "workspace:*", - "preact": "^10.28.3" + "preact": "^10.28.4" } } \ No newline at end of file diff --git a/packages/astro/test/fixtures/css-dangling-references/package.json b/packages/astro/test/fixtures/css-dangling-references/package.json index 629a7832acfa..8209d60a709c 100644 --- a/packages/astro/test/fixtures/css-dangling-references/package.json +++ b/packages/astro/test/fixtures/css-dangling-references/package.json @@ -5,6 +5,6 @@ "dependencies": { "@astrojs/svelte": "workspace:*", "astro": "workspace:*", - "svelte": "^5.51.5" + "svelte": "^5.53.1" } } diff --git a/packages/astro/test/fixtures/entry-file-names/package.json b/packages/astro/test/fixtures/entry-file-names/package.json index 455b72492d9c..c1729e58d3d6 100644 --- a/packages/astro/test/fixtures/entry-file-names/package.json +++ b/packages/astro/test/fixtures/entry-file-names/package.json @@ -5,6 +5,6 @@ "dependencies": { "@astrojs/preact": "workspace:", "astro": "workspace:*", - "preact": "^10.28.3" + "preact": "^10.28.4" } } diff --git a/packages/astro/test/fixtures/fetch/package.json b/packages/astro/test/fixtures/fetch/package.json index 73bd5e056478..ca44c01c501b 100644 --- a/packages/astro/test/fixtures/fetch/package.json +++ b/packages/astro/test/fixtures/fetch/package.json @@ -7,8 +7,8 @@ "@astrojs/svelte": "workspace:*", "@astrojs/vue": "workspace:*", "astro": "workspace:*", - "preact": "^10.28.3", - "svelte": "^5.51.5", + "preact": "^10.28.4", + "svelte": "^5.53.1", "vue": "^3.5.28" } } diff --git a/packages/astro/test/fixtures/hydration-race/package.json b/packages/astro/test/fixtures/hydration-race/package.json index 77d74e6fafd8..a96dcb18b780 100644 --- a/packages/astro/test/fixtures/hydration-race/package.json +++ b/packages/astro/test/fixtures/hydration-race/package.json @@ -9,6 +9,6 @@ "dependencies": { "@astrojs/preact": "workspace:*", "astro": "workspace:*", - "preact": "^10.28.3" + "preact": "^10.28.4" } } diff --git a/packages/astro/test/fixtures/jsx/package.json b/packages/astro/test/fixtures/jsx/package.json index 224c508f53ae..f9631580e186 100644 --- a/packages/astro/test/fixtures/jsx/package.json +++ b/packages/astro/test/fixtures/jsx/package.json @@ -12,11 +12,11 @@ "astro": "workspace:*" }, "dependencies": { - "preact": "^10.28.3", + "preact": "^10.28.4", "react": "^18.3.1", "react-dom": "^18.3.1", "solid-js": "^1.9.11", - "svelte": "^5.51.5", + "svelte": "^5.53.1", "vue": "^3.5.28" } } diff --git a/packages/astro/test/fixtures/middleware-tailwind/package.json b/packages/astro/test/fixtures/middleware-tailwind/package.json index 1a6686d97df7..6848a7b1d5c3 100644 --- a/packages/astro/test/fixtures/middleware-tailwind/package.json +++ b/packages/astro/test/fixtures/middleware-tailwind/package.json @@ -4,7 +4,7 @@ "private": true, "dependencies": { "astro": "workspace:*", - "@tailwindcss/vite": "^4.1.18", - "tailwindcss": "^4.1.18" + "@tailwindcss/vite": "^4.2.0", + "tailwindcss": "^4.2.0" } } diff --git a/packages/astro/test/fixtures/postcss/package.json b/packages/astro/test/fixtures/postcss/package.json index 753f201c8340..af1e26dc6b87 100644 --- a/packages/astro/test/fixtures/postcss/package.json +++ b/packages/astro/test/fixtures/postcss/package.json @@ -10,7 +10,7 @@ "autoprefixer": "^10.4.24", "postcss": "^8.5.6", "solid-js": "^1.9.11", - "svelte": "^5.51.5", + "svelte": "^5.53.1", "vue": "^3.5.28" }, "devDependencies": { diff --git a/packages/astro/test/fixtures/preact-compat-component/package.json b/packages/astro/test/fixtures/preact-compat-component/package.json index cd430d22362f..4d0ad3cc0e65 100644 --- a/packages/astro/test/fixtures/preact-compat-component/package.json +++ b/packages/astro/test/fixtures/preact-compat-component/package.json @@ -6,6 +6,6 @@ "@astrojs/preact": "workspace:*", "@test/react-lib": "workspace:*", "astro": "workspace:*", - "preact": "^10.28.3" + "preact": "^10.28.4" } } diff --git a/packages/astro/test/fixtures/preact-component/package.json b/packages/astro/test/fixtures/preact-component/package.json index 538fa60b0703..92a623c4f7df 100644 --- a/packages/astro/test/fixtures/preact-component/package.json +++ b/packages/astro/test/fixtures/preact-component/package.json @@ -4,8 +4,8 @@ "private": true, "dependencies": { "@astrojs/preact": "workspace:*", - "@preact/signals": "2.7.1", + "@preact/signals": "2.8.1", "astro": "workspace:*", - "preact": "^10.28.3" + "preact": "^10.28.4" } } diff --git a/packages/astro/test/fixtures/reexport-astro-containing-client-component/package.json b/packages/astro/test/fixtures/reexport-astro-containing-client-component/package.json index 5769b1155d1a..d4baf5efe4f3 100644 --- a/packages/astro/test/fixtures/reexport-astro-containing-client-component/package.json +++ b/packages/astro/test/fixtures/reexport-astro-containing-client-component/package.json @@ -4,6 +4,6 @@ "dependencies": { "@astrojs/preact": "workspace:", "astro": "workspace:", - "preact": "^10.28.3" + "preact": "^10.28.4" } } diff --git a/packages/astro/test/fixtures/server-islands/hybrid/package.json b/packages/astro/test/fixtures/server-islands/hybrid/package.json index f7cea6098c11..e1369cfc5ae9 100644 --- a/packages/astro/test/fixtures/server-islands/hybrid/package.json +++ b/packages/astro/test/fixtures/server-islands/hybrid/package.json @@ -5,6 +5,6 @@ "dependencies": { "@astrojs/svelte": "workspace:*", "astro": "workspace:*", - "svelte": "^5.51.5" + "svelte": "^5.53.1" } } diff --git a/packages/astro/test/fixtures/server-islands/ssr/package.json b/packages/astro/test/fixtures/server-islands/ssr/package.json index ae3f14d7fc09..f9b87f175403 100644 --- a/packages/astro/test/fixtures/server-islands/ssr/package.json +++ b/packages/astro/test/fixtures/server-islands/ssr/package.json @@ -6,6 +6,6 @@ "@astrojs/mdx": "workspace:*", "@astrojs/svelte": "workspace:*", "astro": "workspace:*", - "svelte": "^5.51.5" + "svelte": "^5.53.1" } } diff --git a/packages/astro/test/fixtures/slots-preact/package.json b/packages/astro/test/fixtures/slots-preact/package.json index 5cbbe79d1d10..c69b377656a9 100644 --- a/packages/astro/test/fixtures/slots-preact/package.json +++ b/packages/astro/test/fixtures/slots-preact/package.json @@ -6,6 +6,6 @@ "@astrojs/mdx": "workspace:*", "@astrojs/preact": "workspace:*", "astro": "workspace:*", - "preact": "^10.28.3" + "preact": "^10.28.4" } } diff --git a/packages/astro/test/fixtures/slots-svelte/package.json b/packages/astro/test/fixtures/slots-svelte/package.json index c775f2bf0208..2ad08bff100b 100644 --- a/packages/astro/test/fixtures/slots-svelte/package.json +++ b/packages/astro/test/fixtures/slots-svelte/package.json @@ -6,6 +6,6 @@ "@astrojs/mdx": "workspace:*", "@astrojs/svelte": "workspace:*", "astro": "workspace:*", - "svelte": "^5.51.5" + "svelte": "^5.53.1" } } diff --git a/packages/astro/test/fixtures/ssr-env/package.json b/packages/astro/test/fixtures/ssr-env/package.json index 66f4388414d8..3d1a7cda3f9c 100644 --- a/packages/astro/test/fixtures/ssr-env/package.json +++ b/packages/astro/test/fixtures/ssr-env/package.json @@ -5,6 +5,6 @@ "dependencies": { "@astrojs/preact": "workspace:*", "astro": "workspace:*", - "preact": "^10.28.3" + "preact": "^10.28.4" } } diff --git a/packages/astro/test/fixtures/ssr-renderers-static-vue/package.json b/packages/astro/test/fixtures/ssr-renderers-static-vue/package.json index 4d29461f5f02..f1fd904f034a 100644 --- a/packages/astro/test/fixtures/ssr-renderers-static-vue/package.json +++ b/packages/astro/test/fixtures/ssr-renderers-static-vue/package.json @@ -5,6 +5,6 @@ "dependencies": { "@astrojs/vue": "workspace:*", "astro": "workspace:*", - "vue": "^3.5.27" + "vue": "^3.5.28" } } diff --git a/packages/astro/test/fixtures/ssr-scripts/package.json b/packages/astro/test/fixtures/ssr-scripts/package.json index 8b594c44ac89..471f4335176d 100644 --- a/packages/astro/test/fixtures/ssr-scripts/package.json +++ b/packages/astro/test/fixtures/ssr-scripts/package.json @@ -5,6 +5,6 @@ "dependencies": { "@astrojs/preact": "workspace:", "astro": "workspace:*", - "preact": "^10.28.3" + "preact": "^10.28.4" } } diff --git a/packages/astro/test/fixtures/static-build-frameworks/package.json b/packages/astro/test/fixtures/static-build-frameworks/package.json index b14e6fa0e283..fe20003d63f1 100644 --- a/packages/astro/test/fixtures/static-build-frameworks/package.json +++ b/packages/astro/test/fixtures/static-build-frameworks/package.json @@ -6,7 +6,7 @@ "@astrojs/preact": "workspace:*", "@astrojs/react": "workspace:*", "astro": "workspace:*", - "preact": "^10.28.3", + "preact": "^10.28.4", "react": "^18.3.1", "react-dom": "^18.3.1" } diff --git a/packages/astro/test/fixtures/static-build/package.json b/packages/astro/test/fixtures/static-build/package.json index d241c581ee8a..eec01632f2d5 100644 --- a/packages/astro/test/fixtures/static-build/package.json +++ b/packages/astro/test/fixtures/static-build/package.json @@ -6,6 +6,6 @@ "@astrojs/preact": "workspace:*", "@test/static-build-pkg": "workspace:*", "astro": "workspace:*", - "preact": "^10.28.3" + "preact": "^10.28.4" } } diff --git a/packages/astro/test/fixtures/svelte-component/package.json b/packages/astro/test/fixtures/svelte-component/package.json index de9176ccd0b5..6a67a7fd5c48 100644 --- a/packages/astro/test/fixtures/svelte-component/package.json +++ b/packages/astro/test/fixtures/svelte-component/package.json @@ -5,6 +5,6 @@ "dependencies": { "@astrojs/svelte": "workspace:*", "astro": "workspace:*", - "svelte": "^5.51.5" + "svelte": "^5.53.1" } } diff --git a/packages/astro/test/fixtures/tailwindcss/package.json b/packages/astro/test/fixtures/tailwindcss/package.json index 891beaab97da..6deac91dd34e 100644 --- a/packages/astro/test/fixtures/tailwindcss/package.json +++ b/packages/astro/test/fixtures/tailwindcss/package.json @@ -4,8 +4,8 @@ "private": true, "dependencies": { "@astrojs/mdx": "workspace:*", - "@tailwindcss/vite": "^4.1.18", + "@tailwindcss/vite": "^4.2.0", "astro": "workspace:*", - "tailwindcss": "^4.1.18" + "tailwindcss": "^4.2.0" } } diff --git a/packages/astro/test/fixtures/vue-with-multi-renderer/package.json b/packages/astro/test/fixtures/vue-with-multi-renderer/package.json index 7551b580b3e5..5e63081e1315 100644 --- a/packages/astro/test/fixtures/vue-with-multi-renderer/package.json +++ b/packages/astro/test/fixtures/vue-with-multi-renderer/package.json @@ -6,7 +6,7 @@ "@astrojs/svelte": "workspace:*", "@astrojs/vue": "workspace:*", "astro": "workspace:*", - "svelte": "^5.51.5", + "svelte": "^5.53.1", "vue": "^3.5.28" } } diff --git a/packages/astro/test/fonts.test.js b/packages/astro/test/fonts.test.js index da03b4cf8b03..0f1598ad0f53 100644 --- a/packages/astro/test/fonts.test.js +++ b/packages/astro/test/fonts.test.js @@ -2,127 +2,58 @@ import assert from 'node:assert/strict'; import { existsSync } from 'node:fs'; import { readdir } from 'node:fs/promises'; -import { describe, it } from 'node:test'; +import { after, before, describe, it } from 'node:test'; import { fontProviders } from 'astro/config'; import * as cheerio from 'cheerio'; import testAdapter from './test-adapter.js'; import { loadFixture } from './test-utils.js'; -/** - * @param {Omit} inlineConfig - */ -async function createDevFixture(inlineConfig) { - const fixture = await loadFixture({ root: './fixtures/fonts/', ...inlineConfig }); - await fixture.clean(); - const devServer = await fixture.startDevServer(); - - return { - fixture, - devServer, - run: async (/** @type {() => any} */ cb) => { - try { - return await cb(); - } finally { - await devServer.stop(); - } - }, - }; -} - -/** - * @param {Omit} inlineConfig - */ -async function createBuildFixture(inlineConfig) { - const fixture = await loadFixture({ root: './fixtures/fonts/', ...inlineConfig }); - await fixture.build({}); - - return { - fixture, - }; -} - -/** - * @param {Omit} inlineConfig - */ -async function createSsrFixture(inlineConfig) { - const fixture = await loadFixture({ - root: './fixtures/fonts/', - output: 'server', - adapter: testAdapter(), - ...inlineConfig, - }); - await fixture.build({}); - const app = await fixture.loadTestAdapterApp(); - - return { - fixture, - app, - /** - * @param {string} url - */ - fetch: async (url) => { - const request = new Request(`http://example.com${url}`); - const response = await app.render(request); - const html = await response.text(); - return html; - }, - }; -} - describe('astro fonts', () => { + /** @type {import('./test-utils.js').Fixture} */ + let fixture; + describe('dev', () => { - it('Includes styles', async () => { - const { fixture, run } = await createDevFixture({ - fonts: [ - { - name: 'Poppins', - cssVariable: '--font-test', - provider: fontProviders.fontsource(), - weights: [400, 500], - }, - ], + /** @type {import('./test-utils.js').DevServer} */ + let devServer; + + describe('shared', () => { + before(async () => { + fixture = await loadFixture({ + root: './fixtures/fonts/', + fonts: [ + { + name: 'Poppins', + cssVariable: '--font-test', + provider: fontProviders.fontsource(), + weights: [400, 500], + }, + ], + }); + await fixture.clean(); + devServer = await fixture.startDevServer(); + }); + + after(async () => { + await devServer?.stop(); }); - await run(async () => { + + it('Includes styles', async () => { const res = await fixture.fetch('/'); const html = await res.text(); const $ = cheerio.load(html); assert.equal(html.includes('