From 8bb8560557e71c29b683965cedfb936cc7c48d13 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Fri, 10 Apr 2026 10:19:51 +0200 Subject: [PATCH] frontend-plugin-api: always warn on deprecated config.schema with call site Instead of a one-time warning, emit a deprecation warning every time an extension is created using the deprecated `config.schema` option, including the call site location to help track down each usage. Signed-off-by: Patrik Oldsberg Made-with: Cursor --- .../src/schema/createPortableSchema.ts | 20 ++++++++----------- .../src/wiring/createExtension.ts | 3 ++- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/packages/frontend-plugin-api/src/schema/createPortableSchema.ts b/packages/frontend-plugin-api/src/schema/createPortableSchema.ts index c2b816bb29..0abd3224fa 100644 --- a/packages/frontend-plugin-api/src/schema/createPortableSchema.ts +++ b/packages/frontend-plugin-api/src/schema/createPortableSchema.ts @@ -323,17 +323,13 @@ function formatStandardIssue( return `${message} at '${path}'`; } -let hasWarnedConfigSchemaProp = false; - /** @internal */ -export function warnConfigSchemaPropDeprecation() { - if (!hasWarnedConfigSchemaProp) { - hasWarnedConfigSchemaProp = true; - // eslint-disable-next-line no-console - console.warn( - 'DEPRECATION WARNING: The `config.schema` option for extension config is deprecated. ' + - 'Use the `configSchema` option instead with Standard Schema values, for example ' + - '`configSchema: { title: z.string() }` using zod v3.25+ or v4.', - ); - } +export function warnConfigSchemaPropDeprecation(callSite: string) { + // eslint-disable-next-line no-console + console.warn( + `DEPRECATION WARNING: The \`config.schema\` option for extension config is deprecated. ` + + `Use the \`configSchema\` option instead with Standard Schema values, for example ` + + `\`configSchema: { title: z.string() }\` using zod v3.25+ or v4. ` + + `Declared at ${callSite}`, + ); } diff --git a/packages/frontend-plugin-api/src/wiring/createExtension.ts b/packages/frontend-plugin-api/src/wiring/createExtension.ts index 2bcb47d50b..643b4dac1d 100644 --- a/packages/frontend-plugin-api/src/wiring/createExtension.ts +++ b/packages/frontend-plugin-api/src/wiring/createExtension.ts @@ -31,6 +31,7 @@ import { createConfigSchema, warnConfigSchemaPropDeprecation, } from '../schema/createPortableSchema'; +import { describeParentCallSite } from '../routing/describeParentCallSite'; import { type StandardSchemaV1 } from '@standard-schema/spec'; import { OpaqueExtensionDefinition } from '@internal/frontend'; import { ExtensionDataContainer } from './types'; @@ -646,7 +647,7 @@ export function createExtension( const schemaDeclaration = options.configSchema ?? (options.config?.schema as any); if (options.config?.schema) { - warnConfigSchemaPropDeprecation(); + warnConfigSchemaPropDeprecation(describeParentCallSite()); } const resolvedConfigSchema = schemaDeclaration && createConfigSchema(schemaDeclaration);