-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
Proposal: Support for multiple tsconfig.json per project #6109
Comments
What you describe is something a build engine can/should provide and not something the compiler provides. I'm working on making sure MSBuild does what you describe, and you should see that in the 1.8 timeframe. |
@paulvanbrenk I'm voting for this job to be done by compiler but not by an external tool like MSBuild, since:
|
These tools (i.e. grunt/gulp/msbuild) are already in wide use, and used for deployment, minification, etc. They are perfectly situated for figuring out where the |
I use grunt/gulp in my day-by-day work and I don't happy with them (especially when working with big projects with multiple submodules). I've opened #3645 not because these tools are perfect and I see problems that I would like to be handled by compiler. @paulvanbrenk There is a real-world usecase when we want to deploy a codebase into platform like Heroku, so my question is: will MSbuild allows to build project in |
As I said If you're un-happy with Grunt/Gulp/MSBuild you should file bugs on those projects, so they can be improved for all users not just the TypeScript users. |
In this issue tracker we discuss a feature that I and other people want to be a part of It is ok to use Grunt/Gulp/MSBuild but it useless for many devs working in linux, osx environments. It like using |
I agree with lazutkin: Two examples:
Extracting the management of So, extracting this feature out of TSC would require the programmer to always edit things at two different places: When moving/creating/deleting a |
May I add that this thread is being closed a bit too quickly for my liking. We are not trolling around here but discussing a constructive improvement to the project. If I remember it right, the term "Open Source" implicates active participation. That's what's actually happening here. |
@lazutkin gulp/grunt etc work great in non-windows systems. @SetTrend I guess we disagree on the scope of the project, but as clearly stated in bullet 4 of the https://github.com/Microsoft/TypeScript/wiki/TypeScript-Design-Goals#non-goals:
This is not something we're interested in providing, since many tools exist that are either capable of exactly the functionality wanted, or can be more easily modified to have that capability. |
I tend to agree on that we disagree on the scope on the project. To me it looks like you seem to consider the TSC transpiler reacting to a single configuration file a compiler matter while reacting to multiple configuration being an external build configuration. I cannot share this point of view. To me it's like a hen allowed to only lay one single egg during its life but not to lay many eggs. Nonetheless, the non-goals section gives statement about an end-to-end pipeline, but it doesn't give any guideline about whether multiple configuration files are considered a non-goal. So I would believe your reason is rather interpretation than argument. |
What you're proposing is more like a hen laying another hen, in addition to an egg... |
OK, I think arguments have been exchanged sufficiently now. I'm excited to see the outcome of v1.8. And we'll see then. I don't believe it makes any more sense now to discuss unhatched eggs 😉 |
/cc @DovydasNavickas wrote that you have the impression that I'm trying to talk you into adding a file watcher to TSC. Is that correct? I'm by no means suggesting this. In case that's what you truely believe, please let me clarify ... This is (in pseudo code) what TSC currently does: void Main(string[] args)
{
_config = getDefaultConfiguration(); // get (const) TSC default configuration
if (File.Exists("tsconfig.json")) _config = readTsConfig(_config); // if tsconfig.json file exists, read it and overwrite default configuration
Directory.SetCurrentDirectory(_config.ProjectPath); // set root for relative paths here
CompileDirectory(_config.ProjectDirectory); // start browsing the directory for .ts files ...
}
void CompileDirectory(string path)
{
foreach (string directory in Directory.GetDirectories(path)) CompileDirectory(directory); // If there are any sub directories, compile them first
foreach (string file in Directory.GetFiles(path, "*.ts")) CompileFile(Path.Combine(path, file)); // compile all the .ts files in this directory
}
void CompileFile(string filePath)
{
...
} All I suggest is to **move the interpretation of the tsconfig.file from the root procedure to the directory browsing procedure**: void Main(string[] args)
{
_config = getDefaultConfiguration(); // get (const) TSC default configuration
Directory.SetCurrentDirectory(_config.ProjectPath); // set root for relative paths here
CompileDirectory(_config.ProjectDirectory); // start browsing the directory for .ts files ...
}
void CompileDirectory(string path)
{
bool configExists = File.Exists(Path.Combine(path, "tsconfig.json")); // true, if tsconfig.json file exists
if (configExists)
{
_configStack.Push(_config.Clone()); // push current configuration on stack
_config = readTsConfig(_config, path); // update current configuration with content of tsconfig.json file
}
foreach (string directory in Directory.GetDirectories(path)) CompileDirectory(directory); // If there are any sub directories, compile them first
foreach (string file in Directory.GetFiles(path, "*.ts")) CompileFile(Path.Combine(path, file)); // compile all the .ts files in this directory
if (configExists) _config = _configStack.Pop(); // restore previous configuration
}
void CompileFile(string filePath)
{
...
} You see? There is no file watching whatsoever. Me and @lazutkin are only suggesting to move reading a We are suggesting to use dynamic configuration in preference to static configuration. |
No, I understood what you meant. And still think MSBuild is the right tool for the job. i.e. Invoke And because MSBuild has a bunch of context here, it can correctly schedule each build step. |
If you want to create a separate build job (aka. build task) for each of the It would be preposterous to create/maintain a build job via any of the task runners in one file and additionally maintain the options for the compiler in a second file, i.e. a There'd be no reason in supporting |
Although I admit that your way fairly is a solution. Many roads lead to rome. Yours does, too. |
Except that a But yes, if you're all in on MSBuild based solutions there is no specific need for |
Referencing #3645:
I agree with @Eisenspalter: Multiple tsconfig files are indispensable for large enterprise apps.
@mhegazy : As you wrote you don't want to support
tsconfig.json
file inheritance, I'd like to propose the following:My proposal
TSC should come with a new command line parameter, enabling the following behaviour:
tsconfig.json
files.tsconfig.json
files will be found, TSC proceeds with its normal behaviour: Compiling all .ts files found in the projects sub directories, using the default configuration.tsconfig.json
file will be found, the TSC process refrains from compiling. Instead it spawns a new TSC child process for thetsconfig.json
file and continues browsing the project's sub directories fortsconfig.json
files. It does this for eachtsconfig.json
file it reaches.-project
parameter and current working directory of that child process to thetsconfig.json
file's.-project
) if it finds atsconfig.json
file in there.The new command line parameter (e.g.
-browseConfig
) should require a directory information, similar to the-project
command line parameter. This will allow the user to provide a dedicated sub directory as root for scanning.#### Example
The following example depicts the original TSC process to start at
-browseConfig "."
("Project root"):TSC -browseConfig "."
Browsing the project directory tree it finds three
tsconfig.json
files. For each of thetsconfig.json
files it spawns a new TSC process:So there will be four
TSC
processes running in parallel (good for multi-core systems 😉), each evaluating its sub tree of the project. The first process won't perform any transpilation. It only browses the directory tree.The following images depict the main TSC process and the three sub processes, highlighting the files they transpile:
To speed up browsing for
tsconfig.json
files, the first/main/original TSC process could/should better be started using:TSC -browseConfig "./scripts/"
The text was updated successfully, but these errors were encountered: