Skip to content

Commit

Permalink
fix(@schematics/angular): improve paths and exclude options
Browse files Browse the repository at this point in the history
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
  • Loading branch information
alan-agius4 authored and mgechev committed Dec 4, 2019
1 parent af3c3ff commit 4837825
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 11 deletions.
7 changes: 0 additions & 7 deletions packages/schematics/angular/library/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 + '/*');
});
};
}
Expand Down
3 changes: 0 additions & 3 deletions packages/schematics/angular/library/index_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"outDir": "./dist/out-tsc",<% if (strict) { %>
"outDir": "./dist",<% if (strict) { %>
"noImplicitAny": true,
"noImplicitReturns": true,
"noImplicitThis": true,
Expand Down

0 comments on commit 4837825

Please sign in to comment.