From be6bbd2c86b9bf5268e765bb937dda00ff15781a Mon Sep 17 00:00:00 2001 From: Bjorn Lu Date: Mon, 21 Aug 2023 21:04:15 +0800 Subject: [PATCH] Remove deprecated APIs (#8170) --- .changeset/happy-penguins-hug.md | 5 ++ packages/astro/content-types.template.d.ts | 19 ------- packages/astro/src/@types/astro.ts | 27 ---------- packages/astro/src/core/config/config.ts | 61 ---------------------- 4 files changed, 5 insertions(+), 107 deletions(-) create mode 100644 .changeset/happy-penguins-hug.md diff --git a/.changeset/happy-penguins-hug.md b/.changeset/happy-penguins-hug.md new file mode 100644 index 000000000000..215031769837 --- /dev/null +++ b/.changeset/happy-penguins-hug.md @@ -0,0 +1,5 @@ +--- +'astro': major +--- + +Remove deprecated config option types, deprecated script/style attributes, and deprecated `image` export from `astro:content` diff --git a/packages/astro/content-types.template.d.ts b/packages/astro/content-types.template.d.ts index cf825c25eee8..bcd839f78390 100644 --- a/packages/astro/content-types.template.d.ts +++ b/packages/astro/content-types.template.d.ts @@ -14,25 +14,6 @@ declare module 'astro:content' { type Flatten = T extends { [K: string]: infer U } ? U : never; export type CollectionEntry = Flatten; - // TODO: Remove this when having this fallback is no longer relevant. 2.3? 3.0? - erika, 2023-04-04 - /** - * @deprecated - * `astro:content` no longer provide `image()`. - * - * Please use it through `schema`, like such: - * ```ts - * import { defineCollection, z } from "astro:content"; - * - * defineCollection({ - * schema: ({ image }) => - * z.object({ - * image: image(), - * }), - * }); - * ``` - */ - export const image: never; - // This needs to be in sync with ImageMetadata export type ImageFunction = () => import('astro/zod').ZodObject<{ src: import('astro/zod').ZodString; diff --git a/packages/astro/src/@types/astro.ts b/packages/astro/src/@types/astro.ts index 1d8875b4b0b3..4e50d4cc78b3 100644 --- a/packages/astro/src/@types/astro.ts +++ b/packages/astro/src/@types/astro.ts @@ -104,15 +104,11 @@ export interface AstroDefineVarsAttribute { } export interface AstroStyleAttributes { - /** @deprecated Use `is:global` instead */ - global?: boolean; 'is:global'?: boolean; 'is:inline'?: boolean; } export interface AstroScriptAttributes { - /** @deprecated Hoist is now the default behavior */ - hoist?: boolean; 'is:inline'?: boolean; } @@ -1342,29 +1338,6 @@ export interface AstroUserConfig { */ optimizeHoistedScript?: boolean; }; - - // Legacy options to be removed - - /** @deprecated - Use "integrations" instead. Run Astro to learn more about migrating. */ - renderers?: never; - /** @deprecated `projectRoot` has been renamed to `root` */ - projectRoot?: never; - /** @deprecated `src` has been renamed to `srcDir` */ - src?: never; - /** @deprecated `pages` has been removed. It is no longer configurable. */ - pages?: never; - /** @deprecated `public` has been renamed to `publicDir` */ - public?: never; - /** @deprecated `dist` has been renamed to `outDir` */ - dist?: never; - /** @deprecated `styleOptions` has been renamed to `style` */ - styleOptions?: never; - /** @deprecated `markdownOptions` has been renamed to `markdown` */ - markdownOptions?: never; - /** @deprecated `buildOptions` has been renamed to `build` */ - buildOptions?: never; - /** @deprecated `devOptions` has been renamed to `server` */ - devOptions?: never; } // NOTE(fks): We choose to keep our hand-generated AstroUserConfig interface so that diff --git a/packages/astro/src/core/config/config.ts b/packages/astro/src/core/config/config.ts index ba089c9a7727..16c7d28bcdaa 100644 --- a/packages/astro/src/core/config/config.ts +++ b/packages/astro/src/core/config/config.ts @@ -20,73 +20,12 @@ import { mergeConfig } from './merge.js'; import { createRelativeSchema } from './schema.js'; import { loadConfigWithVite } from './vite-load.js'; -const LEGACY_ASTRO_CONFIG_KEYS = new Set([ - 'projectRoot', - 'src', - 'pages', - 'public', - 'dist', - 'styleOptions', - 'markdownOptions', - 'buildOptions', - 'devOptions', -]); - /** Turn raw config values into normalized values */ export async function validateConfig( userConfig: any, root: string, cmd: string ): Promise { - // Manual deprecation checks - /* eslint-disable no-console */ - if (userConfig.hasOwnProperty('renderers')) { - console.error('Astro "renderers" are now "integrations"!'); - console.error('Update your configuration and install new dependencies:'); - try { - const rendererKeywords = userConfig.renderers.map((r: string) => - r.replace('@astrojs/renderer-', '') - ); - const rendererImports = rendererKeywords - .map((r: string) => ` import ${r} from '@astrojs/${r === 'solid' ? 'solid-js' : r}';`) - .join('\n'); - const rendererIntegrations = rendererKeywords.map((r: string) => ` ${r}(),`).join('\n'); - console.error(''); - console.error(colors.dim(' // astro.config.js')); - if (rendererImports.length > 0) { - console.error(colors.green(rendererImports)); - } - console.error(''); - console.error(colors.dim(' // ...')); - if (rendererIntegrations.length > 0) { - console.error(colors.green(' integrations: [')); - console.error(colors.green(rendererIntegrations)); - console.error(colors.green(' ],')); - } else { - console.error(colors.green(' integrations: [],')); - } - console.error(''); - } catch (err) { - // We tried, better to just exit. - } - process.exit(1); - } - - let legacyConfigKey: string | undefined; - for (const key of Object.keys(userConfig)) { - if (LEGACY_ASTRO_CONFIG_KEYS.has(key)) { - legacyConfigKey = key; - break; - } - } - if (legacyConfigKey) { - throw new AstroError({ - ...AstroErrorData.ConfigLegacyKey, - message: AstroErrorData.ConfigLegacyKey.message(legacyConfigKey), - }); - } - /* eslint-enable no-console */ - const AstroConfigRelativeSchema = createRelativeSchema(cmd, root); // First-Pass Validation