Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deprecated APIs #8170

Merged
merged 1 commit into from
Aug 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/happy-penguins-hug.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': major
---

Remove deprecated config option types, deprecated script/style attributes, and deprecated `image` export from `astro:content`
19 changes: 0 additions & 19 deletions packages/astro/content-types.template.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,6 @@ declare module 'astro:content' {
type Flatten<T> = T extends { [K: string]: infer U } ? U : never;
export type CollectionEntry<C extends keyof AnyEntryMap> = Flatten<AnyEntryMap[C]>;

// 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;
Expand Down
27 changes: 0 additions & 27 deletions packages/astro/src/@types/astro.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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
Expand Down
61 changes: 0 additions & 61 deletions packages/astro/src/core/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<AstroConfig> {
// 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
Expand Down
Loading