Skip to content

Commit f4cbf50

Browse files
committed
fix(@schematics/angular): configure library sourceRoot to project root
This ensures that test discovery can properly discover test files across secondary entry points without needing path traversal.
1 parent 9b7a14a commit f4cbf50

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

‎packages/schematics/angular/library/index.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,9 @@ function addLibToWorkspaceFile(
9898
workspace.projects.add({
9999
name: projectName,
100100
root: projectRoot,
101-
sourceRoot: `${projectRoot}/src`,
101+
// TODO(alanagius): consider re-adding this when we move away from ng-packagr.
102+
// sourceRoot: `${projectRoot}/src`,
103+
sourceRoot: projectRoot,
102104
projectType: ProjectType.Library,
103105
prefix: options.prefix,
104106
targets: {

‎packages/schematics/angular/library/index_spec.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ describe('Library Schematic', () => {
328328
project: 'foo',
329329
};
330330
tree = await schematicRunner.runSchematic('component', componentOptions, tree);
331-
expect(tree.exists('/projects/foo/src/lib/comp/comp.ts')).toBe(true);
331+
expect(tree.exists('/projects/foo/lib/comp/comp.ts')).toBe(true);
332332
});
333333

334334
it(`should support creating scoped libraries`, async () => {

0 commit comments

Comments
 (0)