diff --git a/.changeset/slimy-penguins-care.md b/.changeset/slimy-penguins-care.md new file mode 100644 index 0000000000..96016b1ba4 --- /dev/null +++ b/.changeset/slimy-penguins-care.md @@ -0,0 +1,5 @@ +--- +'@backstage/cli': patch +--- + +Fix for the `--link` flag for `package start` to deduplicate `react-router` and `react-router-dom`. diff --git a/packages/cli/src/lib/bundler/linkWorkspaces.ts b/packages/cli/src/lib/bundler/linkWorkspaces.ts index ff5223725c..2fe0eb2fb3 100644 --- a/packages/cli/src/lib/bundler/linkWorkspaces.ts +++ b/packages/cli/src/lib/bundler/linkWorkspaces.ts @@ -48,10 +48,13 @@ export async function createWorkspaceLinkingPlugins( }), // react and react-dom are always resolved from the target directory // Note: this often requires that the linked and target workspace use the same versions of React - new bundler.NormalModuleReplacementPlugin(/^react(?:-dom)?$/, resource => { - if (!relativePath(linkedRoot.dir, resource.context).startsWith('..')) { - resource.context = paths.targetDir; - } - }), + new bundler.NormalModuleReplacementPlugin( + /^react(?:-router)?(?:-dom)?$/, + resource => { + if (!relativePath(linkedRoot.dir, resource.context).startsWith('..')) { + resource.context = paths.targetDir; + } + }, + ), ]; }