Commit a164c77
Support prerendering inside of adapter runtimes (#15077)
* refactor to use buildApp
* fix build
* remove any casting
* refactor: split buildApp into top-level config and post plugin
Move environment builds to top-level builder.buildApp for framework
ownership, add post plugin with enforce:'post' for manifest injection
and page generation. Enables proper coordination with platform plugins.
* feat: add AstroPrerenderer interface for adapter-controlled prerendering
Adds a new prerenderer API allowing adapters to control how pages are
prerendered. Key changes:
- Add AstroPrerenderer interface with setup/getStaticPaths/render/teardown
- Add setPrerenderer to astro:build:start hook
- Create default prerenderer wrapping current Node-based behavior
- Refactor generate.ts to use prerenderer interface
- Add astro:static-paths virtual module for runtime getStaticPaths
* fix: pass allowPrerenderedRoutes=true when matching routes in prerenderer
app.match() filters out prerendered routes by default, causing 404s
* refactor: StaticPaths class for cleaner prerenderer API
- Replace getStaticPaths function with StaticPaths class
- Encapsulates RouteCache internally, adapters just pass app
- Track pathname→route mapping to avoid route priority issues
- Use app.getPathnameFromRequest for base handling
- Fall back to app.match for static routes
* fix: use pipeline.getComponentByRoute for redirect handling
Redirects don't have page modules in pageMap - pipeline method
handles redirects and fallbacks properly.
* refactor: pass routeData to prerenderer.render() to avoid re-matching
getStaticPaths() now returns PathWithRoute[] instead of string[].
render() receives routeData from caller, eliminating path manipulation.
* fix: remove unused PathWithRoute import
* fix: add prerender conflict detection to generate.ts
* fix: lint issues - type import and unused exports
* Fix API to not require routeData
* don't use own prerender entry when prerenderer defined already
* Fix some more tests
* Revert render(request) only approach, restore routeData parameter
The map-based route lookup added complexity and broke i18n fallback tests.
Reverting to pass routeData directly to render() as before.
* Get it working
* Fix build
* fix lint issues
* bad merge thing
* skipping tests
* temp skip netlify
* exclude cloudflare for test
* Add some logging
* Add unhandled rejection logging
* Don't run CSS plugin in prerender
* Some changes
* Fix weird resolution
* Fix lint
* Allow more process listeners
* Add some debug info for handles
* Preoptimize static-paths
* use the exact module name
* Expand when we do this
* no js
* use the virtual module of course
* REmove debugging stuff
* Add a test
* reorder entryType
* Add changesets
* more fixes
* Update packages/astro/src/core/create-vite.ts
Co-authored-by: Florian Lefebvre <contact@florian-lefebvre.dev>
* Update .changeset/custom-prerenderer-api.md
Co-authored-by: Florian Lefebvre <contact@florian-lefebvre.dev>
* Use an options object.
* Directly pass Prerenderer
* PR comments
* Fix build
* Reorganize timers and build block
* Add astro environment to dev CSS plugin
* Add pnpm override to force single vite version (7.3.1)
* Move entrypoint files to entrypoint/dev and entrypoint/prod
* Refactor prerender endpoints into separate utility module
- Create prerender.ts with documented helper functions
- Add isPrerender flag to virtual cloudflare config (only true in prerender env)
- Guard prerender endpoints so they're only active during build
- Use helper functions for cleaner, more readable handler code
* Improve error message for prerender server startup failure
* Use shared endpoint constants in prerenderer
* Improve error message for static paths fetch failure
* Add comment explaining previewServer cleanup
* Add tests for normalizePathname function
* Upgrade to latest cloudflare vite plugin
* Remove the override
* dedupe
* fix types
* Move constants into constants file
* Fix prerendered styles in cloudflare
* Use astro.config for typing
* Add back missing i18n fallback code
* Add comment explaining why prerender is excluded
* Update .changeset/custom-prerenderer-api.md
Co-authored-by: Sarah Rainsberger <5098874+sarah11918@users.noreply.github.com>
* Add a better comment
---------
Co-authored-by: Florian Lefebvre <contact@florian-lefebvre.dev>
Co-authored-by: Sarah Rainsberger <5098874+sarah11918@users.noreply.github.com>1 parent c5ea720 commit a164c77
43 files changed
Lines changed: 1925 additions & 976 deletions
File tree
- .changeset
- packages
- astro
- src
- core
- app
- entrypoint
- build
- plugins
- config
- integrations
- runtime/prerender
- types
- public
- vite-plugin-app
- vite-plugin-astro-server
- vite-plugin-css
- vite-plugin-static-paths
- test
- integrations
- cloudflare
- src
- utils
- test/fixtures/sessions
- node/test
- internal-helpers
- src
- test
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
286 | 286 | | |
287 | 287 | | |
288 | 288 | | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
289 | 293 | | |
290 | 294 | | |
291 | 295 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
55 | 58 | | |
56 | 59 | | |
57 | 60 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | | - | |
3 | | - | |
4 | | - | |
5 | | - | |
6 | | - | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
| 14 | + | |
13 | 15 | | |
14 | 16 | | |
15 | 17 | | |
| |||
0 commit comments