Merge pull request #27491 from backstage/rugvip/link

cli: fix linking with react-router
This commit is contained in:
Patrik Oldsberg
2024-11-05 10:31:36 +01:00
committed by GitHub
2 changed files with 13 additions and 5 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/cli': patch
---
Fix for the `--link` flag for `package start` to deduplicate `react-router` and `react-router-dom`.
@@ -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;
}
},
),
];
}