Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ import { getTracePanel, prepareWebView } from './webview'
import { getCurrentConfig } from './configuration'
import { log } from './logger'
import type { CommandId } from './constants'
import { getParsedCommandLine } from './shared'
import { addTraceFile, getWorkspacePath, openTerminal, openTraceDirectoryExternal, setLastMessageTrigger } from './storage'
import { addTraceDiagnostics, clearTaceDiagnostics } from './traceDiagnostics'
import { setStatusBarState } from './statusBar'
import { afterWatches, projectPath, saveName, state, traceFiles, traceRunning } from './appState'
import { getIncrementalTraceWarning } from './incrementalBuild'

const readdir = promisify(readdirC)

Expand Down Expand Up @@ -121,7 +123,7 @@ async function runTrace(args?: unknown[]) {

const newDirName = dirName
// TODO: use logic from real time metrics that get the tsconfig path
afterWatches(() => {
afterWatches(async () => {
const traceDir = state.tracePath.value
if (!traceDir) {
vscode.window.showWarningMessage('No workspace or folder open')
Expand All @@ -140,6 +142,16 @@ async function runTrace(args?: unknown[]) {
return
}

try {
const parsedCommandLine = await getParsedCommandLine(newDirName ?? workspacePath)
const warning = getIncrementalTraceWarning(parsedCommandLine.options)
if (warning)
vscode.window.showWarningMessage(warning)
}
catch (e) {
log(`could not check incremental build settings: ${e}`)
}

traceRunning.value = true

traceFiles.value = {}
Expand Down
11 changes: 11 additions & 0 deletions src/incrementalBuild.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import type { CompilerOptions } from 'typescript'

export function getIncrementalTraceWarning(options: Pick<CompilerOptions, 'composite' | 'incremental' | 'tsBuildInfoFile'>) {
if (!options.incremental && !options.composite)
return undefined

const enabledBy = options.incremental ? 'incremental' : 'composite'
const buildInfo = options.tsBuildInfoFile ? ` (${options.tsBuildInfoFile})` : ''

return `Tracing with ${enabledBy} builds enabled may reuse .tsbuildinfo${buildInfo} and produce traces that do not represent a clean type-check. Consider disabling incremental builds or deleting the build info file before comparing traces.`
}
26 changes: 26 additions & 0 deletions test/incremental-build.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { describe, expect, it } from 'vitest'
import { getIncrementalTraceWarning } from '../src/incrementalBuild'

describe('getIncrementalTraceWarning', () => {
it('does not warn when incremental options are disabled', () => {
expect(getIncrementalTraceWarning({})).toBeUndefined()
expect(getIncrementalTraceWarning({ incremental: false, composite: false })).toBeUndefined()
})

it('warns when incremental builds are enabled', () => {
const warning = getIncrementalTraceWarning({
incremental: true,
tsBuildInfoFile: '.cache/project.tsbuildinfo',
})

expect(warning).toContain('incremental')
expect(warning).toContain('.cache/project.tsbuildinfo')
})

it('warns when composite builds imply incremental behavior', () => {
const warning = getIncrementalTraceWarning({ composite: true })

expect(warning).toContain('composite')
expect(warning).toContain('.tsbuildinfo')
})
})