astro@3.0.0-beta.3
版本发布时间: 2023-08-18 23:50:03
withastro/astro最新发布版本:astro@5.0.0-beta.2(2024-09-24 17:12:05)
Major Changes
-
#8113
2484dc408
Thanks @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
dbc97b121
Thanks @bluwy! - Export experimentaldev
,build
,preview
, andsync
APIs 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
68efd4a8b
Thanks @bluwy! - Remove exports forastro/internal/*
andastro/runtime/server/*
in favour ofastro/runtime/*
. Add newastro/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:
- 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
5208a3c8f
Thanks @natemoo-re! - Removed duplicateastro/dist/jsx
export. Please use theastro/jsx
export instead -
#8118
8a5b0c1f3
Thanks @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.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".import { defineConfig } from 'astro/config'; export default defineConfig({ build: { inlineStylesheets: 'never', }, });
-
#7921
b76c166bd
Thanks @Princesseuh! -astro:assets
is now enabled by default. If you were previously using theexperimental.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 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
ea7ff5177
Thanks @matthewp! -astro:
namespace aliases for middleware and componentsThis adds aliases of
astro:middleware
andastro: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.
Patch Changes
-
#8128
c2c71d90c
Thanks @Princesseuh! - Update error message when Sharp couldn't be found (tends to happen on pnpm notably) -
#8092
7177f7579
Thanks @natemoo-re! - Ensure dotfiles are cleaned during static builds -
#8070
097a8e4e9
Thanks @lilnasy! - Fix a handful of edge cases with prerendered 404/500 pages -
#8078
2540feedb
Thanks @alexanderniebuhr! - Reimplement https://github.com/withastro/astro/pull/7509 to correctly emit pre-rendered pages now thatbuild.split
is deprecated and this configuration has been moved tofunctionPerRoute
inside the adapter. -
#8105
0e0fa605d
Thanks @martrapp! - ViewTransition: bug fix for lost scroll position in browser history -
#7778
d6b494376
Thanks @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.build
to 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
4477bb41c
Thanks @matthewp! - Update Astro types to reflect that compress defaults to true -
#8130
3e834293d
Thanks @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