* fix(transitions router): no-op on the server
* factor out onPopState
* add e2e test case
* Apply suggestions from code review
Co-authored-by: Martin Trapp <94928215+martrapp@users.noreply.github.com>
* use supportsViewTransitions
* add changeset
* warn on navigate() use during ssr
* switch supportsViewTransitions to import.meta.env
* correct typo
* bring back import.meta.env
* !import.meta.env.SSR -> inBrowser
* Apply suggestions from code review
Co-authored-by: Martin Trapp <94928215+martrapp@users.noreply.github.com>
* Apply suggestions from code review
Co-authored-by: Martin Trapp <94928215+martrapp@users.noreply.github.com>
---------
Co-authored-by: Martin Trapp <94928215+martrapp@users.noreply.github.com>
* feat(cloudflare): add D1 database binding
* feat(cloudflare): add local mocking for R2 bindings (#8656)
* feat(cloudflare): add local mocking for KV bindings (#8657)
* feat(cloudflare): add local mocking for Caches bindings (#8664)
* feat(cloudflare): add local mocking for DO bindings (#8690)
---------
Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
* Fix assets not getting optimized when `outDir` is outside the CWD
* Add missing import
* Add changeset
* Fix import, again.
* Use getOutDirWithinCwd in the serverRoot declaration
* Add View Transitions announcer
* fix astro check
* Append the text in a setTimeout
* Use 60 for the timeout
* Add comment on magic number
* Add a changeset
* Update .changeset/small-rules-relax.md
Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
* Bring back announce logic
* Remove mention of env file
---------
Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
* refactored CSR into goto() function
* first refectoring for router API
* added test
* added comments to fixture
* rename + preliminary changeset
* changeset: now 'minor' and featuring Mathew's example from the docs
* moved for simpler diff
* update after #8617
* fixed ts-errors
* more comprehensible handling of intra-page state
* sync with main
* synch from next_tm
* added config for _routes.json generation
* added changeset
* renamed test file
* updated comments
* Apply suggestions from code review
Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
* worked on tests
* worked on docs
* worked on docs
* worked on tests
* updated pnpm-lock.yaml
* worked on tests
* moved the _worker.js in cloudflareSpecialFiles statement
---------
Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
Co-authored-by: Alexander Niebuhr <alexander@nbhr.io>
* fix(markdown): Fix Markdown images breaking the build
* chore: changeset
* Update packages/astro/src/core/errors/errors-data.ts
Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
* Fix tla chunking
* One directory up
* Down we go
---------
Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
Co-authored-by: bluwy <bjornlu.dev@gmail.com>
* Change functionPerRoute to false by default
* Update test that depends on functionPerRoute
* Update .changeset/cool-pianos-smell.md
Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
* Update .changeset/cool-pianos-smell.md
Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
* Update packages/integrations/vercel/README.md
Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
* Update packages/integrations/vercel/README.md
Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
* Update .changeset/cool-pianos-smell.md
---------
Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
* Individually enable Speed Insights and Web Analytics
* Update pnpm-lock.yaml
* Remove .only on tests
* Fix build
* Move `beforeSend` out of config
* Address feedback from review
* Update README.md
* Add back the `analytics` property and add deprecation warning when used
* Add migration guide for the deprecated `analytics` property
* Update packages/integrations/vercel/README.md
Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
* Update README.md
* Fix external dependency issue
* Simplify plugin and reduce scope
* Update .changeset/sixty-teachers-tap.md
Co-authored-by: Emanuele Stoppa <my.burning@gmail.com>
* Apply feedback from review
* Move exposeEnv to speed-insights since it's only used there
---------
Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
Co-authored-by: Matthew Phillips <matthew@skypack.dev>
Co-authored-by: Emanuele Stoppa <my.burning@gmail.com>
* bugfix checking media-type
* bugfix checking media-type
* Update packages/astro/components/ViewTransitions.astro
.* is longest possible run, but a dollar won't harm us :)
Co-authored-by: Nate Moore <natemoo-re@users.noreply.github.com>
* make typescript happy
---------
Co-authored-by: Nate Moore <natemoo-re@users.noreply.github.com>
* feat: added types to astro:content to allow user space content services
* Create small-apes-clap.md
---------
Co-authored-by: Nate Moore <natemoo-re@users.noreply.github.com>
Co-authored-by: Erika <3019731+Princesseuh@users.noreply.github.com>
* feat(vercel): Use Sharp in dev instead of Squoosh by default
* fix(build):
* nit: adjust with feedback
* fix: imports
* Update packages/integrations/vercel/README.md
Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
* docs: small change in other part of the README
---------
Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
* Bugfixes for back navigation in the view transition client-side router
* re-introduced pushState on self links as required for update of browser's address bar
* format
* Fix multi-layout head injection
* Tracing fix
* Improved walk
* Upgrade the compiler version
---------
Co-authored-by: Nate Moore <natemoo-re@users.noreply.github.com>
* added e2e test regarding loss of router
* only navigate to pages from which we can navigate back
* location does not change before deferred pushState
* initialize history state
* test cases adapted to new semantics (only traverse to pages w/ ViewTransigs)
* type URL instead of Location
* + changeset
* fix: no asset plugin w/ img is imported with query
* add changeset
* add test for the new feature
* remove exp
* use removeQueryString instead of `includes('?')`
it's more explicit
---------
Co-authored-by: Erika <3019731+Princesseuh@users.noreply.github.com>
* add leading and trailing slash sanitization for params
* chore: fix lint
* refactor: use shared trimSlashes util
---------
Co-authored-by: Nate Moore <natemoo-re@users.noreply.github.com>
Co-authored-by: Nate Moore <nate@astro.build>
* View Transitions: use history.scrollRestoration="manual"
* Update changeset
* Set scrollRestoration to manual before popState
Co-authored-by: Martin Trapp <94928215+martrapp@users.noreply.github.com>
---------
Co-authored-by: Nate Moore <natemoo-re@users.noreply.github.com>
Co-authored-by: Martin Trapp <94928215+martrapp@users.noreply.github.com>
* fix(ssr): inline middleware during the build, not rely on file system
* feedback
* chore: fix lint
---------
Co-authored-by: Nate Moore <nate@astro.build>
Co-authored-by: Nate Moore <natemoo-re@users.noreply.github.com>
* Lazily initialize ResponseWithEncoding
* Fix things
* Add a TODO about removing the workaround
* Remove unused lint ignore
* Use canplaythrough instead
* Use an inline script
* Check the readystate first
* Download the video locally
* Capture consoles
* More debugging
* Use autoplay instead of a ready event
* fix(deno): add start to options and extract to new file
* Reword changeset
---------
Co-authored-by: Arsh <69170106+lilnasy@users.noreply.github.com>
* Fixes in the client-side router
* reverted function declaration after review (#8166)
---------
Co-authored-by: Nate Moore <natemoo-re@users.noreply.github.com>
* fix(node): delegate preview's not found and error handling to core/app
* add changeset
---------
Co-authored-by: Nate Moore <natemoo-re@users.noreply.github.com>
* chore: replace `class:list` implementation with `clsx`
* chore: remove Set support from `class:list` test
* chore: better class:list test
* Update packages/astro/src/runtime/server/render/component.ts
Remove support for Node 16. The lowest supported version by Astro and all integrations is now v18.14.1. As a reminder, Node 16 will be deprecated on the 11th September 2023.
This import alias is no longer included by default with astro:assets. If you were using this alias with experimental assets, you must convert them to relative file paths, or create your own [import aliases](https://docs.astro.build/en/guides/aliases/).
The Solid integration now has new `include` and `exclude` config options. Use these if you want to use Solid alongside another JSX framework; include specifies files to be compiled for Solid and `exclude` does the opposite.
Sharp is now the default image service used for `astro:assets`. If you would prefer to still use Squoosh, you can update your config with the following:
```ts
import { defineConfig, squooshImageService } from "astro/config";
// https://astro.build/config
export default defineConfig({
image: {
service: squooshImageService(),
}
})
```
However, not only do we recommend using Sharp as it is faster and more reliable, it is also highly likely that the Squoosh service will be removed in a future release.
Remove backwards-compatible kebab-case transform for camelCase CSS variable names passed to the `style` attribute. If you were relying on the kebab-case transform in your styles, make sure to use the camelCase version to prevent missing styles. For example:
When using an adapter that supports neither Squoosh or Sharp, Astro will now automatically use an image service that does not support processing, but still provides the other benefits of `astro:assets` such as enforcing `alt`, no CLS etc to users
The Preact integration now has new `include` and `exclude` config options. Use these if you want to use Preact alongside another JSX framework; include specifies files to be compiled for Preact and `exclude` does the opposite.
Export experimental `dev`, `build`, `preview`, and `sync` APIs from `astro`. These APIs allow you to run Astro's commands programmatically, and replaces the previous entry point that runs the Astro CLI.
While these APIs are experimental, the inline config parameter is relatively stable without foreseeable changes. However, the returned results of these APIs are more likely to change in the future.
```ts
import { dev, build, preview, sync, type AstroInlineConfig } from 'astro';
// Inline Astro config object.
// Provide a path to a configuration file to load or set options directly inline.
Reimplement https://github.com/withastro/astro/pull/7509 to correctly emit pre-rendered pages now that `build.split` is deprecated and this configuration has been moved to `functionPerRoute` inside the adapter.
`astro:`namespace aliases for middleware and components
This adds aliases of `astro:middleware` and `astro:components` for the middleware and components modules. This is to make our documentation consistent between are various modules, where some are virtual modules and others are not. Going forward new built-in modules will use this namespace.
Remove exports for `astro/internal/*` and `astro/runtime/server/*` in favour of `astro/runtime/*`. Add new `astro/compiler-runtime` export for compiler-specific runtime code.
These are exports for Astro's internal API and should not affect your project, but if you do use these entrypoints, you can migrate like below:
Astro's JSX handling has been refactored with better support for each framework.
Previously, Astro automatically scanned your components to determine which framework-specific transformations should be used. In practice, supporting advanced features like Fast Refresh with this approach proved difficult.
Now, Astro determines which framework to use with `include` and `exclude` config options where you can specify files and folders on a per-framework basis. When using multiple JSX frameworks in the same project, users should manually control which files belong to each framework using the `include` and `exclude` options.
```js
export default defineConfig({
// The `include` config is only needed in projects that use multiple JSX frameworks;
`@astrojs/vercel/serverless` now supports Edge middleware, so a separate adapter for Edge itself (deploying your entire app to the edge) is no longer necessary. Please update your Astro config to reflect this change:
```diff
// astro.config.mjs
import { defineConfig } from 'astro/config';
- import vercel from '@astrojs/vercel/edge';
+ import vercel from '@astrojs/vercel/serverless';
export default defineConfig({
output: 'server',
adapter: vercel({
+ edgeMiddleware: true
}),
});
```
This adapter had several known limitations and compatibility issues that prevented many people from using it in production. To reduce maintenance costs and because we have a better story with Serveless + Edge Middleware, we are removing the Edge adapter.
The value of `import.meta.env.BASE_URL`, which is derived from the `base` option, will no longer have a trailing slash added by default or when `trailingSlash: "ignore"` is set. The existing behavior of `base` in combination with `trailingSlash: "always"` or `trailingSlash: "never"` is unchanged.
If your `base` already has a trailing slash, no change is needed.
If your `base` does not have a trailing slash, add one to preserve the previous behaviour:
The React integration now fully supports React Refresh and is backed by `@vitejs/plugin-react`.
Also included in this change are new `include` and `exclude` config options. Use these if you want to use React alongside another JSX framework; include specifies files to be compiled for React and `exclude` does the opposite.
Astro is smarter about CSS! Small stylesheets are now inlined by default, and no longer incur the cost of additional requests to your server. Your visitors will have to wait less before they see your pages, especially those in remote locations or in a subway.
This may not be news to you if you had opted-in via the `build.inlineStylesheets` configuration. Stabilized in Astro 2.6 and set to "auto" by default for Starlight, this configuration allows you to reduce the number of requests for stylesheets by inlining them into <style> tags. The new default is "auto", which selects assets smaller than 4kB and includes them in the initial response.
To go back to the previous default behavior, change `build.inlineStylesheets` to "never".
Added support for optimizing remote images from authorized sources when using `astro:assets`. This comes with two new parameters to specify which domains (`image.domains`) and host patterns (`image.remotePatterns`) are authorized for remote images.
For example, the following configuration will only allow remote images from `astro.build` to be optimized:
```ts
// astro.config.mjs
export default defineConfig({
image: {
domains: ["astro.build"],
}
});
```
The following configuration will only allow remote images from HTTPS hosts:
Reduced the amount of polyfills provided by Astro. Astro will no longer provide (no-op) polyfills for several web apis such as HTMLElement, Image or Document. If you need access to those APIs on the server, we recommend using more proper polyfills available on npm.
`@astrojs/netlify/functions` now supports Edge middleware, so a separate adapter for Edge itself (deploying your entire app to the edge) is no longer necessary. Please update your Astro config to reflect this change:
```diff
// astro.config.mjs
import { defineConfig } from 'astro/config';
- import netlify from '@astrojs/netlify/edge';
+ import netlify from '@astrojs/netlify/functions';
export default defineConfig({
output: 'server',
adapter: netlify({
+ edgeMiddleware: true
}),
});
```
This adapter had several known limitations and compatibility issues that prevented many people from using it in production. To reduce maintenance costs and because we have a better story with Serveless + Edge Middleware, we are removing the Edge adapter.
Update `tsconfig.json` presets with `moduleResolution: 'bundler'` and other new options from TypeScript 5.0. Astro now assumes that you use TypeScript 5.0 (March 2023), or that your editor includes it, ex: VS Code 1.77
The `astro check` command now requires an external package `@astrojs/check` and an install of `typescript` in your project. This was done in order to make the main `astro` package smaller and give more flexibility to users in regard to the version of TypeScript they use.
Astro.cookies.get(key) returns undefined if cookie doesn't exist
With this change, Astro.cookies.get(key) no longer always returns a `AstroCookie` object. Instead it now returns `undefined` if the cookie does not exist.
You should update your code if you assume that all calls to `get()` return a value. When using with `has()` you still need to assert the value, like so:
`astro:assets` is now enabled by default. If you were previously using the `experimental.assets` flag, please remove it from your config. Also note that the previous `@astrojs/image` integration is incompatible, and must be removed.
This also brings two important changes to using images in Astro:
- New ESM shape: importing an image will now return an object with different properties describing the image such as its path, format and dimensions. This is a breaking change and may require you to update your existing images.
- In Markdown, MDX, and Markdoc, the `![]()` syntax will now resolve relative images located anywhere in your project in addition to remote images and images stored in the `public/` folder. This notably unlocks storing images next to your content.
Please see our existing [Assets page in Docs](https://docs.astro.build/en/guides/assets/) for more information about using `astro:assets`.
✅ I am using the **latest version of Astro** and all plugins.
✅ I am using a version of Node that Astro supports (`>=18.14.1`)
- type:input
id:astro-version
- type:textarea
id:astro-info
attributes:
label:What version of `astro` are you using?
placeholder:0.0.0
validations:
required:true
- type:input
id:ssr-adapter
attributes:
label:Are you using an SSR adapter? If so, which one?
placeholder:None, or Netlify, Vercel, Cloudflare, etc.
validations:
required:true
- type:input
id:package-manager
attributes:
label:What package manager are you using?
placeholder:npm, yarn, pnpm
validations:
required:true
- type:input
id:os
attributes:
label:What operating system are you using?
placeholder:Mac, Windows, Linux
label:Astro Info
description:Run the command `astro info` in your terminal and paste the output here. Please review the data before submitting in case there is any sensitive information you don't want to share.
render:block
validations:
required:true
- type:input
id:browser
attributes:
label:What browser are you using?
label:If this issue only occurs in one browser, which browser is a problem?