-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(angular): update tsconfig included and excluded files when genera…
…ting a library secondary entry point
- Loading branch information
1 parent
971a020
commit 8daf6f8
Showing
4 changed files
with
73 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
...ngular/src/generators/library-secondary-entry-point/lib/update-tsconfig-included-files.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { joinPathFragments, updateJson, type Tree } from '@nx/devkit'; | ||
import type { NormalizedGeneratorOptions } from '../schema'; | ||
|
||
export function updateTsConfigIncludedFiles( | ||
tree: Tree, | ||
options: NormalizedGeneratorOptions | ||
): void { | ||
const candidateTsConfigPaths = [ | ||
options.libraryProject.targets?.build?.options?.tsConfig, | ||
joinPathFragments(options.libraryProject.root, 'tsconfig.lib.json'), | ||
joinPathFragments(options.libraryProject.root, 'tsconfig.json'), | ||
]; | ||
|
||
const tsConfigPath = candidateTsConfigPaths.find( | ||
(path) => path && tree.exists(path) | ||
); | ||
if (!tsConfigPath) { | ||
// ignore if the library has a custom tsconfig setup | ||
return; | ||
} | ||
|
||
updateJson(tree, tsConfigPath, (json) => { | ||
if (json.include?.length) { | ||
json.include = json.include.map((path: string) => | ||
path.replace(/^(?:\.\/)?src\//, '') | ||
); | ||
} | ||
|
||
if (json.exclude?.length) { | ||
json.exclude = json.exclude.map((path: string) => | ||
path.replace(/^(?:\.\/)?src\//, '') | ||
); | ||
} | ||
|
||
return json; | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters