Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds a new "astro:build:generated" hook for SSG builds #4775

Merged
merged 4 commits into from
Sep 21, 2022

Conversation

tony-sull
Copy link
Contributor

This feature was originally reviewed in #4772 but accidentally merged in as a minor release too early. #4774 reverted the feature to avoid blocking patch releases


Changes

This adds a new astro:build:generated hook that runs after all SSG pages are generated but before build artifacts are cleaned up.

Why?

This handles a very specific use case for @astrojs/image. The new wasm-based image service uses a worker pool to build multiple images in parallel. The workers need to reference the build's main entrypoint bundle before it's removed by the cleanup process

Alternatives considered

  • fire astro:build:done before the cleanup process

This would technically be a breaking change, and feels a little gross in general since the build really isn't done until it's finished cleanup and is exiting

  • refactor the SSG image service to build images during the page generation rather than building all images at the end.

This is a huge performance hit, doing all images at once allows the process to read a local image file once and build all needed versions at once without hitting fs.readFile again

Testing

Test added to make sure the event fires with the correct output directory

Docs

Docs PR #1572

/cc @withastro/maintainers-docs for feedback!

@tony-sull tony-sull requested a review from a team as a code owner September 15, 2022 21:32
@changeset-bot
Copy link

changeset-bot bot commented Sep 15, 2022

🦋 Changeset detected

Latest commit: 74c8133

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 16 packages
Name Type
astro Minor
@e2e/astro-component Patch
@e2e/error-cyclic Patch
@e2e/error-react-spectrum Patch
@e2e/error-sass Patch
@e2e/errors Patch
@e2e/hydration-race Patch
@e2e/lit-component Patch
@e2e/preact-component Patch
@e2e/react-component Patch
@e2e/solid-component Patch
@e2e/solid-recurse Patch
@e2e/svelte-component Patch
@e2e/e2e-tailwindcss Patch
@e2e/ts-resolution Patch
@e2e/third-party-astro Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added the pkg: astro Related to the core `astro` package (scope) label Sep 15, 2022
@tony-sull tony-sull self-assigned this Sep 15, 2022
@tony-sull tony-sull added the semver: minor Change triggers a `minor` release label Sep 15, 2022
@sarah11918 sarah11918 removed the request for review from a team September 21, 2022 14:05
@sarah11918
Copy link
Member

Unrequested Docs Maintainers review, since this was triggered automatically by a change to @types/astro.ts. But, changes don't affect public-facing docs on configuration-reference page. We're on the separate Docs PR for this one!

@tony-sull tony-sull merged commit b0cc939 into main Sep 21, 2022
@tony-sull tony-sull deleted the feat/generated-hook branch September 21, 2022 17:13
@astrobot-houston astrobot-houston mentioned this pull request Sep 21, 2022
ArmandPhilippot added a commit to ArmandPhilippot/astro-docs that referenced this pull request Jan 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg: astro Related to the core `astro` package (scope) semver: minor Change triggers a `minor` release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants