diff --git a/.changeset/witty-pets-march.md b/.changeset/witty-pets-march.md new file mode 100644 index 0000000000..163d146027 --- /dev/null +++ b/.changeset/witty-pets-march.md @@ -0,0 +1,5 @@ +--- +'@backstage/frontend-plugin-api': patch +--- + +Allow route references to be installed in multiple app instances as long as their name is the same. diff --git a/packages/frontend-plugin-api/src/routing/RouteRef.test.ts b/packages/frontend-plugin-api/src/routing/RouteRef.test.ts index de7a3de887..570723df9a 100644 --- a/packages/frontend-plugin-api/src/routing/RouteRef.test.ts +++ b/packages/frontend-plugin-api/src/routing/RouteRef.test.ts @@ -35,6 +35,7 @@ describe('RouteRef', () => { internal.setId('some-id'); expect(String(internal)).toBe('RouteRef{some-id}'); + internal.setId('some-id'); // Should allow same ID expect(() => internal.setId('some-other-id')).toThrow( "RouteRef was referenced twice as both 'some-id' and 'some-other-id'", diff --git a/packages/frontend-plugin-api/src/routing/RouteRef.ts b/packages/frontend-plugin-api/src/routing/RouteRef.ts index da562e5273..1678e14cd4 100644 --- a/packages/frontend-plugin-api/src/routing/RouteRef.ts +++ b/packages/frontend-plugin-api/src/routing/RouteRef.ts @@ -95,7 +95,7 @@ export class RouteRefImpl implements InternalRouteRef { if (!id) { throw new Error(`${this.#name} id must be a non-empty string`); } - if (this.#id) { + if (this.#id && this.#id !== id) { throw new Error( `${this.#name} was referenced twice as both '${this.#id}' and '${id}'`, );