-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Environment API #14306
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
Merged
+13,500
−10,204
Merged
Environment API #14306
Changes from all commits
Commits
Show all changes
134 commits
Select commit
Hold shift + click to select a range
cb3f394
refactor: use environments to load modules (#14191)
ematipico c6a8ac8
refactor: make `App` more extensible using `BaseApp` (#14197)
ematipico c970fc4
refactor: App to extends the new BaseApp (#14213)
ematipico a9b4871
refactor: manifest as virtual module (#14298)
ematipico 5df82a0
chore: resolve merging conflicts
ematipico c701fe4
chore: resolve merging conflicts
ematipico 019336e
refactor: create generate when needed (#14303)
ematipico 9ed7a3c
refactor: routes as virtual module (#14313)
ematipico ed90bcb
Merge branch 'main' into feat/environment-api
ascorbic 2b17868
Lock
ascorbic 5c41688
Use separate env to load content config (#14324)
ascorbic 4a80ecf
fix: creation of routes list in build (#14325)
ematipico 43b3ed5
refactor(dev): use entry point to bootstrap the app (#14333)
ematipico de4e76d
refactor(dev): expose dev app and entrypoint (#14337)
ematipico e168464
Add Cloudflare Vite plugin (#14309)
ascorbic a2e2965
refactor: dedicated `App` for astro server and for external servers (…
ematipico 1e50d7d
Add support for content layer in env API (#14357)
ascorbic d5979c2
Add support for Cloudflare images binding in environment API (#14358)
ascorbic 48197bb
Use imported Cloudflare handler in env API (#14360)
ascorbic b8ba777
Merge branch 'main' into feat/environment-api
ascorbic 22b9c33
Dedupe
ascorbic 77fdf98
Support framework components (#14382)
matthewp 56718e0
Update vite plugin
ascorbic 1a184bc
feat: add support for server islands in Environment API (#14390)
ascorbic f55775e
Merge branch 'main' into feat/environment-api
ascorbic dc345ca
Support HMR in Environment API (#14393)
ascorbic aa355a0
Fix unit tests for environment API (#14394)
ascorbic 28b2f42
refactor: clean up dead code for env API (#14395)
ascorbic 14dd565
Merge branch 'next' into feat/environment-api
ascorbic 62051d5
Add draft changesets
ascorbic a545ca7
Merge branch 'next' into feat/environment-api
ascorbic ea1543a
lock
ascorbic d6caec8
feat: support for astro actions (#14478)
ematipico a2a07aa
feat: support i18n (#14486)
ematipico 015e4e2
chore: add `astro:env` examples to cloudflare (#14534)
ematipico f91503f
chore: upgrade vite to v7 (#14535)
ematipico 9d2b501
chore: handle invalidation of manifest (#14537)
ematipico 492cc59
refactor: support devtoolbar (#14549)
ematipico 74ddeaa
chore: fix regression in tests
ematipico 974fdea
chore: add view transitions example (#14561)
ematipico 082d47d
Merge remote-tracking branch 'origin/next' into feat/environment-api
ematipico 5303c50
chore: fix rebase with next
ematipico f6b0a73
refactor: entrypoint DX (#14563)
ematipico 1fcab24
environments: get images to build in fixture (#14599)
matthewp 783daf6
refactor: support middleware in entrypoint (#14616)
ematipico 714f755
refactor(sessions): import driver via vite plugin (#14632)
ematipico 6c066d5
Get demo app deploying to Cloudflare (#14634)
matthewp 05b8ff9
refactor(core): clean up of apps (#14637)
ematipico 1f1e669
refactor: fonts (#14694)
ematipico 7fcd225
feat: full sessions support w/ environment api (#14696)
matthewp 21d819d
refactor: remove `getRunnableDevEnvironment` (#14705)
ematipico 0834318
refactor: properly load and compute server island (#14742)
ematipico e58896e
Unify client/ssr builds using Vite environments (#14763)
matthewp e39f6a0
Only build client output if there are client scripts
matthewp 20a3e6e
refactor: make styles working in dev (#14753)
ematipico 3f217bc
fix: resolve environment-api build issues for client & CSS (#14770)
matthewp ce85e9c
Fixes CSS when both static/client styles exist (#14790)
matthewp 326b568
remove unused getStylesForURL tests
matthewp 536d4ba
fix: flag `serverLike` incorrectly computed (#14792)
ematipico 36cae83
Merge branch 'next' into feat/environment-api
matthewp 2c6bdd1
Merge branch 'feat/environment-api' of github.com:withastro/astro int…
matthewp 96972be
Remove logger not used in next
matthewp dc2d9c3
Fix breaking unit tests
matthewp 72d8329
Fix linting in vite-plugin-astro-server tests
matthewp c91fbc3
Use routeCache from the pipeline (#14794)
matthewp 4ccf8e9
fix: redirects and i18n routing (#14797)
ematipico f3401fa
Always include the routeData in the prerender manifest for generation…
matthewp 771832e
fix: logger level and static paths params (#14799)
ematipico e0f1ba3
Filter out SSR routes from prerender (#14802)
matthewp 8a43add
Fix image tests crashing (#14803)
matthewp 0ee8474
Environment api: use proper logger (#14805)
Princesseuh 05070a2
Prevent duplication of client CSS (#14812)
matthewp ada0ece
fix(environment): Error overlay not working (#14816)
Princesseuh 78cb18d
Move assets before generating pages (#14817)
matthewp 8eee00d
fix: hashing of chunks (#14811)
ematipico 23812d8
refactor: build and error handling (#14823)
ematipico 5c7a32b
Fix before-hydration script emission for environment-api (#14818)
matthewp 2e8fc0e
Merge branch 'next' into feat/environment-api
ematipico a51b0ce
fix rebase
ematipico 44667ff
fix rebase v2
ematipico ce3313b
Merge remote-tracking branch 'refs/remotes/origin/feat/environment-ap…
ematipico 00c1322
fix: node leak into content collections (#14820)
Princesseuh 7df8925
fix: avoid `node:path` (#14827)
ematipico b91e282
Restore propagated styles injection for content collections (#14814)
matthewp 85041e4
Fix API route tests (#14825)
matthewp e6477e6
test(css): ensure CSS modules are not duplicated in build output (#14…
hasegawa-101 c9b2e7a
Fix unit tests (#14832)
matthewp 4ca3c28
Merge branch 'next' into feat/environment-api
matthewp 93a77e0
Fix outdated lockfile
matthewp cebe38e
chore: don't enforce assist in PRs (#14849)
ematipico 7ff6a8f
Remove non-sensical routing tests for format: file (#14835)
matthewp 360a485
fix: server islands build (#14830)
ematipico 921b10a
Fix astro-component-bundling tests (#14840)
matthewp b5165f8
Fix astro-component-bundling tests (#14837)
matthewp 4d82cd4
Don't generate default routes (#14841)
matthewp 96fdb52
Fix config alias by using resolve.alias config (#14828)
matthewp 66dfdcd
fix: container and routing tests (#14852)
ematipico 733ba46
fix: respect user vite config on sourcemaps (#14847)
Princesseuh 4bd6145
fix: remove useless tests (#14854)
ematipico a947086
Fixes assetQueryParams and public folder tests (#14853)
matthewp 1527b36
fix: renderError fallback (#14855)
ematipico dff3310
Fix server-islands data being used across tests (#14857)
matthewp 2481df5
Prevent loading plugin-pages in build/pipeline (#14859)
matthewp 30c610b
Remove prerender-chunks tests (#14860)
matthewp 36e0bed
fix: incorrect configuration in tests (#14858)
ematipico 86ad8e1
Fixes for tests in environment branch (#14865)
matthewp eef7bff
Fixes for e2e tests in environment branch (#14870)
matthewp 4d3e8ff
fix(test): svelte async rendering (#14886)
Princesseuh e8aba4b
Remove virtual page module from importing renderers (#14885)
matthewp c0553c1
fix(cloudflare/vercel/netlify): some tests pass and excluded others (…
ematipico eb0fc87
Fixes for node integrations tests (#14900)
matthewp 22518ac
Fix @astrojs/db tests (#14899)
matthewp dbb3e9f
feat(cloudflare): preview server (#14906)
ematipico 3c86364
docs: add changesets for environment API refactor (#14915)
matthewp 93095c4
fix(environment): Prevent Vite from interpreting injected sourcemap c…
Princesseuh 3e172ef
Fix remaining cloudflare tests (#14912)
matthewp cf56296
Remove usage of augmentChunkHash (#14926)
matthewp 82d9f37
fix(sourcemap): Avoid Vite's regex picking up generated sourceMappingURL
Princesseuh f6f3bf8
fix(vite): import mergeConfig from direct file to avoid dynamic impor…
Princesseuh 922daf0
Fix astro:env tests in Cloudflare (#14925)
matthewp 2d35ddb
Update .changeset/encoding-static-builds.md
matthewp a5eb3db
Update .changeset/route-data-breaking.md
matthewp 1e75fb0
Update .changeset/ssr-manifest-breaking.md
matthewp 0b0ddfd
Update .changeset/vite-environments-breaking.md
matthewp ba0db9c
Update .changeset/adapter-interface-breaking.md
matthewp 58d51c3
Update .changeset/cloudflare-entrypoint-breaking.md
matthewp 152e785
Update .changeset/cloudflare-entrypoint-breaking.md
matthewp 0228984
Update .changeset/open-monkeys-boil.md
matthewp 76e803d
Update .changeset/wet-lines-wear.md
matthewp 592fbeb
Update .changeset/open-monkeys-boil.md
matthewp f188ba5
add titles to code samples
matthewp 76210c6
Merge branch 'feat/environment-api' of github.com:withastro/astro int…
matthewp 71d2382
Update .changeset/route-data-breaking.md
matthewp 98144fb
refactor: optimise dependencies (#14951)
ematipico File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| --- | ||
| 'astro': minor | ||
| --- | ||
|
|
||
| Adds new optional properties to `setAdapter()` for adapter entrypoint handling in the Adapter API | ||
|
|
||
| **Changes:** | ||
| - New optional properties: | ||
| - `devEntrypoint?: string | URL` - specifies custom dev server entrypoint | ||
| - `entryType?: 'self' | 'legacy-dynamic'` - determines if the adapter provides its own entrypoint (`'self'`) or if Astro constructs one (`'legacy-dynamic'`, default) | ||
|
|
||
| **Migration:** Adapter authors can optionally add these properties to support custom dev entrypoints. If not specified, adapters will use the legacy behavior. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| --- | ||
| '@astrojs/cloudflare': major | ||
| --- | ||
|
|
||
| Changes the API for creating a custom `entrypoint`, replacing the `createExports()` function with a direct export pattern. | ||
|
|
||
| #### What should I do? | ||
|
|
||
| If you're using a custom `entryPoint` in your Cloudflare adapter config, update your existing worker file that uses `createExports()` to reflect the new, simplified pattern: | ||
|
|
||
|
|
||
| __my-entry.ts__ | ||
|
|
||
| ```ts | ||
| import type { SSRManifest } from 'astro'; | ||
| import { App } from 'astro/app'; | ||
| import { handle } from '@astrojs/cloudflare/handler' | ||
| import { DurableObject } from 'cloudflare:workers'; | ||
|
|
||
| class MyDurableObject extends DurableObject<Env> { | ||
| constructor(ctx: DurableObjectState, env: Env) { | ||
| super(ctx, env) | ||
| } | ||
| } | ||
|
|
||
| export function createExports(manifest: SSRManifest) { | ||
| const app = new App(manifest); | ||
| return { | ||
| default: { | ||
| async fetch(request, env, ctx) { | ||
| await env.MY_QUEUE.send("log"); | ||
| return handle(manifest, app, request, env, ctx); | ||
| }, | ||
| async queue(batch, _env) { | ||
| let messages = JSON.stringify(batch.messages); | ||
| console.log(`consumed from our queue: ${messages}`); | ||
| } | ||
| } satisfies ExportedHandler<Env>, | ||
| MyDurableObject: MyDurableObject, | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| To create the same custom `entrypoint` using the updated API, export the following function instead: | ||
|
|
||
| __my-entry.ts__ | ||
|
|
||
| ```ts | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same file title here as the previous example |
||
| import { handle } from '@astrojs/cloudflare/utils/handler'; | ||
|
|
||
| export default { | ||
| async fetch(request, env, ctx) { | ||
| await env.MY_QUEUE.send("log"); | ||
| return handle(manifest, app, request, env, ctx); | ||
| }, | ||
| async queue(batch, _env) { | ||
| let messages = JSON.stringify(batch.messages); | ||
| console.log(`consumed from our queue: ${messages}`); | ||
| } | ||
| } satisfies ExportedHandler<Env>, | ||
| ``` | ||
|
|
||
| The manifest is now created internally by the adapter. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| 'astro': major | ||
| --- | ||
|
|
||
| Removes support for routes with percent-encoded percent signs (e.g. `%25`) - ([v6 upgrade guidance](https://deploy-preview-12322--astro-docs-2.netlify.app/en/guides/upgrade-to/v6/#removed-percent-encoding-in-routes)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- | ||
| '@astrojs/cloudflare': minor | ||
| --- | ||
|
|
||
| Adds support for `astro preview` command | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This one looks great! |
||
|
|
||
| Developers can now use `astro preview` to test their Cloudflare Workers application locally before deploying. The preview runs using Cloudflare's workerd runtime, giving you a staging environment that matches production exactly—including support for KV namespaces, environment variables, and other Cloudflare-specific features. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| --- | ||
| '@astrojs/cloudflare': major | ||
| --- | ||
|
|
||
| Development server now runs in workerd | ||
sarah11918 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| `astro dev` now runs your Cloudflare application using Cloudflare's workerd runtime instead of Node.js. This means your development environment is now a near-exact replica of your production environment—the same JavaScript engine, the same APIs, the same behavior. You'll catch issues during development that would have only appeared in production, and features like Durable Objects, Workers Analytics Engine, and R2 bindings work exactly as they do on Cloudflare's platform. | ||
matthewp marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| To accommodate this major change to your development environment, this update includes breaking changes to `Astro.locals.runtime`, removing some of its properties. | ||
|
|
||
| #### What should I do? | ||
|
|
||
| Update occurrences of `Astro.locals.runtime` as shown below: | ||
|
|
||
| - `Astro.locals.runtime` no longer contains the `env` object. Instead, import it directly: | ||
| ```js | ||
| import { env } from 'cloudflare:workers'; | ||
| ``` | ||
|
|
||
| - `Astro.locals.runtime` no longer contains the `cf` object. Instead, access it directly from the request: | ||
| ```js | ||
| Astro.request.cf | ||
| ``` | ||
|
|
||
| - `Astro.locals.runtime` no longer contains the `caches` object. Instead, use the global `caches` object directly: | ||
| ```js | ||
| caches.default.put(request, response) | ||
| ``` | ||
|
|
||
| - `Astro.locals.runtime` object is replaced with `Astro.locals.cfContext` which contains the Cloudflare `ExecutionContext`: | ||
| ```js | ||
| const cfContext = Astro.locals.cfContext; | ||
| ``` | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| 'astro': major | ||
| --- | ||
|
|
||
| Removes `RouteData.generate` from the Integration API - ([v6 upgrade guidance](https://deploy-preview-12322--astro-docs-2.netlify.app/en/guides/upgrade-to/v6/#removed-routedatagenerate-adapter-api)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| 'astro': major | ||
| --- | ||
|
|
||
| Changes the shape of `SSRManifest` properties and adds several new required properties in the Adapter API - ([v6 upgrade guidance](https://deploy-preview-12322--astro-docs-2.netlify.app/en/guides/upgrade-to/v6/#changed-ssrmanifest-interface-structure-adapter-api)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| 'astro': major | ||
| --- | ||
|
|
||
| Changes integration hooks and HMR access patterns in the Integration API - ([v6 upgrade guidance](https://deploy-preview-12322--astro-docs-2.netlify.app/en/guides/upgrade-to/v6/#changed-integration-hooks-and-hmr-access-patterns-integration-api)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| 'astro': major | ||
| --- | ||
|
|
||
| Removes the unused `astro:ssr-manifest` virtual module - ([v6 upgrade guidance](https://deploy-preview-12322--astro-docs-2.netlify.app/en/guides/upgrade-to/v6/#removed-astrossr-manifest-virtual-module-integration-api)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,7 +28,7 @@ | |
| "assist": { | ||
| "actions": { | ||
| "source": { | ||
| "organizeImports": "on" | ||
| "organizeImports": "off" | ||
| } | ||
| } | ||
| }, | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For clarity, can you add a title to this file (and the following)?