astro 3.0.0-beta.3
Major Changes
-
#8113
2484dc408Thanks @Princesseuh! - 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.--- // src/pages/posts/post-1.astro - import rocket from '~/assets/rocket.png' + import rocket from '../../assets/rocket.png'; --- -
#7979
dbc97b121Thanks @bluwy! - Export experimentaldev,build,preview, andsyncAPIs fromastro. 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.
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. const inlineConfig: AstroInlineConfig = { // Inline-specific options... configFile: './astro.config.mjs', logLevel: 'info', // Standard Astro config options... site: 'https://example.com', }; // Start the Astro dev server const devServer = await dev(inlineConfig); await devServer.stop(); // Build your Astro project await build(inlineConfig); // Preview your built project const previewServer = await preview(inlineConfig); await previewServer.stop(); // Generate types for your Astro project await sync(inlineConfig); -
#8085
68efd4a8bThanks @bluwy! - Remove exports forastro/internal/*andastro/runtime/server/*in favour ofastro/runtime/*. Add newastro/compiler-runtimeexport 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:
- import 'astro/internal/index.js'; + import 'astro/runtime/server/index.js'; - import 'astro/server/index.js'; + import 'astro/runtime/server/index.js';import { transform } from '@astrojs/compiler'; const result = await transform(source, { - internalURL: 'astro/runtime/server/index.js', + internalURL: 'astro/compiler-runtime', // ... }); -
#8030
5208a3c8fThanks @natemoo-re! - Removed duplicateastro/dist/jsxexport. Please use theastro/jsxexport instead -
#8118
8a5b0c1f3Thanks @lilnasy! - 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.inlineStylesheetsconfiguration. 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 intoTo go back to the previous default behavior, change
build.inlineStylesheetsto "never".import { defineConfig } from 'astro/config'; export default defineConfig({ build: { inlineStylesheets: 'never', }, }); -
#7921
b76c166bdThanks @Princesseuh! -astro:assetsis now enabled by default. If you were previously using theexperimental.assetsflag, please remove it from your config. Also note that the previous@astrojs/imageintegration 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 thepublic/folder. This notably unlocks storing images next to your content.
Please see our existing Assets page in Docs for more information about using
astro:assets.
Minor Changes
-
#8101
ea7ff5177Thanks @matthewp! -astro:namespace aliases for middleware and componentsThis adds aliases of
astro:middlewareandastro:componentsfor 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.
Patch Changes
-
#8128
c2c71d90cThanks @Princesseuh! - Update error message when Sharp couldn't be found (tends to happen on pnpm notably) -
#8092
7177f7579Thanks @natemoo-re! - Ensure dotfiles are cleaned during static builds -
#8070
097a8e4e9Thanks @lilnasy! - Fix a handful of edge cases with prerendered 404/500 pages -
#8078
2540feedbThanks @alexanderniebuhr! - Reimplement https://github.com/withastro/astro/pull/7509 to correctly emit pre-rendered pages now thatbuild.splitis deprecated and this configuration has been moved tofunctionPerRouteinside the adapter. -
#8105
0e0fa605dThanks @martrapp! - ViewTransition: bug fix for lost scroll position in browser history -
#7778
d6b494376Thanks @y-nk! - Added support for optimizing remote images from authorized sources when usingastro: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.buildto be optimized:// astro.config.mjs export default defineConfig({ image: { domains: ['astro.build'], }, });The following configuration will only allow remote images from HTTPS hosts:
// astro.config.mjs export default defineConfig({ image: { remotePatterns: [{ protocol: 'https' }], }, }); -
#8072
4477bb41cThanks @matthewp! - Update Astro types to reflect that compress defaults to true -
#8130
3e834293dThanks @Princesseuh! - Add some polyfills for Stackblitz until they support Node 18. Running Astro on Node 16 is still not officially supported, however. -
Updated dependencies [
3e834293d]:- @astrojs/telemetry@3.0.0-beta.2