-
Notifications
You must be signed in to change notification settings - Fork 37
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
Cross-project dependencies #6
Comments
For my current use case, if it moved files under both app and util to the specified location (relative to each project), that would be correct. And it would be nice if it piped the util files through the rest of the gulp stream as well. I'm not sure if that's possible, or good default behavior. |
@scriby Thanks for report! Yep, it is not designed behavior that files referenced by compile targets leave the compiled files in the source directory... If I understand correctly, the structure you mentioned is like this:
And what you want as the result is like:
Is that correct? IMO it is not "natural" that one gulp task put genereated files into multiple destinations ( Instead, I think gulp-tsc should simulate
Then, the result should be:
This is the same result as running Do you agree with this? By the way, just an idea: The result structure you desire would be achieved by using another gulp plugin "mapping piped files to multiple destination" that allows you to write a gulp task like this:
But I can't find out an ideal plugin does things like that. So I think I will write up the plugin by myself when I have time. Would it be great? |
By facing issue #6, we should have managed files referenced by compile targets, because they are also compiled implicitly. This commit changes how we handle output files. We give --outDir option to tsc with a temporary directory path so that all files generated by tsc command go to the directory, and we can manage them properly. No more "mark and sweep" is needed. However, this has a side-effect that causes sourcemap files to have unsolvable relative path to the source files. So we add sourceRoot option and outDir option to manage with this problem. sourceRoot option makes paths in sourcemap files absolute, and outDir option is a hint for Compiler where the output files are going to, so that it can correct paths in sourcemap.
As you know, the current version of gulp-tsc tries to "calculate" output files from source files like On PR above, I have completely changed how gulp-tsc finds the output files. By passing If you have some comment on this change, I'd like to hear that! :) |
I tested out the branch and it mostly works. The biggest issue is this:
Once the util files get compiled into app's build directory, they can no longer load the node_modules from util. I was playing around with this structure and you can make it work if you symlink the node_modules into the build folder. This seemed overly complicated though, and I just decided to compile the source in-place. It's a little "less clean", but all the references and things work out correctly. I also noticed a bug in the new branch where if I compile the source in place, the .ts files at the top level don't get compiled (or their output gets lost). I also tried this structure to fix the node_modules problem:
But it doesn't work either. The problem there is that code in app that references util won't work at runtime. The references will be pointing to code living under source, but at runtime it needs to be pointing at code under build. But just compiling in place solves all the issues. And my IDE supports folding the .js and .map files under the .ts file, so it's not so bad. Thanks, Chris |
@scriby Big thanks to your cooperation!
I see... I didn't realize that you have In-place compile is obvious way to solve it, but how about using Example project is here: https://github.com/kotas/gulp-tsc-cross-project
In
However, some trick is needed for
Or, I think it is much cleaner and more consistent to split your util project into other repository so that app project can install it via the repository as dependency.
Sorry, I can't reproduce that. What the structure and gulp task is like? When the structure is like:
And gulp task is something like:
|
I do have the util project split into a separate repository (you just have to check both out into the same parent directory). I think your structure with the package.json "main" looks interesting. I'm happy enough w/ the in-place compile and will probably go with it for now. I really appreciate you spending all this time to help me out! Thanks!!! |
All right! I'll close the issue and ship the branch as a next version. Thank you so much for using my plugin! 😃 |
Change the strategy for handling output files
hi! first of all awesome plugin and support kotas :)
the util project is in our case a common project which should be compiled independently from the app. is there a way to resolve this issue so that we get the following file structure (including working sourcemaps) ??
thanks in advance :) |
@MrMuh Hi, thank you for using gulp-tsc! :) I have published gulp-tsc v0.8.0 with new You can modify paths of compiled files by using the option. See document for details. For your case, you will need a gulp task like following:
By pathFilter, Sourcemaps are supported! Tell me if it doen't meet your requirements. Thanks! |
@kotas awesome! works like a charm :) thx for your great support! |
I have two typescript projects (app and util). The app project references files in the util project.
I set up my gulp-tsc with sources from the app project, but during compilation, the typescript compiler also compiles files in the util project. This is mostly ok, but because the util files don't get added to the gulp output files, there's a couple caveats:
I'm not even sure there's anything worthwhile to do about this, but just thought I'd bring it up to see if you had any ideas.
Thanks,
Chris
The text was updated successfully, but these errors were encountered: