Skip to content

Commit

Permalink
Merge branch 'main' into chore/GH-12805
Browse files Browse the repository at this point in the history
  • Loading branch information
ascorbic authored Jan 10, 2025
2 parents 9f631ee + f00c2dd commit 557b8bb
Show file tree
Hide file tree
Showing 42 changed files with 199 additions and 97 deletions.
5 changes: 0 additions & 5 deletions .changeset/cold-clocks-tell.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/purple-pillows-lay.md

This file was deleted.

5 changes: 5 additions & 0 deletions .changeset/tame-hats-kiss.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"astro": patch
---

Improves the session error messages
5 changes: 0 additions & 5 deletions .changeset/twelve-cobras-shake.md

This file was deleted.

2 changes: 1 addition & 1 deletion examples/basics/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
"astro": "astro"
},
"dependencies": {
"astro": "^5.1.4"
"astro": "^5.1.5"
}
}
4 changes: 2 additions & 2 deletions examples/blog/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
"astro": "astro"
},
"dependencies": {
"@astrojs/mdx": "^4.0.4",
"@astrojs/mdx": "^4.0.5",
"@astrojs/rss": "^4.0.11",
"@astrojs/sitemap": "^3.2.1",
"astro": "^5.1.4"
"astro": "^5.1.5"
}
}
2 changes: 1 addition & 1 deletion examples/component/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
],
"scripts": {},
"devDependencies": {
"astro": "^5.1.4"
"astro": "^5.1.5"
},
"peerDependencies": {
"astro": "^4.0.0 || ^5.0.0"
Expand Down
4 changes: 2 additions & 2 deletions examples/container-with-vitest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"test": "vitest run"
},
"dependencies": {
"@astrojs/react": "^4.1.2",
"astro": "^5.1.4",
"@astrojs/react": "^4.1.3",
"astro": "^5.1.5",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"vitest": "^3.0.0-beta.3"
Expand Down
2 changes: 1 addition & 1 deletion examples/framework-alpine/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
"@astrojs/alpinejs": "^0.4.1",
"@types/alpinejs": "^3.13.10",
"alpinejs": "^3.14.3",
"astro": "^5.1.4"
"astro": "^5.1.5"
}
}
4 changes: 2 additions & 2 deletions examples/framework-multiple/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
},
"dependencies": {
"@astrojs/preact": "^4.0.1",
"@astrojs/react": "^4.1.2",
"@astrojs/react": "^4.1.3",
"@astrojs/solid-js": "^5.0.1",
"@astrojs/svelte": "^7.0.3",
"@astrojs/vue": "^5.0.4",
"@types/react": "^18.3.12",
"@types/react-dom": "^18.3.1",
"astro": "^5.1.4",
"astro": "^5.1.5",
"preact": "^10.24.3",
"react": "^18.3.1",
"react-dom": "^18.3.1",
Expand Down
2 changes: 1 addition & 1 deletion examples/framework-preact/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"dependencies": {
"@astrojs/preact": "^4.0.1",
"@preact/signals": "^2.0.0",
"astro": "^5.1.4",
"astro": "^5.1.5",
"preact": "^10.24.3"
}
}
4 changes: 2 additions & 2 deletions examples/framework-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
"astro": "astro"
},
"dependencies": {
"@astrojs/react": "^4.1.2",
"@astrojs/react": "^4.1.3",
"@types/react": "^18.3.12",
"@types/react-dom": "^18.3.1",
"astro": "^5.1.4",
"astro": "^5.1.5",
"react": "^18.3.1",
"react-dom": "^18.3.1"
}
Expand Down
2 changes: 1 addition & 1 deletion examples/framework-solid/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
},
"dependencies": {
"@astrojs/solid-js": "^5.0.1",
"astro": "^5.1.4",
"astro": "^5.1.5",
"solid-js": "^1.9.3"
}
}
2 changes: 1 addition & 1 deletion examples/framework-svelte/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
},
"dependencies": {
"@astrojs/svelte": "^7.0.3",
"astro": "^5.1.4",
"astro": "^5.1.5",
"svelte": "^5.1.16"
}
}
2 changes: 1 addition & 1 deletion examples/framework-vue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
},
"dependencies": {
"@astrojs/vue": "^5.0.4",
"astro": "^5.1.4",
"astro": "^5.1.5",
"vue": "^3.5.12"
}
}
2 changes: 1 addition & 1 deletion examples/hackernews/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
},
"dependencies": {
"@astrojs/node": "^9.0.0",
"astro": "^5.1.4"
"astro": "^5.1.5"
}
}
2 changes: 1 addition & 1 deletion examples/integration/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
],
"scripts": {},
"devDependencies": {
"astro": "^5.1.4"
"astro": "^5.1.5"
},
"peerDependencies": {
"astro": "^4.0.0"
Expand Down
2 changes: 1 addition & 1 deletion examples/minimal/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
"astro": "astro"
},
"dependencies": {
"astro": "^5.1.4"
"astro": "^5.1.5"
}
}
2 changes: 1 addition & 1 deletion examples/portfolio/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
"astro": "astro"
},
"dependencies": {
"astro": "^5.1.4"
"astro": "^5.1.5"
}
}
2 changes: 1 addition & 1 deletion examples/ssr/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"dependencies": {
"@astrojs/node": "^9.0.0",
"@astrojs/svelte": "^7.0.3",
"astro": "^5.1.4",
"astro": "^5.1.5",
"svelte": "^5.1.16"
}
}
2 changes: 1 addition & 1 deletion examples/starlog/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"astro": "astro"
},
"dependencies": {
"astro": "^5.1.4",
"astro": "^5.1.5",
"sass": "^1.80.6",
"sharp": "^0.33.3"
}
Expand Down
2 changes: 1 addition & 1 deletion examples/toolbar-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@
},
"devDependencies": {
"@types/node": "^18.17.8",
"astro": "^5.1.4"
"astro": "^5.1.5"
}
}
4 changes: 2 additions & 2 deletions examples/with-markdoc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"astro": "astro"
},
"dependencies": {
"@astrojs/markdoc": "^0.12.4",
"astro": "^5.1.4"
"@astrojs/markdoc": "^0.12.5",
"astro": "^5.1.5"
}
}
4 changes: 2 additions & 2 deletions examples/with-mdx/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
"astro": "astro"
},
"dependencies": {
"@astrojs/mdx": "^4.0.4",
"@astrojs/mdx": "^4.0.5",
"@astrojs/preact": "^4.0.1",
"astro": "^5.1.4",
"astro": "^5.1.5",
"preact": "^10.24.3"
}
}
2 changes: 1 addition & 1 deletion examples/with-nanostores/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"dependencies": {
"@astrojs/preact": "^4.0.1",
"@nanostores/preact": "^0.5.2",
"astro": "^5.1.4",
"astro": "^5.1.5",
"nanostores": "^0.11.3",
"preact": "^10.24.3"
}
Expand Down
4 changes: 2 additions & 2 deletions examples/with-tailwindcss/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
"astro": "astro"
},
"dependencies": {
"@astrojs/mdx": "^4.0.4",
"@astrojs/mdx": "^4.0.5",
"@astrojs/tailwind": "^5.1.4",
"@types/canvas-confetti": "^1.6.4",
"astro": "^5.1.4",
"astro": "^5.1.5",
"autoprefixer": "^10.4.20",
"canvas-confetti": "^1.9.3",
"postcss": "^8.4.49",
Expand Down
2 changes: 1 addition & 1 deletion examples/with-vitest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"test": "vitest"
},
"dependencies": {
"astro": "^5.1.4",
"astro": "^5.1.5",
"vitest": "^3.0.0-beta.3"
}
}
12 changes: 12 additions & 0 deletions packages/astro/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# astro

