Skip to content

Commit

Permalink
Ensure --incremental works properly with custom file extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
dfreeman committed Nov 22, 2022
1 parent 8b59d87 commit 9432f17
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions packages/core/src/common/transform-manager.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { statSync as fsStatSync, Stats } from 'fs';
import { statSync as fsStatSync, Stats, existsSync } from 'fs';
import {
TransformedModule,
rewriteModule,
Expand Down Expand Up @@ -241,10 +241,19 @@ export default class TransformManager {
};

public getModifiedTime = (filename: string): Date | undefined => {
let fileStat = statSync(filename);
// In most circumstances we can just ask the DocumentCache what the canonical path
// for a given document is, but since `getModifiedTime` is invoked as part of
// rehydrating a `.tsbuildinfo` file, typically won't actually know the answer to
// that question yet.
let canonicalFilename = this.documents
.getCandidateDocumentPaths(filename)
.find((path) => existsSync(path));
if (!canonicalFilename) return undefined;

let fileStat = statSync(canonicalFilename);
if (!fileStat) return undefined;

let companionPath = this.documents.getCompanionDocumentPath(filename);
let companionPath = this.documents.getCompanionDocumentPath(canonicalFilename);
if (!companionPath) return fileStat.mtime;

let companionStat = statSync(companionPath);
Expand Down

0 comments on commit 9432f17

Please sign in to comment.