Skip to content

Not write output file if no content changes #13801

Closed
@gdh1995

Description

@gdh1995

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Working as IntendedThe behavior described is the intended behavior; this is not a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions