Skip to content

Commit 814f43b

Browse files
committed
fixup! feat(@schematics/angular): use library builder and add entry-point schematic
1 parent f9097ac commit 814f43b

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

‎packages/schematics/angular/entry-point/index.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ function updateTsConfig(packageName: string, ...paths: string[]): Rule {
3636
const file = new JSONFile(host, 'tsconfig.json');
3737
const jsonPath = ['compilerOptions', 'paths', packageName];
3838
const value = file.get(jsonPath);
39-
file.modify(jsonPath, Array.isArray(value) ? [...value, ...paths] : paths);
39+
file.modify(jsonPath, Array.isArray(value) ? Array.from(new Set([...value, ...paths])) : paths);
4040
};
4141
}
4242

‎packages/schematics/angular/entry-point/index_spec.ts‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,17 @@ describe('EntryPoint Schematic', () => {
185185
expect(tsConfigJson.compilerOptions.paths['foo/secondary']).toEqual(['./dist/foo/secondary']);
186186
});
187187

188+
it('should not duplicate existing paths mapping in root tsconfig.json', async () => {
189+
const tsConfig = getJsonFileContent(workspaceTree, '/tsconfig.json');
190+
tsConfig.compilerOptions.paths['foo/secondary'] = ['./dist/foo/secondary'];
191+
workspaceTree.overwrite('/tsconfig.json', JSON.stringify(tsConfig, null, 2));
192+
193+
const tree = await schematicRunner.runSchematic('entry-point', defaultOptions, workspaceTree);
194+
195+
const tsConfigJson = getJsonFileContent(tree, '/tsconfig.json');
196+
expect(tsConfigJson.compilerOptions.paths['foo/secondary']).toEqual(['./dist/foo/secondary']);
197+
});
198+
188199
it('should respect custom outputPath in angular.json for tsconfig paths mapping', async () => {
189200
const angularJson = getJsonFileContent(workspaceTree, '/angular.json');
190201
angularJson.projects.foo.architect.build.options.outputPath = 'custom-dist/foo';

0 commit comments

Comments
 (0)