eclipse-typescript icon indicating copy to clipboard operation
eclipse-typescript copied to clipboard

Last modified of generated js files

Open StephanRepublika opened this issue 9 years ago • 2 comments

Hi,

This is a great plugin, however, it recompiles and changes dates of every referenced TypeScript file almost always. That's not the problem, it's good to check more often than less.

But... the problem is the lastModified time of the generated JavaScript files, these files get a timestamp of the generated things. Even when nothing has changed.

Is it possible to change it so that it will set the lastModified time of the generated JavaScript files to the lastModified time of the TypeScript files?

Like this?

diff --git a/com.palantir.typescript/src/com/palantir/typescript/TypeScriptBuilder.java b/com.palantir.typescript/src/com/palantir/typescript/TypeScriptBuilder.java index c12235f..8af44d5 100644 --- a/com.palantir.typescript/src/com/palantir/typescript/TypeScriptBuilder.java +++ b/com.palantir.typescript/src/com/palantir/typescript/TypeScriptBuilder.java @@ -300,10 +300,17 @@ String filePath = EclipseResources.getFilePath(eclipseFile); File file = new File(filePath);

  •        IFile eclipseInputFile = EclipseResources.getFile(fileName);
    
  •        String inputFilePath = EclipseResources.getFilePath(eclipseInputFile);
    
  •        File inputFile = new File(inputFilePath);
    
  •        long lastModified = inputFile.lastModified();
    
    •    // write the file
         try {
             Files.createParentDirs(file);
             Files.write(outputFile.getText(), file, Charsets.UTF_8);
      
  •            file.setLastModified(lastModified);
         } catch (IOException e) {
             throw new RuntimeException(e);
         }
    

Kind regards,

Stephan van Loendersloot.

StephanRepublika avatar Mar 04 '16 22:03 StephanRepublika

I should have clarified the reason... apologies..

If caching is important on websites, usually file times, sizes and such are used to determine whether a file has changed or not. Even when combining resources, such as JS and CSS files; in this case generated JS files.

Hence the request to apply this.

Thanks.

Stephan.

StephanRepublika avatar Mar 04 '16 22:03 StephanRepublika

The timestamps of the TypeScript files should not be touched by any automated processes, right?

I'd be cool with this as a PR if you'd like to submit it.

derekcicerone-zz avatar Mar 04 '16 23:03 derekcicerone-zz