-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Add new compiler option --rootDir #2772
Conversation
Conflicts: tests/baselines/reference/APISample_compile.types tests/baselines/reference/APISample_linter.types tests/baselines/reference/APISample_transform.types tests/baselines/reference/APISample_watcher.types
"category": "Message", | ||
"code": 6058 | ||
}, | ||
"File '{0}' is not under rootDir '{1}'. RootDir is expected to contain all source files.": { |
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.
Use lowercase 'r' for 'RootDir', use single quotes :
"under 'rootDir' '{1}'. 'rootDir' is expected..."
Conflicts: tests/baselines/reference/APISample_compile.types tests/baselines/reference/APISample_linter.types tests/baselines/reference/APISample_transform.types tests/baselines/reference/APISample_watcher.types
return getNormalizedPathFromPathComponents(commonPathComponents); | ||
} | ||
|
||
function checkSourceFilesBelongToPath(soruceFiles: SourceFile[], rootDirectory: string): boolean { |
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.
soruceFiles -> sourceFiles
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.
why so soruce?
👍 |
Add new compiler option --rootDir
Is this in beta already or will be only in release? |
Should be in 1.5-beta |
The new option fixes #2644, which is a reactivation of #287, and has been in discussion in #2034.
Background
The current behavior of the compiler when using
--outDir
is to duplicate the input structure in the output under the value of--outDir
. the root of the input is computed as the longest common path of all source (.ts and not .d.ts) files. so an input ofFolderA\FolderB\1.ts
andFolderA\FolderB\2.ts
would result in computing the commonSourceRoot toFolderA\FolderB\
. now if a new fileFolderA\3.ts
is added to the input, the commonSourceRoot will pop out toFolderA\
.This is generally undesirable and can be confusing. it also does not allow for folders that do not contain .ts files to be replicated in the output.
--rootDir
flagThe new flag is used to customize the commonSourceRoot instead of automatically calculating it.
The same rules apply, i.e. all source files (.ts) should be under the rootDir, otherwise the output generation may not be correct.
The name
rootDir
is meant to resembleoutDir
as both flags go together.