Skip to content
This repository has been archived by the owner on Aug 22, 2023. It is now read-only.

feat(tsconfig): add ability to extend base tsconfig #177

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

garrettjstevens
Copy link

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.

Comment on lines +54 to +56
target: tsconfigParsed.options.target === undefined ?
tsconfigParsed.options.target :
typescript.ScriptTarget[tsconfigParsed.options.target],
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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().

Comment on lines -104 to -109
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
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

parseJsonConfigFileContent() resolves rootDir, rootDirs, and outDir to their full paths, so no need to join their path with the root.

garrettjstevens added a commit to GMOD/jbrowse-components that referenced this pull request Sep 29, 2020
It's not supported by oclif, but could be re-enabled if
oclif/config#177 is accepted.
@codecov
Copy link

codecov bot commented Sep 30, 2020

Codecov Report

Merging #177 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@          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.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 25ea412...6b26980. Read the comment docs.

Copy link

@mshwery mshwery left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Thanks for adding this. ❤️

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

tsconfig "extends" not used
3 participants