Index features on id instead of object.
This will allow features added from an external package location to be loaded correctly., without the requirement of making backstage packages singletons. Signed-off-by: David Festal <dfestal@redhat.com>
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
---
|
||||
'@backstage/backend-app-api': patch
|
||||
---
|
||||
|
||||
Index features on id instead of object.
|
||||
|
||||
This will allow features added from an external package location to be loaded correctly,
|
||||
without the requirement of making backstage packages singletons.
|
||||
@@ -44,10 +44,7 @@ export interface BackendRegisterInit {
|
||||
export class BackendInitializer {
|
||||
#startPromise?: Promise<void>;
|
||||
#features = new Array<InternalBackendFeature>();
|
||||
#extensionPoints = new Map<
|
||||
ExtensionPoint<unknown>,
|
||||
{ impl: unknown; pluginId: string }
|
||||
>();
|
||||
#extensionPoints = new Map<string, { impl: unknown; pluginId: string }>();
|
||||
#serviceHolder: EnumerableServiceHolder | undefined;
|
||||
#providedServiceFactories = new Array<ServiceFactory>();
|
||||
#defaultApiFactories: ServiceFactory[];
|
||||
@@ -64,7 +61,7 @@ export class BackendInitializer {
|
||||
const missingRefs = new Set<ServiceOrExtensionPoint>();
|
||||
|
||||
for (const [name, ref] of Object.entries(deps)) {
|
||||
const ep = this.#extensionPoints.get(ref as ExtensionPoint<unknown>);
|
||||
const ep = this.#extensionPoints.get(ref.id);
|
||||
if (ep) {
|
||||
if (ep.pluginId !== pluginId) {
|
||||
throw new Error(
|
||||
@@ -201,12 +198,12 @@ export class BackendInitializer {
|
||||
|
||||
if (r.type === 'plugin' || r.type === 'module') {
|
||||
for (const [extRef, extImpl] of r.extensionPoints) {
|
||||
if (this.#extensionPoints.has(extRef)) {
|
||||
if (this.#extensionPoints.has(extRef.id)) {
|
||||
throw new Error(
|
||||
`ExtensionPoint with ID '${extRef.id}' is already registered`,
|
||||
);
|
||||
}
|
||||
this.#extensionPoints.set(extRef, {
|
||||
this.#extensionPoints.set(extRef.id, {
|
||||
impl: extImpl,
|
||||
pluginId: r.pluginId,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user