cli: fix trailing /* in automatic imports

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2025-04-07 14:58:46 +02:00
parent 61f169210c
commit 6969f79ff0
2 changed files with 12 additions and 7 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/cli': patch
---
Avoid trailing `/*` when automatically adding imports for package with multiple entry points.
@@ -166,8 +166,11 @@ async function rewriteEntryPoints(
if (!pkg.typesVersions) {
pkg.typesVersions = { '*': {} };
}
const mount = entryPoint.name === 'index' ? '*' : entryPoint.name;
pkg.typesVersions['*'][mount] = [`dist/${entryPoint.name}.d.ts`];
if (entryPoint.name !== 'index') {
pkg.typesVersions['*'][entryPoint.name] = [
`dist/${entryPoint.name}.d.ts`,
];
}
}
exp.default = exp.require ?? exp.import;
@@ -217,12 +220,9 @@ async function rewriteEntryPoints(
}
}
// Clean up the typesVersions field if it only contains a wildcard
// Make sure package.json is also available in typesVersions if present
if (pkg.typesVersions?.['*']) {
const keys = Object.keys(pkg.typesVersions['*']);
if (keys.length === 1 && keys[0] === '*') {
delete pkg.typesVersions;
}
pkg.typesVersions['*']['package.json'] = ['package.json'];
}
if (pkg.exports) {