Skip to content

Commit 8ebcacb

Browse files
committed
fix(@angular/build): resolve secondary entry point README.md from entry point directory
Resolve the default `README.md` asset for secondary entry points from `path.join(projectRoot, entryPoint.name)` instead of `path.dirname(entryPoint.entryFilePath)` so that secondary entry points with nested entry files (e.g. `testing/src/public-api.ts`) pick up `testing/README.md`, matching `ng-packagr` behavior.
1 parent f0a74e8 commit 8ebcacb

2 files changed

Lines changed: 25 additions & 1 deletion

File tree

‎packages/angular/build/src/builders/library/options.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ export async function normalizeLibraryOptions(
9999
}
100100
defaultAssets.push({
101101
glob: 'README.md',
102-
input: path.dirname(entryPoint.entryFilePath),
102+
input: path.join(projectRoot, entryPoint.name),
103103
output: entryPoint.name,
104104
});
105105
}

‎packages/angular/build/src/builders/library/tests/options/assets_spec.ts‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,29 @@ describeLibraryBuilder(executeLibraryBuilder, LIBRARY_BUILDER_INFO, (harness) =>
5050

5151
expect(harness.readFile('dist/lib/docs/README.md')).toBe('# Library Docs');
5252
});
53+
54+
it('should copy secondary entry point README.md from the entry point directory by default', async () => {
55+
await harness.writeFiles({
56+
'projects/lib/package.json': JSON.stringify({
57+
name: 'lib',
58+
version: '0.0.1',
59+
exports: {
60+
'.': './src/public-api.ts',
61+
'./testing': './testing/src/public-api.ts',
62+
},
63+
}),
64+
'projects/lib/testing/README.md': '# Testing Entry Point',
65+
'projects/lib/testing/src/public-api.ts': 'export const TESTING = true;',
66+
});
67+
68+
harness.useTarget('build', {
69+
...BASE_OPTIONS,
70+
});
71+
72+
const { result } = await harness.executeOnce();
73+
expect(result?.success).toBeTrue();
74+
75+
expect(harness.readFile('dist/lib/testing/README.md')).toBe('# Testing Entry Point');
76+
});
5377
});
5478
});

0 commit comments

Comments
 (0)