From 281cf1e580ddf7bb3389714dc86dc721c1d2a865 Mon Sep 17 00:00:00 2001 From: Rizumu Ayaka Date: Thu, 16 Oct 2025 17:26:30 +0800 Subject: [PATCH 1/3] feat: deprecated API alert --- build/plugins/comfyAPIPlugin.ts | 54 +++++++++++++++++++++++++++++++-- 1 file changed, 52 insertions(+), 2 deletions(-) diff --git a/build/plugins/comfyAPIPlugin.ts b/build/plugins/comfyAPIPlugin.ts index 5b7f4bec42..cd13789881 100644 --- a/build/plugins/comfyAPIPlugin.ts +++ b/build/plugins/comfyAPIPlugin.ts @@ -6,6 +6,41 @@ interface ShimResult { exports: string[] } +type DeprecationInfo = + | { + /** Replacement API or migration guide text */ + replacement: string + /** Version when this will be removed (e.g., 'v2.0.0') */ + removeVersion: string + /** URL to migration guide (optional) */ + migrationUrl?: string + + skip?: false + } + | { + skip: true + } + +/** + * Map of deprecated file paths to their deprecation info. + * Key format: relative path from src/ without extension + */ +const deprecatedFiles: Record = { + all: { + removeVersion: 'v1.33', + // TODO: Update this + replacement: 'Use the new API instead', + // TODO: Update this + migrationUrl: 'https://comfy.org' + }, + 'scripts/app': { + skip: true + }, + 'scripts/api': { + skip: true + } +} + function isLegacyFile(id: string): boolean { return ( id.endsWith('.ts') && @@ -63,12 +98,27 @@ export function comfyAPIPlugin(isDev: boolean): Plugin { const relativePath = path.relative(path.join(projectRoot, 'src'), id) const shimFileName = relativePath.replace(/\.ts$/, '.js') - const shimComment = `// Shim for ${relativePath}\n` + let shimContent = `// Shim for ${relativePath}\n` + + const fileKey = relativePath.replace(/\.ts$/, '').replace(/\\/g, '/') + const deprecationInfo = + deprecatedFiles[fileKey] || deprecatedFiles['all'] + if (deprecationInfo && deprecationInfo.skip != true) { + let warningMessage = `[ComfyUI Deprecated] Importing from ${shimFileName} is deprecated. ${deprecationInfo.replacement}. This will be removed in ${deprecationInfo.removeVersion}.` + + if (deprecationInfo.migrationUrl) { + warningMessage += ` See: ${deprecationInfo.migrationUrl}` + } + + shimContent += `console.warn('${warningMessage}');\n` + } + + shimContent += result.exports.join('') this.emitFile({ type: 'asset', fileName: shimFileName, - source: shimComment + result.exports.join('') + source: shimContent }) } From de82f05f349e101e558255440c53e87f06808ec2 Mon Sep 17 00:00:00 2001 From: Rizumu Ayaka Date: Fri, 17 Oct 2025 19:58:12 +0800 Subject: [PATCH 2/3] internal api and remove in 1.34 --- build/plugins/comfyAPIPlugin.ts | 54 +++++++++------------------------ 1 file changed, 15 insertions(+), 39 deletions(-) diff --git a/build/plugins/comfyAPIPlugin.ts b/build/plugins/comfyAPIPlugin.ts index cd13789881..364f82e74e 100644 --- a/build/plugins/comfyAPIPlugin.ts +++ b/build/plugins/comfyAPIPlugin.ts @@ -6,39 +6,21 @@ interface ShimResult { exports: string[] } -type DeprecationInfo = - | { - /** Replacement API or migration guide text */ - replacement: string - /** Version when this will be removed (e.g., 'v2.0.0') */ - removeVersion: string - /** URL to migration guide (optional) */ - migrationUrl?: string - - skip?: false - } - | { - skip: true - } +const SKIP_WARNING_FILES = new Set(['scripts/app', 'scripts/api']) + +function getWarningMessage( + fileKey: string, + shimFileName: string +): string | null { + if (SKIP_WARNING_FILES.has(fileKey)) { + return null + } -/** - * Map of deprecated file paths to their deprecation info. - * Key format: relative path from src/ without extension - */ -const deprecatedFiles: Record = { - all: { - removeVersion: 'v1.33', - // TODO: Update this - replacement: 'Use the new API instead', - // TODO: Update this - migrationUrl: 'https://comfy.org' - }, - 'scripts/app': { - skip: true - }, - 'scripts/api': { - skip: true + if (fileKey.startsWith('scripts/ui/')) { + return `[ComfyUI Deprecated] Importing from "${shimFileName}" is deprecated and will be removed in v1.34.` } + + return `[ComfyUI Notice] "${shimFileName}" is an internal module, not part of the public API. Future updates may break this import.` } function isLegacyFile(id: string): boolean { @@ -101,15 +83,9 @@ export function comfyAPIPlugin(isDev: boolean): Plugin { let shimContent = `// Shim for ${relativePath}\n` const fileKey = relativePath.replace(/\.ts$/, '').replace(/\\/g, '/') - const deprecationInfo = - deprecatedFiles[fileKey] || deprecatedFiles['all'] - if (deprecationInfo && deprecationInfo.skip != true) { - let warningMessage = `[ComfyUI Deprecated] Importing from ${shimFileName} is deprecated. ${deprecationInfo.replacement}. This will be removed in ${deprecationInfo.removeVersion}.` - - if (deprecationInfo.migrationUrl) { - warningMessage += ` See: ${deprecationInfo.migrationUrl}` - } + const warningMessage = getWarningMessage(fileKey, shimFileName) + if (warningMessage) { shimContent += `console.warn('${warningMessage}');\n` } From 8aa073718830aab4275a6132952800ac75e7f3fe Mon Sep 17 00:00:00 2001 From: Rizumu Ayaka Date: Mon, 20 Oct 2025 13:41:19 +0900 Subject: [PATCH 3/3] add more deprecated files --- build/plugins/comfyAPIPlugin.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/build/plugins/comfyAPIPlugin.ts b/build/plugins/comfyAPIPlugin.ts index 364f82e74e..3e9a9e5b98 100644 --- a/build/plugins/comfyAPIPlugin.ts +++ b/build/plugins/comfyAPIPlugin.ts @@ -8,6 +8,13 @@ interface ShimResult { const SKIP_WARNING_FILES = new Set(['scripts/app', 'scripts/api']) +/** Files that will be removed in v1.34 */ +const DEPRECATED_FILES = [ + 'scripts/ui', + 'extensions/core/maskEditorOld', + 'extensions/core/groupNode' +] as const + function getWarningMessage( fileKey: string, shimFileName: string @@ -16,7 +23,11 @@ function getWarningMessage( return null } - if (fileKey.startsWith('scripts/ui/')) { + const isDeprecated = DEPRECATED_FILES.some((deprecatedPath) => + fileKey.startsWith(deprecatedPath) + ) + + if (isDeprecated) { return `[ComfyUI Deprecated] Importing from "${shimFileName}" is deprecated and will be removed in v1.34.` } @@ -86,6 +97,7 @@ export function comfyAPIPlugin(isDev: boolean): Plugin { const warningMessage = getWarningMessage(fileKey, shimFileName) if (warningMessage) { + // It will only display once because it is at the root of the file. shimContent += `console.warn('${warningMessage}');\n` }