feat(tsconfig): add ability to extend base tsconfig#177
feat(tsconfig): add ability to extend base tsconfig#177garrettjstevens wants to merge 1 commit intooclif:mainfrom
Conversation
| target: tsconfigParsed.options.target === undefined ? | ||
| tsconfigParsed.options.target : | ||
| typescript.ScriptTarget[tsconfigParsed.options.target], |
There was a problem hiding this comment.
This bit is because parseJsonConfigFileContent() transforms "target" into its numerical enum value, so we have to change it back to a string to use with tsnode.register().
| const {rootDir, rootDirs, outDir} = tsconfig.compilerOptions | ||
| const rootDirPath = rootDir || (rootDirs || [])[0] | ||
| if (!rootDirPath || !outDir) return orig | ||
| const {rootDir, rootDirs, outDir: lib} = tsconfig.compilerOptions // ./lib | ||
| const src = rootDir || (rootDirs || [])[0] // ./src | ||
| if (!src || !lib) return orig | ||
| // rewrite path from ./lib/foo to ./src/foo | ||
| const lib = path.join(root, outDir) // ./lib | ||
| const src = path.join(root, rootDirPath) // ./src |
There was a problem hiding this comment.
parseJsonConfigFileContent() resolves rootDir, rootDirs, and outDir to their full paths, so no need to join their path with the root.
It's not supported by oclif, but could be re-enabled if oclif/config#177 is accepted.
Codecov Report
@@ Coverage Diff @@
## master #177 +/- ##
======================================
Coverage 0.00% 0.00%
======================================
Files 2 2
Lines 12 12
Branches 3 3
======================================
Misses 12 12 Continue to review full report at Codecov.
|
mshwery
left a comment
There was a problem hiding this comment.
Looks great! Thanks for adding this. ❤️
Fixes #176 by using TypeScript's
parseJsonConfigFileContent(), which resolves the "extends" in a tsconfig and merges the various options in the base and extending tsconfigs.I wasn't what was a good way to add a test for having a base and extending config. Also, this is a pretty minimal change, so it could be expanded/cleaned up a bit based on your preferences.