-
-
Notifications
You must be signed in to change notification settings - Fork 540
[BREAKING] make --script-mode the default; add --cwd-mode to switch back to old behavior #1155
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
Merged
+242
−93
Conversation
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
Codecov Report
|
…quire.resolve cache; causes entrypoint to resolve incorrectly when --prefer-ts-exts is used
…ojectSearchDir as needed
e05f037
to
7d7f76b
Compare
This was referenced Feb 15, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Resolves #949
Resolves #1194
Resolves #1189
Resolves #1197
Resolves #1220
Resolves #1225
I took a quick look at our old discussions and it doesn't seem like we came up with any reasons why this change is bad.
Adds
--cwd-mode
flag to switch back to the old behavior, or users can specify a directory with--dir
or a tsconfig file with--project
Need to rethink the way
--dir
works. Currently, it is treated as if you'dcd
ed to the target directory, which affects lots of behaviors. The--help
docs say it only affects config resolution. But in the code, it overrides allprocess.cwd()
checks. That seems confusing to me.For example, if you use
--dir
, then error messages which log script paths will log them relative to--dir
.--project
is also interpreted relative to--dir
.Now that implementation is complete, a summary of changes:
--script-mode
by default--cwd-mode
flag to opt-out of--script-mode
ts-node-cwd
entry-point that uses--cwd-mode
by default--dir
to--cwd
;TS_NODE_DIR
toTS_NODE_CWD
; parse legacy names for backwards compatibility--cwd
docs to say it changes effectivecwd
projectSearchDir
API option to set directory from which tsconfig search is performedrequire.resolve
cache and prevent correct extension from loading (ts-node ./index may execute the wrong file extension because tsconfig search poisons the require.resolve cache #1220)--cwd
no longer sets--scope
--scope
from CLI flags and tsconfig-loaded options; it is an API-only option, to match the intended use-case: programmatically installing multiple ts-node instancesscopeDir
API optionTS_NODE_SCOPE
env varignore
rules evaluated relative totsconfig.json
, otherwisecwd
; no longer tied to--dir
compiler
is loaded relative totsconfig.json
instead ofcwd
or entrypoint script (Load compiler relative to tsconfig.json instead of cwd #1225)