Skip to content

Not write output file if no content changes #13801

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

Closed
gdh1995 opened this issue Feb 1, 2017 · 3 comments
Closed

Not write output file if no content changes #13801

gdh1995 opened this issue Feb 1, 2017 · 3 comments
Labels
Working as Intended The behavior described is the intended behavior; this is not a bug

Comments

@gdh1995
Copy link
Contributor

gdh1995 commented Feb 1, 2017

TypeScript Version: 2.2.0 / master

Action

# long long ago
cd ~/project
tsc -p .
zip -FS output.zip $(find . -name \*.js)

# after a few days
# I've changed one .ts file
tsc -p .
zip -FS output.zip $(find . -name \*.js)

Expected behavior:
zip will know most .js files keep the same, and only update one .js file corresponding to the modified .ts file.

Actual behavior:
All output .js files are updated by the second tsc -p ., so zip -FS re-updates tons of .js files.

Intention
When I use tsc or tsc -p ., I want it to write into a file only if the output content is different from the old, so the modification times might keep the same, which would be friendly to many tools like diff / make / zip / Beyond Compare.

This refers to #13776 . @mhegazy You said:

Most build systems do check time stamps before calling the compiler

But tsc -p doesn't - what it only does is to compile all .ts files found and update all output files.

And I think: unless I write a very long command line to replace a simple tsconfig.json, I won't be able to keep mtime of unchanged files. The command line would be like this:

TSC_ARGS="--strictNullChecks ----noImplicitReturns --noUnusedLocals --noUnusedParameters --alwaysStrict --removeComments --skipDefaultLibCheck --listEmittedFiles"

dist/%.js: src/%.ts
	tsc $(TSC_ARGS) $@

Too ugly and inconvenient, isn't it?

Update: I find that configurable gulp-typescript / grunt supports this, but they're a bit more than what I just need - I just want one single config file for both VS Code and tsc.

@mhegazy
Copy link
Contributor

mhegazy commented Feb 1, 2017

This refers to #13776 . @mhegazy You said:

Most build systems do check time stamps before calling the compiler

But tsc -p doesn't - what it only does is to compile all .ts files found and update all output files.

tsc -p is not a build system. it is a compiler, similar to csc, gcc, javac, etc.. your build system, e.g. gulp will not call tsc if it knows it does not need to, i.e. that the outputs are newer than the inputs.

@mhegazy
Copy link
Contributor

mhegazy commented Feb 1, 2017

And I think: unless I write a very long command line to replace a simple tsconfig.json, I won't be able to keep mtime of unchanged files. The command line would be like this:

I am not sure i understand the issue here. tsc --p is the same as tsc --<arguments in tsconfig.json>. they behave the same, and both will update the file regardless if the output is different or not.

@mhegazy mhegazy added the Working as Intended The behavior described is the intended behavior; this is not a bug label Feb 1, 2017
@gdh1995
Copy link
Contributor Author

gdh1995 commented Feb 2, 2017

Well, if so, I have to say that tsc is nothing more than a toy. Anyway, closed.

@gdh1995 gdh1995 closed this as completed Feb 2, 2017
@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
Working as Intended The behavior described is the intended behavior; this is not a bug
Projects
None yet
Development

No branches or pull requests

2 participants