From d5b078df9322d61520a5f4a786209348472072cb Mon Sep 17 00:00:00 2001 From: logonoff Date: Thu, 19 Mar 2026 00:26:29 -0400 Subject: [PATCH] CONSOLE-5135: add deprecation warning --- .../CHANGELOG-webpack.md | 5 ++++- .../src/shared-modules/shared-modules-meta.ts | 15 +++++++++---- .../src/webpack/ConsoleRemotePlugin.ts | 22 +++++++++++++++++++ 3 files changed, 37 insertions(+), 5 deletions(-) diff --git a/frontend/packages/console-dynamic-plugin-sdk/CHANGELOG-webpack.md b/frontend/packages/console-dynamic-plugin-sdk/CHANGELOG-webpack.md index da1c556085c..dbe4ac3bcf5 100644 --- a/frontend/packages/console-dynamic-plugin-sdk/CHANGELOG-webpack.md +++ b/frontend/packages/console-dynamic-plugin-sdk/CHANGELOG-webpack.md @@ -15,6 +15,7 @@ table in [Console dynamic plugins README](./README.md). - **Deprecated**: `loadPluginEntry` callback is deprecated in favor of `__load_plugin_entry__`. Migrate by building your plugin with a 4.22 or later of `ConsoleRemotePlugin`. Runtime support for older plugins built for 4.21 or older will be removed in a future version of OCP Console. ([CONSOLE-3769], [#15904]) +- Add warnings for usage of deprecated Console provided shared modules ([CONSOLE-5135], [#16178]) ## 4.22.0-prerelease.1 - 2025-01-21 @@ -109,6 +110,7 @@ table in [Console dynamic plugins README](./README.md). [CONSOLE-4400]: https://issues.redhat.com/browse/CONSOLE-4400 [CONSOLE-4623]: https://issues.redhat.com/browse/CONSOLE-4623 [CONSOLE-5050]: https://issues.redhat.com/browse/CONSOLE-5050 +[CONSOLE-5135]: https://issues.redhat.com/browse/CONSOLE-5135 [OCPBUGS-30762]: https://issues.redhat.com/browse/OCPBUGS-30762 [OCPBUGS-30824]: https://issues.redhat.com/browse/OCPBUGS-30824 [OCPBUGS-31901]: https://issues.redhat.com/browse/OCPBUGS-31901 @@ -140,5 +142,6 @@ table in [Console dynamic plugins README](./README.md). [#15479]: https://github.com/openshift/console/pull/15479 [#15802]: https://github.com/openshift/console/pull/15802 [#15904]: https://github.com/openshift/console/pull/15904 -[#15945]: https://github.com/openshift/console/pull/15945 [#15934]: https://github.com/openshift/console/pull/15934 +[#15945]: https://github.com/openshift/console/pull/15945 +[#16178]: https://github.com/openshift/console/pull/16178 diff --git a/frontend/packages/console-dynamic-plugin-sdk/src/shared-modules/shared-modules-meta.ts b/frontend/packages/console-dynamic-plugin-sdk/src/shared-modules/shared-modules-meta.ts index 38d00dad5aa..cad0e9489fa 100644 --- a/frontend/packages/console-dynamic-plugin-sdk/src/shared-modules/shared-modules-meta.ts +++ b/frontend/packages/console-dynamic-plugin-sdk/src/shared-modules/shared-modules-meta.ts @@ -16,6 +16,9 @@ type SharedModuleMetadata = Partial<{ * @default false */ allowFallback: boolean; + + /** A message describing the deprecation, if the module is deprecated. */ + deprecated: string | false; }>; /** @@ -50,8 +53,8 @@ const sharedPluginModulesMetadata: Record => { - const { singleton = true, allowFallback = false } = sharedPluginModulesMetadata[moduleName]; - return { singleton, allowFallback }; + const { + singleton = true, + allowFallback = false, + deprecated = false, + } = sharedPluginModulesMetadata[moduleName]; + return { singleton, allowFallback, deprecated }; }; diff --git a/frontend/packages/console-dynamic-plugin-sdk/src/webpack/ConsoleRemotePlugin.ts b/frontend/packages/console-dynamic-plugin-sdk/src/webpack/ConsoleRemotePlugin.ts index 41afbda70d3..faef6698bda 100644 --- a/frontend/packages/console-dynamic-plugin-sdk/src/webpack/ConsoleRemotePlugin.ts +++ b/frontend/packages/console-dynamic-plugin-sdk/src/webpack/ConsoleRemotePlugin.ts @@ -121,6 +121,23 @@ export const validateConsoleExtensionsFileSchema = ( return new SchemaValidator(description).validate(schema, extensions); }; +const getDeprecatedSharedModuleWarnings = (pkg: ConsolePluginPackageJSON): string[] => { + const pluginDeps = getPackageDependencies(pkg); + const warnings: string[] = []; + + sharedPluginModules.forEach((moduleName) => { + const { deprecated } = getSharedModuleMetadata(moduleName); + + if (deprecated && pluginDeps[moduleName]) { + warnings.push( + `shared modules: [DEPRECATION ALERT] '${moduleName}' is deprecated. ${deprecated}`, + ); + } + }); + + return warnings; +}; + const validateConsoleProvidedSharedModules = (pkg: ConsolePluginPackageJSON) => { const pluginDeps = getPackageDependencies(pkg); const sdkPkgDeps = getPluginSDKPackagePeerDependencies(); @@ -372,6 +389,7 @@ export class ConsoleRemotePlugin implements WebpackPluginInstance { } = pluginMetadata; const logger = compiler.getInfrastructureLogger(ConsoleRemotePlugin.name); + const publicPath = `/api/plugins/${name}/`; if (compiler.options.output.publicPath !== undefined) { @@ -455,6 +473,10 @@ export class ConsoleRemotePlugin implements WebpackPluginInstance { }); compiler.hooks.thisCompilation.tap(ConsoleRemotePlugin.name, (compilation) => { + getDeprecatedSharedModuleWarnings(this.pkg).forEach((message) => { + compilation.warnings.push(new compiler.webpack.WebpackError(message)); + }); + const modifiedModules: string[] = []; compiler.webpack.NormalModule.getCompilationHooks(compilation).beforeLoaders.tap(