diff --git a/app/assets/javascripts/discourse-common/addon/resolver.js b/app/assets/javascripts/discourse-common/addon/resolver.js index 6cfbded2825..d8356d917e2 100644 --- a/app/assets/javascripts/discourse-common/addon/resolver.js +++ b/app/assets/javascripts/discourse-common/addon/resolver.js @@ -115,6 +115,10 @@ const DEPRECATED_MODULES = new Map( }) ); +export function normalizeDeprecatedModule(name) { + return DEPRECATED_MODULES.get(name)?.newName || name; +} + export function setResolverOption(name, value) { _options[name] = value; } diff --git a/app/assets/javascripts/discourse/app/lib/plugin-api.gjs b/app/assets/javascripts/discourse/app/lib/plugin-api.gjs index 83e3d21fb51..9ed9a97e8c3 100644 --- a/app/assets/javascripts/discourse/app/lib/plugin-api.gjs +++ b/app/assets/javascripts/discourse/app/lib/plugin-api.gjs @@ -159,6 +159,7 @@ import { registerIconRenderer, replaceIcon, } from "discourse-common/lib/icon-library"; +import { normalizeDeprecatedModule } from "discourse-common/resolver"; import { addImageWrapperButton } from "discourse-markdown-it/features/image-controls"; import { CUSTOM_USER_SEARCH_OPTIONS } from "select-kit/components/user-chooser"; import { modifySelectKit } from "select-kit/mixins/plugin-api"; @@ -255,14 +256,14 @@ class PluginApi { opts = opts || {}; if ( - this.container.cache[resolverName] || + this.container.cache[normalizeDeprecatedModule(resolverName)] || (resolverName === "model:user" && this.container.lookup("service:current-user")) ) { // eslint-disable-next-line no-console console.warn( consolePrefix(), - `"${resolverName}" has already been initialized and registered as a singleton. Move the modifyClass call earlier in the boot process for changes to take effect. https://meta.discourse.org/t/262064` + `Attempted to modify "${resolverName}", but it was already initialized earlier in the boot process (e.g. via a lookup()). Remove that lookup, or move the modifyClass call earlier in the boot process for changes to take effect. https://meta.discourse.org/t/262064` ); }