-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(TS_CONFIG_PATH): TS_CONFIG_PATH
environment variable for forcing tsconfig loading
#64
Conversation
@yoursunny This is one way to implement this, I could also have it be the path of the actual config/project file. |
I'm working on refactoring my testing infrastructure so I can add a proper test, it's actually how the Type-Checking thing got started. I need a test that ensures that a |
I'd prefer being able to specify full path to The simplest implementation is: export function getTSConfig(modulePath: string): CompilerOptions {
const tsConfigPath = process.env.TS_CONFIG_PATH ?? ts.findConfigFile(modulePath, ts.sys.fileExists); |
I tested this change along with #80 in NDNts repository, and they appear to work well without using my custom hacks. export TS_CONFIG_PATH=$ROOTDIR/mk/tsconfig-literate.json
node --loader @k-foss/ts-esnode --experimental-specifier-resolution=node literate-temp.ts You may want to rename this PR to reflect the changed environment variable name. Currently this change does not recognize TSConfig |
TS_PROJECT
environment variable for searchTS_CONFIG_PATH
environment variable for forcing tsconfig loading
I've renamed the PR and fixed the description. And... I got "extends" working. The current |
const jsonText = await fs.readFile(tsConfigPath); | ||
const result = ts.parseJsonText(tsConfigPath, jsonText.toString()); | ||
|
||
tsConfigCache = ts.convertCompilerOptionsFromJson( | ||
tsConfigFile.compilerOptions, | ||
pathDirname(tsConfigPath), | ||
tsConfigCache = ts.parseJsonSourceFileConfigFileContent( | ||
result, | ||
ts.sys, | ||
dirname(tsConfigPath), | ||
).options; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will likely have a small perf impact until I setup proper caching. Need to finish moving this repo over to using @K-FOSS/TS-ESTests and have proper time differences on each PR/commit. Speed is my main priority with TS-ESNode.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested this (after git merge master
) in NDNts codebase and it works well. "extends" is working too.
@yoursunny Release should be live in a few minutes. |
# [1.6.0](v1.5.1...v1.6.0) (2020-05-27) ### Features * **TS_CONFIG_PATH:** `TS_CONFIG_PATH` environment variable for forcing tsconfig loading ([#64](#64)) ([5885d2e](5885d2e))
🎉 This PR is included in version 1.6.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This PR adds the option to provide
TS_CONFIG_PATH
environment variable to force the path to the TSConfig file to use for transpiling and paths.