1/* @internal */ 2namespace ts { 3 type PerfLogger = typeof import("@microsoft/typescript-etw"); 4 const nullLogger: PerfLogger = { 5 logEvent: noop, 6 logErrEvent: noop, 7 logPerfEvent: noop, 8 logInfoEvent: noop, 9 logStartCommand: noop, 10 logStopCommand: noop, 11 logStartUpdateProgram: noop, 12 logStopUpdateProgram: noop, 13 logStartUpdateGraph: noop, 14 logStopUpdateGraph: noop, 15 logStartResolveModule: noop, 16 logStopResolveModule: noop, 17 logStartParseSourceFile: noop, 18 logStopParseSourceFile: noop, 19 logStartReadFile: noop, 20 logStopReadFile: noop, 21 logStartBindFile: noop, 22 logStopBindFile: noop, 23 logStartScheduledOperation: noop, 24 logStopScheduledOperation: noop, 25 }; 26 27 // Load optional module to enable Event Tracing for Windows 28 // See https://github.com/microsoft/typescript-etw for more information 29 let etwModule; 30 try { 31 const etwModulePath = process.env.TS_ETW_MODULE_PATH ?? "./node_modules/@microsoft/typescript-etw"; 32 33 // require() will throw an exception if the module is not found 34 // It may also return undefined if not installed properly 35 etwModule = require(etwModulePath); 36 } 37 catch (e) { 38 etwModule = undefined; 39 } 40 41 /** Performance logger that will generate ETW events if possible - check for `logEvent` member, as `etwModule` will be `{}` when browserified */ 42 export const perfLogger: PerfLogger = etwModule && etwModule.logEvent ? etwModule : nullLogger; 43} 44