fix(bazel): don't produce self-references in metadata (#29317)
Fixes #29315 PR Close #29317
This commit is contained in:

committed by
Matias Niemelä

parent
1db8bf312e
commit
3facdebd07
@ -399,7 +399,7 @@ export * from '${srcDirRelative(inputPath, typingsFile.replace(/\.d\.tsx?$/, '')
|
|||||||
* @param typingsPath the typings bundle entrypoint
|
* @param typingsPath the typings bundle entrypoint
|
||||||
*/
|
*/
|
||||||
function rewireMetadata(metadataPath: string, typingsPath: string): string {
|
function rewireMetadata(metadataPath: string, typingsPath: string): string {
|
||||||
const metadata = fs.readFileSync(metadataPath, 'utf-8');
|
const metadata = JSON.parse(fs.readFileSync(metadataPath, 'utf-8'));
|
||||||
|
|
||||||
let typingsRelativePath =
|
let typingsRelativePath =
|
||||||
normalizeSeparators(path.relative(path.dirname(metadataPath), typingsPath));
|
normalizeSeparators(path.relative(path.dirname(metadataPath), typingsPath));
|
||||||
@ -411,7 +411,13 @@ export * from '${srcDirRelative(inputPath, typingsFile.replace(/\.d\.tsx?$/, '')
|
|||||||
|
|
||||||
// the regexp here catches all relative paths such as:
|
// the regexp here catches all relative paths such as:
|
||||||
// ./src/core/foo.d.ts and ../src/core/foo.d.ts
|
// ./src/core/foo.d.ts and ../src/core/foo.d.ts
|
||||||
return metadata.replace(/\.?\.\/[\w\.\-_\/]+/g, typingsRelativePath);
|
const relativePathRegex = /\.?\.\/[\w\.\-_\/]+/g;
|
||||||
|
if (metadata.exports) {
|
||||||
|
// Strip re-exports which are now self-references
|
||||||
|
metadata.exports =
|
||||||
|
metadata.exports.filter((e: {from: string}) => !relativePathRegex.test(e.from));
|
||||||
|
}
|
||||||
|
return JSON.stringify(metadata).replace(relativePathRegex, typingsRelativePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user