Skip to content
Permalink
Browse files

fix(bazel): don't produce self-references in metadata (#29317)

Fixes #29315

PR Close #29317
  • Loading branch information...
alexeagle authored and matsko committed Mar 14, 2019
1 parent 1db8bf3 commit 3facdebd074b59e7e865c4c9d6f4adc5bead5754
Showing with 8 additions and 2 deletions.
  1. +8 −2 packages/bazel/src/ng_package/packager.ts
@@ -399,7 +399,7 @@ export * from '${srcDirRelative(inputPath, typingsFile.replace(/\.d\.tsx?$/, '')
* @param typingsPath the typings bundle entrypoint
*/
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 =
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:
// ./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);
}

/**

0 comments on commit 3facdeb

Please sign in to comment.
You can’t perform that action at this time.