v8-compile-cache
v8-compile-cache copied to clipboard
using of v8-compile-cache breaks source-maps functionality
The following code: index.ts:
require('v8-compile-cache');
import { testFunction } from './testFunction';
function main(): void {
try {
testFunction();
} catch (err: any) {
console.error('Caught error:', err);
}
}
main();
testFunction.ts:
export function testFunction() {
throw new Error('TEST ERROR');
}
prints:
Caught error: Error: TEST ERROR at testFunction (Q:\source-maps-test\dist\testFunction.js:5:11) at null.main (Q:\source-maps-test\index.ts:6:15) at Object.(Q:\source-maps-test\index.ts:12:1) at Module._compile (node:internal/modules/cjs/loader:1101:14) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10) at Module.load (node:internal/modules/cjs/loader:981:32) at Function.Module._load (node:internal/modules/cjs/loader:822:12) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) at node:internal/main/run_main_module:17:47
with the commented index.ts' first line (//require('v8-compile-cache');
) it prints:
Caught error: Q:\source-maps-test\testFunction.ts:2 throw new Error('TEST ERROR'); ^ Error: TEST ERROR at null.testFunction (Q:\source-maps-test\testFunction.ts:2:8) at null.main (Q:\source-maps-test\index.ts:6:15) at Object.(Q:\source-maps-test\index.ts:12:1) at Module._compile (node:internal/modules/cjs/loader:1101:14) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10) at Module.load (node:internal/modules/cjs/loader:981:32) at Function.Module._load (node:internal/modules/cjs/loader:822:12) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) at node:internal/main/run_main_module:17:47
So, the source-maps stack trace translation is broken after the first level. With turned on v8-compile-cache a javascript file is displayed instead of a typescript file.
I attach the whole test project here. source-maps-test.zip