Skip to content

Use common source directory for calculating concatenated module paths #5661

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
merged 19 commits into from
Nov 26, 2015

Conversation

weswigham
Copy link
Member

Rather than the current directory.

@mhegazy
Copy link
Contributor

mhegazy commented Nov 13, 2015

👍

@mhegazy
Copy link
Contributor

mhegazy commented Nov 13, 2015

can you give this a try on #5471 and see if it failed tests @sheetalkamat is seeing?

@sheetalkamat
Copy link
Member

@weswigham you would need to make sure when running project test cases (with #5471) that there are no *.dts.errors.txt is generated

@weswigham
Copy link
Member Author

Additionally, I needed to change program to always compute a common source directory - that we sometimes never bothered to compute it caused certain configurations of arguments to fail. Given that so many configurations require it at this point, it's better to just always have a directory ready. Plus, it was really weird that host.getCommonSourceDirectory()'s undefined-ness was reliant on compiler flags. Any external implementer of an emit host would not be so unpredictable, I think.

@weswigham
Copy link
Member Author

I've been able to merge this PR with #5471 locally and the tests all pass except getEmitOutputSingleFile2 which has a baseline change where the module name "tests/cases/fourslash/inputFile3" is instead "inputFile3", which is in-line with the change of using common source directory here.

So it looks good now. 👍

@sheetalkamat
Copy link
Member

@weswigham I don't think it is good idea to calculate common source directory irrespective of options. We should be calculating it only for the options that use it. Because first it is unnecessary and second it should be reporting error on not finding common source directory and it would be wrong to do that if we aren't going to use it.

@weswigham
Copy link
Member Author

@sheetalkamat: what about if I defer the error reporting until getCommonSourceDirectory() is actually invoked? This way the error is reported when its relevant and you never have to worry about if a common source directory has been generated or not.

@weswigham
Copy link
Member Author

@sheetalkamat on that - I've actually already deferred it to error at the same time it would have before in #5590. Taken together they seem fine.

@sheetalkamat
Copy link
Member

@weswigham Question is should it be error if there is no common source directory when --outFile is specified? I guess not. Can you add a test case with such scenario, so we can see how the output will look especially in case of combining external modules.

I still don't like the idea that we do work related to finding common source directory when its not needed. Special consideration to project with lots of sources.

@weswigham
Copy link
Member Author

@sheetalkamat: Maybe it would simply be best to actually put the generation of a common source directory within the get common source directory function (Including logic to cache it), then? (And calling it in verifyCompilerOptions if we need to check for error scenarios) This way there's no cognitive overhead of needing to know which compiler options force generation of one and no runtime overhead of generating one when its not used...

@weswigham
Copy link
Member Author

Also, I will add a test for that - I'm not sure what we do for that today.

@weswigham
Copy link
Member Author

@sheetalkamat do you wanna look at this again?

@sheetalkamat
Copy link
Member

👍

@sheetalkamat
Copy link
Member

A question though... should --rootDir be used if specified as common source directory?

@weswigham
Copy link
Member Author

It is used - it gets set as the value of commonSourceDirectory in verifyCompilerOptions if present and all source files are within it (and the verify compiler options check has decided that it needs to pregenerate a common source directory).

@sheetalkamat
Copy link
Member

@weswigham but that happens only if --outDir, --sourcRoot or --mapRoot
Here!

@weswigham
Copy link
Member Author

@sheetalkamat correct. I guess it would be possible to use --rootDir without any of those and still be in a situation where you'd like to get a common source directory. (This totally needs a test) I suppose I should pull that same check for rootDir into the default value function. This could actually simplify the verify code a bit, too. I assume the errors we emit with rootDir are valid in all cases we'd want to find a common source directory, so I can continue to use checkSourceFilesBelongToPath and its diagnostics within it.

weswigham added a commit that referenced this pull request Nov 26, 2015
Use common source directory for calculating concatenated module paths
@weswigham weswigham merged commit c9b3b7e into microsoft:master Nov 26, 2015
@weswigham weswigham deleted the use-common-directory-for-out branch August 17, 2017 23:04
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants