Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

using of v8-compile-cache breaks source-maps functionality #40

Open
yarick123 opened this issue Jan 21, 2022 · 0 comments
Open

using of v8-compile-cache breaks source-maps functionality #40

yarick123 opened this issue Jan 21, 2022 · 0 comments

Comments

@yarick123
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant