Conversation

mhegazy

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 of FolderA\FolderB\1.ts and FolderA\FolderB\2.ts would result in computing the commonSourceRoot to FolderA\FolderB\. now if a new file FolderA\3.ts is added to the input, the commonSourceRoot will pop out to FolderA\.

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 flag

The 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 resemble outDir as both flags go together.

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.": {

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 {

Choose a reason for hiding this comment

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

soruceFiles -> sourceFiles

Copy link
Contributor

Choose a reason for hiding this comment

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

why so soruce?

@DanielRosenwasser

👍

mhegazy added a commit that referenced this pull request Apr 20, 2015
Add new compiler option --rootDir
@mhegazymhegazy merged commit 7f8e21b into master Apr 20, 2015
@mhegazymhegazy deleted the rootDir branch April 20, 2015 21:42
@NekR

Is this in beta already or will be only in release?

@mhegazy

Should be in 1.5-beta

@NekR

@mhegazy filed here #2974

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

Successfully merging this pull request may close these issues.

Empty parent directories are not preserved with --outDir