## 5.1.5

### Patch Changes

- [#12934](https://github.com/withastro/astro/pull/12934) [`673a518`](https://github.com/withastro/astro/commit/673a518b011e2df35a099f8205611d98a223a92a) Thanks [@ematipico](https://github.com/ematipico)! - Fixes a regression where the Astro Container didn't work during the build, using `pnpm`

- [#12955](https://github.com/withastro/astro/pull/12955) [`db447f2`](https://github.com/withastro/astro/commit/db447f2816836b635355cc2b0a73678facd155a5) Thanks [@martrapp](https://github.com/martrapp)! - Lets TypeScript know about the "blocking" and "disabled" attributes of the `<link>` element.

- [#12922](https://github.com/withastro/astro/pull/12922) [`faf74af`](https://github.com/withastro/astro/commit/faf74af522f4499ab95531b24a0a1c14070abe8b) Thanks [@adamchal](https://github.com/adamchal)! - Improves performance of static asset generation by fixing a bug that caused image transforms to be performed serially. This fix ensures that processing uses all CPUs when running in a multi-core environment.

- [#12947](https://github.com/withastro/astro/pull/12947) [`3c2292f`](https://github.com/withastro/astro/commit/3c2292f2f0accf1974b30dbe32f040c56413e731) Thanks [@ascorbic](https://github.com/ascorbic)! - Fixes a bug that caused empty content collections when running dev with NODE_ENV set

## 5.1.4

### Patch Changes
Expand Down
4 changes: 3 additions & 1 deletion packages/astro/astro-jsx.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -837,10 +837,12 @@ declare namespace astroHTML.JSX {

interface LinkHTMLAttributes extends HTMLAttributes {
as?: string | undefined | null;
blocking?: 'render' | undefined | null;
crossorigin?: boolean | string | undefined | null;
disabled?: boolean | undefined | null;
fetchpriority?: 'auto' | 'high' | 'low' | undefined | null;
href?: string | URL | undefined | null;
hreflang?: string | undefined | null;
fetchpriority?: 'auto' | 'high' | 'low' | undefined | null;
integrity?: string | undefined | null;
media?: string | undefined | null;
imagesrcset?: string | undefined | null;
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "astro",
"version": "5.1.4",
"version": "5.1.5",
"description": "Astro is a modern site builder with web best practices, performance, and DX front-of-mind.",
"type": "module",
"author": "withastro",
Expand Down
8 changes: 1 addition & 7 deletions packages/astro/src/assets/build/generate.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import fs, { readFileSync } from 'node:fs';
import { basename } from 'node:path/posix';
import { dim, green } from 'kleur/colors';
import type PQueue from 'p-queue';
import { getOutDirWithinCwd } from '../../core/build/common.js';
import type { BuildPipeline } from '../../core/build/pipeline.js';
import { getTimeStat } from '../../core/build/util.js';
Expand Down Expand Up @@ -101,16 +100,11 @@ export async function generateImagesForPath(
originalFilePath: string,
transformsAndPath: MapValue<AssetsGlobalStaticImagesList>,
env: AssetEnv,
queue: PQueue,
) {
let originalImage: ImageData;

for (const [_, transform] of transformsAndPath.transforms) {
await queue
.add(async () => generateImage(transform.finalPath, transform.transform))
.catch((e) => {
throw e;
});
await generateImage(transform.finalPath, transform.transform);
}

// In SSR, we cannot know if an image is referenced in a server-rendered page, so we can't delete anything
Expand Down
68 changes: 67 additions & 1 deletion packages/astro/src/core/build/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,73 @@ export async function generatePages(options: StaticBuildOptions, internals: Buil

const assetsTimer = performance.now();
for (const [originalPath, transforms] of staticImageList) {
await generateImagesForPath(originalPath, transforms, assetsCreationPipeline, queue);
// Process each source image in parallel based on the queue’s concurrency
// (`cpuCount`). Process each transform for a source image sequentially.
//
// # Design Decision:
// We have 3 source images (A.png, B.png, C.png) and 3 transforms for
// each:
// ```
// A1.png A2.png A3.png
// B1.png B2.png B3.png
// C1.png C2.png C3.png
// ```
//
// ## Option 1
// Enqueue all transforms indiscriminantly
// ```
// |_A1.png |_B2.png |_C1.png
// |_B3.png |_A2.png |_C3.png
// |_C2.png |_A3.png |_B1.png
// ```
// * Advantage: Maximum parallelism, saturate CPU
// * Disadvantage: Spike in context switching
//
// ## Option 2
// Enqueue all transforms, but constrain processing order by source image
// ```
// |_A3.png |_B1.png |_C2.png
// |_A1.png |_B3.png |_C1.png
// |_A2.png |_B2.png |_C3.png
// ```
// * Advantage: Maximum parallelism, saturate CPU (same as Option 1) in
// hope to avoid context switching
// * Disadvantage: Context switching still occurs and performance still
// suffers
//
// ## Option 3
// Enqueue each source image, but perform the transforms for that source
// image sequentially
// ```
// \_A1.png \_B1.png \_C1.png
// \_A2.png \_B2.png \_C2.png
// \_A3.png \_B3.png \_C3.png
// ```
// * Advantage: Less context switching
// * Disadvantage: If you have a low number of source images with high
// number of transforms then this is suboptimal.
//
// ## BEST OPTION:
// **Option 3**. Most projects will have a higher number of source images
// with a few transforms on each. Even though Option 2 should be faster
// and _should_ prevent context switching, this was not observed in
// nascent tests. Context switching was high and the overall performance
// was half of Option 3.
//
// If looking to optimize further, please consider the following:
// * Avoid `queue.add()` in an async for loop. Notice the `await
// queue.onIdle();` after this loop. We do not want to create a scenario
// where tasks are added to the queue after the queue.onIdle() resolves.
// This can break tests and create annoying race conditions.
// * Exposing a concurrency property in `astro.config.mjs` to allow users
// to override Node’s os.cpus().length default.
// * Create a proper performance benchmark for asset transformations of
// projects in varying sizes of source images and transforms.
queue
.add(() => generateImagesForPath(originalPath, transforms, assetsCreationPipeline))
.catch((e) => {
throw e;
});
}

await queue.onIdle();
Expand Down
Loading

0 comments on commit 557b8bb

Please sign in to comment.