cli: fix typesVersions generation in prepack
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/cli': patch
|
||||
---
|
||||
|
||||
Fixed the package prepack command so that it no longer produces unnecessary `index` entries in the `typesVersions` map, which could cause `/index` to be added when automatically adding imports.
|
||||
@@ -143,7 +143,7 @@ async function rewriteEntryPoints(
|
||||
|
||||
// Clear to ensure a clean slate before adding entries back in further down
|
||||
if (pkg.typesVersions) {
|
||||
pkg.typesVersions = { '*': {} };
|
||||
pkg.typesVersions = undefined;
|
||||
}
|
||||
|
||||
for (const entryPoint of entryPoints) {
|
||||
@@ -166,9 +166,8 @@ async function rewriteEntryPoints(
|
||||
if (!pkg.typesVersions) {
|
||||
pkg.typesVersions = { '*': {} };
|
||||
}
|
||||
pkg.typesVersions['*'][entryPoint.name] = [
|
||||
`dist/${entryPoint.name}.d.ts`,
|
||||
];
|
||||
const mount = entryPoint.name === 'index' ? '*' : entryPoint.name;
|
||||
pkg.typesVersions['*'][mount] = [`dist/${entryPoint.name}.d.ts`];
|
||||
}
|
||||
|
||||
exp.default = exp.require ?? exp.import;
|
||||
@@ -218,6 +217,14 @@ async function rewriteEntryPoints(
|
||||
}
|
||||
}
|
||||
|
||||
// Clean up the typesVersions field if it only contains a wildcard
|
||||
if (pkg.typesVersions?.['*']) {
|
||||
const keys = Object.keys(pkg.typesVersions['*']);
|
||||
if (keys.length === 1 && keys[0] === '*') {
|
||||
delete pkg.typesVersions;
|
||||
}
|
||||
}
|
||||
|
||||
if (pkg.exports) {
|
||||
pkg.exports = outputExports;
|
||||
// We treat package.json as a fixed export that is always available in the published package
|
||||
|
||||
Reference in New Issue
Block a user