Skip to content

Commit

Permalink
Unflag View Transition support (#8218)
Browse files Browse the repository at this point in the history
* Unflag View Transition support

* Add a changeset

* Update .changeset/grumpy-pens-melt.md

Co-authored-by: Sarah Rainsberger <[email protected]>

---------

Co-authored-by: Sarah Rainsberger <[email protected]>
  • Loading branch information
matthewp and sarah11918 authored Aug 25, 2023
1 parent 3bae77d commit 44f7a28
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 47 deletions.
21 changes: 21 additions & 0 deletions .changeset/grumpy-pens-melt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
'astro': minor
---

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:

```diff
import { defineConfig } from 'astro'

export default defineConfig({
- experimental: {
- viewTransitions: true,
- }
})
```

After removing this flag, please also consult the specific [upgrade to v3.0 advice](https://docs.astro.build/en/guides/view-transitions/#upgrade-to-v30-from-v2x) as some API features have changed and you may have breaking changes with your existing view transitions.

See the [View Transitions guide](https://docs.astro.build/en/guides/view-transitions/) to learn how to use the API.
3 changes: 0 additions & 3 deletions packages/astro/e2e/fixtures/view-transitions/astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ export default defineConfig({
output: 'server',
adapter: nodejs({ mode: 'standalone' }),
integrations: [react()],
experimental: {
viewTransitions: true,
},
vite: {
build: {
assetsInlineLimit: 0,
Expand Down
21 changes: 0 additions & 21 deletions packages/astro/src/@types/astro.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1282,27 +1282,6 @@ export interface AstroUserConfig {
* These flags are not guaranteed to be stable.
*/
experimental?: {
/**
* @docs
* @name experimental.viewTransitions
* @type {boolean}
* @default `false`
* @version 2.9.0
* @description
* Enable experimental support for the `<ViewTransitions / >` component. With this enabled
* you can opt-in to [view transitions](https://docs.astro.build/en/guides/view-transitions/) on a per-page basis using this component
* and enable animations with the `transition:animate` directive.
*
* ```js
* {
* experimental: {
* viewTransitions: true,
* },
* }
* ```
*/
viewTransitions?: boolean;

/**
* @docs
* @name experimental.optimizeHoistedScript
Expand Down
5 changes: 0 additions & 5 deletions packages/astro/src/core/config/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ const ASTRO_CONFIG_DEFAULTS = {
legacy: {},
redirects: {},
experimental: {
viewTransitions: false,
optimizeHoistedScript: false,
},
} satisfies AstroUserConfig & { server: { open: boolean } };
Expand Down Expand Up @@ -264,10 +263,6 @@ export const AstroConfigSchema = z.object({
.default(ASTRO_CONFIG_DEFAULTS.vite),
experimental: z
.object({
viewTransitions: z
.boolean()
.optional()
.default(ASTRO_CONFIG_DEFAULTS.experimental.viewTransitions),
optimizeHoistedScript: z
.boolean()
.optional()
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/core/create-vite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ export async function createVite(
astroContentAssetPropagationPlugin({ mode, settings }),
vitePluginSSRManifest(),
astroAssetsPlugin({ settings, logger, mode }),
astroTransitions({ config: settings.config }),
astroTransitions(),
],
publicDir: fileURLToPath(settings.config.publicDir),
root: fileURLToPath(settings.config.root),
Expand Down
18 changes: 1 addition & 17 deletions packages/astro/src/transitions/vite-plugin-transitions.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import * as vite from 'vite';
import type { AstroConfig } from '../@types/astro';
import { AstroError } from '../core/errors/index.js';

const virtualModuleId = 'astro:transitions';
const resolvedVirtualModuleId = '\0' + virtualModuleId;

// The virtual module for the astro:transitions namespace
export default function astroTransitions({ config }: { config: AstroConfig }): vite.Plugin {
export default function astroTransitions(): vite.Plugin {
return {
name: 'astro:transitions',
async resolveId(id) {
Expand All @@ -16,20 +14,6 @@ export default function astroTransitions({ config }: { config: AstroConfig }): v
},
load(id) {
if (id === resolvedVirtualModuleId) {
if (!config.experimental.viewTransitions) {
throw new AstroError({
name: 'TransitionError',
title: 'Experimental View Transitions not enabled',
message: `View Transitions support is experimental. To enable update your config to include:
export default defineConfig({
experimental: {
viewTransitions: true
}
})`,
});
}

return `
export * from "astro/transitions";
export { default as ViewTransitions } from "astro/components/ViewTransitions.astro";
Expand Down

0 comments on commit 44f7a28

Please sign in to comment.