Skip to content

astro@3.0.0

Compare
Choose a tag to compare
@astrobot-houston astrobot-houston released this 30 Aug 11:40
· 1768 commits to main since this release
5598feb

Major Changes

  • #8188 d0679a666 Thanks @ematipico! - 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.

  • #8188 364d861bd Thanks @ematipico! - Removed automatic flattening of getStaticPaths result. .flatMap and .flat should now be used to ensure that you're returning a flat array.

  • #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';
    ---
  • #8142 81545197a Thanks @natemoo-re! - Fixes for the class:list directive

    • Previously, class:list would ocassionally not be merged the class prop when passed to Astro components. Now, class:list is always converted to a class prop (as a string value).
    • Previously, class:list diverged from clsx in a few edge cases. Now, class:list uses clsx directly.
      • class:list used to deduplicate matching values, but it no longer does
      • class:list used to sort individual values, but it no longer does
      • class:list used to support Set and other iterables, but it no longer does
  • #8179 6011d52d3 Thanks @matthewp! - Astro 3.0 Release Candidate

  • #8188 80f1494cd Thanks @ematipico! - The build.split and build.excludeMiddleware configuration options are deprecated and have been replaced by options in the adapter config.

    If your config includes the build.excludeMiddleware option, replace it with edgeMiddleware in your adapter options:

    import { defineConfig } from "astro/config";
    import netlify from "@astrojs/netlify/functions";
    
    export default defineConfig({
         build: {
    -        excludeMiddleware: true
         },
         adapter: netlify({
    +        edgeMiddleware: true
         }),
    });

    If your config includes the build.split option, replace it with functionPerRoute in your adapter options:

    import { defineConfig } from "astro/config";
    import netlify from "@astrojs/netlify/functions";
    
    export default defineConfig({
         build: {
    -        split: true
         },
         adapter: netlify({
    +        functionPerRoute: true
         }),
    });
  • #8207 e45f30293 Thanks @natemoo-re! - Change the View Transition built-in animation options.

    The transition:animate value morph has been renamed to initial. Also, this is no longer the default animation.

    If no transition:animate directive is specified, your animations will now default to fade.

    Astro also supports a new transition:animate value, none. This value can be used on a page's <html> element to disable animated full-page transitions on an entire page.

  • #8188 c0de7a7b0 Thanks @ematipico! - 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:

    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.

  • #8188 3c3100851 Thanks @ematipico! - Remove support for Astro.__renderMarkdown which is used by @astrojs/markdown-component.

    The <Markdown /> component was deprecated in Astro v1 and is completely removed in v3. This integration must now be removed from your project.

    As an alternative, you can use community packages that provide a similar component like https://github.com/natemoo-re/astro-remote instead.

  • #8019 34cb20021 Thanks @bluwy! - 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:

    ---
    const myValue = 'red';
    ---
    
    <!-- input -->
    <div style={{ '--myValue': myValue }}></div>
    
    <!-- output (before) -->
    <div style="--my-value:var(--myValue);--myValue:red"></div>
    
    <!-- output (after) -->
    <div style="--myValue:red"></div>
    <style>
      div {
    -   color: var(--my-value);
    +   color: var(--myValue);
      }
    </style>
  • #8170 be6bbd2c8 Thanks @bluwy! - Remove deprecated config option types, deprecated script/style attributes, and deprecated image export from astro:content

  • #8188 7511a4980 Thanks @ematipico! - 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

  • #7979 dbc97b121 Thanks @bluwy! - 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.

    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);
  • #8188 7d2f311d4 Thanks @ematipico! - Removed support for old syntax of the API routes.

  • #8085 68efd4a8b Thanks @bluwy! - 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:

    - 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',
      // ...
    });
  • #7893 7bd1b86f8 Thanks @ematipico! - Implements a new scope style strategy called "attribute". When enabled, styles are applied using data-* attributes.

    The default value of scopedStyleStrategy is "attribute".

    If you want to use the previous behaviour, you have to use the "where" option:

    import { defineConfig } from 'astro/config';
    
    export default defineConfig({
    +    scopedStyleStrategy: 'where',
    });
  • #7924 519a1c4e8 Thanks @matthewp! - 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.

    export default defineConfig({
      // The `include` config is only needed in projects that use multiple JSX frameworks;
      // if only using one no extra config is needed.
      integrations: [
        preact({
          include: ['**/preact/*'],
        }),
        react({
          include: ['**/react/*'],
        }),
        solid({
          include: ['**/solid/*'],
        }),
      ],
    });
  • #8030 5208a3c8f Thanks @natemoo-re! - Removed duplicate astro/dist/jsx export. Please use the astro/jsx export instead

  • #8188 84af8ed9d Thanks @ematipico! - Remove MDX plugin re-ordering hack

  • #8180 f003e7364 Thanks @ematipico! - The scoped hash created by the Astro compiler is now lowercase.

  • #7878 0f637c71e Thanks @bluwy! - 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:

    // astro.config.mjs
    - base: 'my-base',
    + base: 'my-base/',
  • #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',
      },
    });
  • #8188 148e61d24 Thanks @ematipico! - 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.

  • #8169 e79e3779d Thanks @bluwy! - Remove pre-shiki v0.14 theme names for compatibility. Please rename to the new theme names to migrate:

    • material-darker -> material-theme-darker
    • material-default -> material-theme
    • material-lighter -> material-theme-lighter
    • material-ocean -> material-theme-ocean
    • material-palenight -> material-theme-palenight
  • #8188 96beb883a Thanks @ematipico! - 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

  • #8188 997a0db8a Thanks @ematipico! - 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.

  • #8188 80f1494cd Thanks @ematipico! - The build.split and build.excludeMiddleware configuration options are deprecated and have been replaced by options in the adapter config.

    If your config includes the build.excludeMiddleware option, replace it with edgeMiddleware in your adapter options:

    import { defineConfig } from "astro/config";
    import vercel from "@astrojs/vercel/serverless";
    
    export default defineConfig({
         build: {
    -        excludeMiddleware: true
         },
         adapter: vercel({
    +        edgeMiddleware: true
         }),
    });

    If your config includes the build.split option, replace it with functionPerRoute in your adapter options:

    import { defineConfig } from "astro/config";
    import vercel from "@astrojs/vercel/serverless";
    
    export default defineConfig({
         build: {
    -        split: true
         },
         adapter: vercel({
    +        functionPerRoute: true
         }),
    });
  • #8188 0f0625504 Thanks @ematipico! - Lowercase names for endpoint functions are now deprecated.

    Rename functions to their uppercase equivalent:

    - export function get() {
    + export function GET() {
        return new Response(JSON.stringify({ "title": "Bob's blog" }));
    }
    
    - export function post() {
    + export function POST() {
        return new Response(JSON.stringify({ "title": "Bob's blog" }));
    }
    
    - export function put() {
    + export function PUT() {
        return new Response(JSON.stringify({ "title": "Bob's blog" }));
    }
    
    - export function all() {
    + export function ALL() {
        return new Response(JSON.stringify({ "title": "Bob's blog" }));
    }
    
    // you can use the whole word "DELETE"
    - export function del() {
    + export function DELETE() {
        return new Response(JSON.stringify({ "title": "Bob's blog" }));
    }
  • #8188 e1ae56e72 Thanks @ematipico! - 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:

    ---
    if (Astro.cookies.has(id)) {
      const id = Astro.cookies.get(id)!;
    }
    ---
  • #8188 f32d093a2 Thanks @ematipico! - The property compressHTML is now true by default. Setting this value to true is no longer required.

    If you do not want to minify your HTML output, you must set this value to false in astro.config.mjs.

    import {defineConfig} from "astro/config";
    export default defineConfig({
    +  compressHTML: false
    })
  • #8188 f01eb585e Thanks @ematipico! - Astro's default port when running the dev or preview server is now 4321.

    This will reduce conflicts with ports used by other tools.

  • #7921 b76c166bd Thanks @Princesseuh! - 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 for more information about using astro:assets.

  • #8188 32669cd47 Thanks @ematipico! - Remove MDX special components export handling

Minor Changes

  • #8188 cd2d7e769 Thanks @ematipico! - Introduced the concept of feature map. A feature map is a list of features that are built-in in Astro, and an Adapter
    can tell Astro if it can support it.

    import { AstroIntegration } from './astro';
    
    function myIntegration(): AstroIntegration {
      return {
        name: 'astro-awesome-list',
        // new feature map
        supportedAstroFeatures: {
          hybridOutput: 'experimental',
          staticOutput: 'stable',
          serverOutput: 'stable',
          assets: {
            supportKind: 'stable',
            isSharpCompatible: false,
            isSquooshCompatible: false,
          },
        },
      };
    }
  • #8218 44f7a2872 Thanks @matthewp! - View Transitions unflagged

    View Transition support in Astro is now unflagged. For those who have used the experimental feature you can remove the flag in your Astro config:

    import { defineConfig } from 'astro'
    
    export default defineConfig({
    -  experimental: {
    -    viewTransitions: true,
    -  }
    })

    After removing this flag, please also consult the specific upgrade to v3.0 advice as some API features have changed and you may have breaking changes with your existing view transitions.

    See the View Transitions guide to learn how to use the API.

  • #8101 ea7ff5177 Thanks @matthewp! - 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.

  • #8188 036388f66 Thanks @ematipico! - Integrations can now log messages using Astro’s built-in logger.

    The logger is available to all hooks as an additional parameter:

    import { AstroIntegration } from './astro';
    
    // integration.js
    export function myIntegration(): AstroIntegration {
      return {
        name: 'my-integration',
        hooks: {
          'astro:config:done': ({ logger }) => {
            logger.info('Configure integration...');
          },
        },
      };
    }
  • #8181 a8f35777e Thanks @matthewp! - Finalize View Transition event names

  • #8012 866ed4098 Thanks @ematipico! - Add a new astro/errors module. Developers can import AstroUserError, and provide a message and an optional hint

Patch Changes

  • #8139 db39206cb Thanks @Princesseuh! - Use undici for File changeset for Node 16 compatibility

  • #8188 adf9fccfd Thanks @ematipico! - Do not throw Error when users pass an object with a "type" property

  • #8234 0c7b42dc6 Thanks @natemoo-re! - Update telemetry notice

  • #8251 46c4c0e05 Thanks @Princesseuh! - Adds a link to the error reference in the CLI when an error occurs

  • #8128 c2c71d90c Thanks @Princesseuh! - Update error message when Sharp couldn't be found (tends to happen on pnpm notably)

  • #7998 65c354969 Thanks @bluwy! - Call astro sync once before calling astro check

  • #8232 a824863ab Thanks @matthewp! - Use .js to import logger

  • #8253 1048aca55 Thanks @matthewp! - Fix, lazily initialize ResponseWithEncoding

  • #8263 9e021a91c Thanks @Princesseuh! - Add a type param to AstroGlobal to type params. This will eventually be used automatically by our tooling to provide typing and completions for Astro.params

  • #8217 c37632a20 Thanks @martrapp! - Specify data-astro-reload (no value) on an anchor element to force the browser to ignore view transitions and fall back to default loading.

    This is helpful when navigating to documents that have different content-types, e.g. application/pdf, where you want to use the build in viewer of the browser.
    Example: <a href='/my.pdf' data-astro-reload>...</a>

  • #8156 acf652fc1 Thanks @kurtextrem! - The scrollend mechanism is a better way to record the scroll position compared to throttling, so we now use it whenever a browser supports it.

  • #8188 42785c7b7 Thanks @ematipico! - Improve fidelity of time stats when running astro build

  • #8266 8450379db Thanks @Princesseuh! - Fix image.service requiring to be set manually when image.domains or image.remotePatterns was assigned a value

  • #8078 2540feedb Thanks @alexanderniebuhr! - Reimplement #7509 to correctly emit pre-rendered pages now that build.split is deprecated and this configuration has been moved to functionPerRoute inside the adapter.

  • #8264 1f58a7a1b Thanks @natemoo-re! - Fire astro:unmount event when island is disconnected

  • #8188 2ae9d37f0 Thanks @ematipico! - Open to configured base when astro dev --open runs

  • #8188 70f34f5a3 Thanks @ematipico! - Remove StreamingCompatibleResponse polyfill

  • #8229 ffc9e2d3d Thanks @Princesseuh! - Paginate will now return exact types instead of a naive Record

  • #8099 732111cdc Thanks @bluwy! - Deprecate the markdown.drafts configuration option.

    If you'd like to create draft pages that are visible in dev but not in production, you can migrate to content collections and manually filter out pages with the draft: true frontmatter property instead.

  • #8188 33b8910cf Thanks @ematipico! - On back navigation only animate view transitions that were animated going forward.

  • #8196 632579dc2 Thanks @bluwy! - Prevent bundling sharp as it errors in runtime

  • #8237 3674584e0 Thanks @Princesseuh! - Fix astro check not finding the @astrojs/check package

  • #8258 1db4e92c1 Thanks @matthewp! - Allow fallback animations on html element

  • #8270 e7f872e91 Thanks @matthewp! - Prevent ViewTransition script from being added by mistake

  • #8271 16f09dfff Thanks @matthewp! - Fix video persistence regression

  • #8072 4477bb41c Thanks @matthewp! - Update Astro types to reflect that compress defaults to true

  • #8214 55c10d1d5 Thanks @Princesseuh! - Automatically update user's env.d.ts with the proper types to help out migrating away from assets being experimental

  • #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.

  • #8188 a87cbe400 Thanks @ematipico! - fix: reinsert attribute to specify direction of ViewTransition (forward / back)

  • #8132 767eb6866 Thanks @bluwy! - Deprecate returning simple objects from endpoints. Endpoints should only return a Response.

    To return a result with a custom encoding not supported by a Response, you can use the ResponseWithEncoding utility class instead.

    Before:

    export function GET() {
      return {
        body: '...',
        encoding: 'binary',
      };
    }

    After:

    export function GET({ ResponseWithEncoding }) {
      return new ResponseWithEncoding('...', undefined, 'binary');
    }
  • Updated dependencies [d0679a666, 2aa6d8ace, 0c7b42dc6, 6011d52d3, e79e3779d, 3e834293d, b675acb2a]:

    • @astrojs/telemetry@3.0.0
    • @astrojs/internal-helpers@0.2.0
    • @astrojs/markdown-remark@3.0.0