This repository has been archived by the owner on Sep 27, 2023. It is now read-only.
Resolve basePath
parameter to prevent errors when loading compiler options
#470
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR resolves the relative
basePath
parameter passed tots.parseJsonConfigFileContent()
.Background
Despite setting the correct
target
andmodule
versions intsconfig.json
, thereplaceRequire
option was never being set.As it turned out,
loadCompilerOptions
was failing to parse ourtsconfig.json
correctly - the following error was causing it to return an empty object (despite the parsed config having a validoptions
property):We don't explicitly specify the
files
orinclude
keys intsconfig.json
, which produces the default behavior of including all files in the current directory and subdirectory. Of course, we don't see the above error in any other circumstance - onlyrelay-compiler-typescript
'sloadCompilerOptions
method.Passing the relative path string
'./'
(existing behavior) produces an emptyfiles
array. This is because the relative path gets passed all the way through to TS'sgetNormalizedAbsolutePath()
, which seems to expect an absolute path itself. When given a relative path, it produces a path string which causes no files to be resolved.Resolution
Resolving the path using
ts.sys.resolvePath('./')
results in ourfiles
array being populated correctly, the above error not being (silently) emitted, and things downstream working properly (module numbers being loaded from config, andreplaceRequire
being set accordingly).