Adds a new "astro:build:generated" hook for SSG builds #4775
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 processAlternatives considered
astro:build:done
before the cleanup processThis 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
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
againTesting
Test added to make sure the event fires with the correct output directory
Docs
Docs PR #1572
/cc @withastro/maintainers-docs for feedback!