From be1bcbaead1aa101791475891bc6796eb3cef849 Mon Sep 17 00:00:00 2001 From: Alan Agius Date: Tue, 3 Dec 2019 19:06:29 +0100 Subject: [PATCH] fix(@schematics/angular): improve paths and exclude options Currently the library schematic doesn't support adding a secondary entry-point and having deep imports is not recommanded. It's best if paths are more stricter when having a secondary entry-point instead of a wildcard. Instead of : ``` "lib/*": [ "dist/lib/*" ] ``` Users should configure: ``` "lib/secondary": [ "dist/lib/secondary" ] ``` This would allow a better DX experience when using auto imports in IDE's. Closes: #15952 --- packages/schematics/angular/library/index.ts | 7 ------- packages/schematics/angular/library/index_spec.ts | 3 --- .../angular/workspace/files/tsconfig.json.template | 2 +- 3 files changed, 1 insertion(+), 11 deletions(-) diff --git a/packages/schematics/angular/library/index.ts b/packages/schematics/angular/library/index.ts index 506dff3d7161..4ffcb1ff8fd0 100644 --- a/packages/schematics/angular/library/index.ts +++ b/packages/schematics/angular/library/index.ts @@ -68,13 +68,6 @@ function updateTsConfig(packageName: string, distRoot: string) { tsconfig.compilerOptions.paths[packageName] = []; } tsconfig.compilerOptions.paths[packageName].push(distRoot); - - // deep import & secondary entrypoint support - const deepPackagePath = packageName + '/*'; - if (!tsconfig.compilerOptions.paths[deepPackagePath]) { - tsconfig.compilerOptions.paths[deepPackagePath] = []; - } - tsconfig.compilerOptions.paths[deepPackagePath].push(distRoot + '/*'); }); }; } diff --git a/packages/schematics/angular/library/index_spec.ts b/packages/schematics/angular/library/index_spec.ts index f22ac7ef275f..609fa1d4c51d 100644 --- a/packages/schematics/angular/library/index_spec.ts +++ b/packages/schematics/angular/library/index_spec.ts @@ -208,9 +208,6 @@ describe('Library Schematic', () => { expect(tsConfigJson.compilerOptions.paths.foo).toBeTruthy(); expect(tsConfigJson.compilerOptions.paths.foo.length).toEqual(1); expect(tsConfigJson.compilerOptions.paths.foo[0]).toEqual('dist/foo'); - expect(tsConfigJson.compilerOptions.paths['foo/*']).toBeTruthy(); - expect(tsConfigJson.compilerOptions.paths['foo/*'].length).toEqual(1); - expect(tsConfigJson.compilerOptions.paths['foo/*'][0]).toEqual('dist/foo/*'); }); it(`should append to existing paths mappings`, async () => { diff --git a/packages/schematics/angular/workspace/files/tsconfig.json.template b/packages/schematics/angular/workspace/files/tsconfig.json.template index 9eb43d31920f..896ab790a464 100644 --- a/packages/schematics/angular/workspace/files/tsconfig.json.template +++ b/packages/schematics/angular/workspace/files/tsconfig.json.template @@ -2,7 +2,7 @@ "compileOnSave": false, "compilerOptions": { "baseUrl": "./", - "outDir": "./dist/out-tsc",<% if (strict) { %> + "outDir": "./dist",<% if (strict) { %> "noImplicitAny": true, "noImplicitReturns": true, "noImplicitThis": true,