Skip to content

Commit

Permalink
fix(bazel): do not error on types with wildcard
Browse files Browse the repository at this point in the history
Currently, when a package export types field contain a wildcard the the api-golden step fails due to unsupported package name. This commit fixes this issue by not considering this as entry-point.

This fix is needed for angular/angular#52080
  • Loading branch information
alan-agius4 authored and devversion committed Oct 10, 2023
1 parent 1d8a9ff commit 0319624
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
10 changes: 5 additions & 5 deletions bazel/api-golden/find_entry_points.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,19 @@ export function findEntryPointsWithinNpmPackage(
dirPath: string,
packageJson: PackageJson,
): PackageEntryPoint[] {
const entryPoints: PackageEntryPoint[] = [];

// Legacy behavior to support Angular packages without the `exports` field.
// TODO: Remove when https://github.com/angular/angular-cli/issues/22889 is resolved.
if (packageJson.exports === undefined) {
return findEntryPointsThroughNestedPackageFiles(dirPath);
}

for (const [subpath, conditions] of Object.entries(packageJson.exports)) {
if (conditions.types !== undefined) {
const entryPoints: PackageEntryPoint[] = [];
for (const [subpath, {types}] of Object.entries(packageJson.exports)) {
// Wildcard types mappings are supported.
if (types !== undefined && !types.includes('*')) {
entryPoints.push({
subpath,
typesEntryPointPath: join(dirPath, conditions.types),
typesEntryPointPath: join(dirPath, types),
});
}
}
Expand Down
3 changes: 3 additions & 0 deletions bazel/api-golden/test/fixtures/test_package/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
},
"./testing/nested": {
"types": "./testing/nested.d.ts"
},
"./testing/wildcard/*": {
"types": "./testing/wildcard/*.d.ts"
}
}
}

0 comments on commit 0319624

Please sign in to comment.