cli: fix linking with react-router
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
@@ -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;
|
||||
}
|
||||
},
|
||||
),
|
||||
];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user