Use approx in frame source map resolution and update cleanFrames
MODIFY
packages/@romejs/codec-source-map/SourceMapConsumerCollection.ts
packages/@romejs/codec-source-map/SourceMapConsumerCollection.ts
@@ -40,7 +40,7 @@ export default class SourceMapConsumerCollection {
}
if (start !== undefined) {
- const resolved = this.exactOriginalPositionFor(
+ const resolved = this.approxOriginalPositionFor(
filename,
start.line,
start.column,
@@ -56,7 +56,7 @@ export default class SourceMapConsumerCollection {
}
if (end !== undefined) {
- const resolved = this.exactOriginalPositionFor(
+ const resolved = this.approxOriginalPositionFor(
filename,
end.line,
end.column,

MODIFY
packages/@romejs/core/test-worker/TestWorkerRunner.ts
packages/@romejs/core/test-worker/TestWorkerRunner.ts
@@ -180,21 +180,18 @@ export default class TestWorkerRunner {
filename,
cleanFrames(frames) {
// TODO we should actually get the frames before module init and do it that way
-
// Remove everything before the original module factory
let latestTestWorkerFrame = frames.find((frame, i) => {
if (frame.typeName === 'global' && frame.methodName === undefined &&
frame.functionName ===
undefined) {
// We are the global.<anonymous> frame
-
// Now check for Script.runInContext
const nextFrame = frames[i + 1];
if (nextFrame !== undefined && nextFrame.typeName === 'Script' &&
nextFrame.methodName ===
'runInContext') {
// Yes!
-
// TODO also check for ___$romejs$core$common$utils$executeMain_ts$default (packages/romejs/core/common/utils/executeMain.ts:69:17)
return true;
}
@@ -206,8 +203,8 @@ export default class TestWorkerRunner {
// And if there was no module factory frame, then we must be inside of a test
if (latestTestWorkerFrame === undefined) {
latestTestWorkerFrame = frames.find((frame) => {
- return frame.filename !== undefined && frame.filename.includes(
- 'core/test-worker',
+ return frame.typeName !== undefined && frame.typeName.includes(
+ '$TestWorkerRunner',
);
});
}

MODIFY
packages/@romejs/diagnostics/DiagnosticsProcessor.ts
packages/@romejs/diagnostics/DiagnosticsProcessor.ts
@@ -226,9 +226,11 @@ export default class DiagnosticsProcessor {
if (!sourceMaps.hasAny()) {
return diag;
}
+
function check(filename: undefined | string) {
return filename !== undefined && sourceMaps.has(filename);
}
+
// Check location
let {location} = diag;
const hasLocation = check(location.filename);
@@ -272,11 +274,11 @@ export default class DiagnosticsProcessor {
frames: item.frames.map((frame) => {
const {filename, line, column} = frame;
if (filename === undefined || line === undefined || column ===
- undefined) {
+ undefined || !sourceMaps.has(filename)) {
return frame;
}
- const resolved = sourceMaps.exactOriginalPositionFor(
+ const resolved = sourceMaps.approxOriginalPositionFor(
filename,
line,
column,

Use approx in frame source map resolution and update cleanFrames