Skip to content

Commit

Permalink
Switch to @jridgewell/trace-mapping in fixture-test-runner
Browse files Browse the repository at this point in the history
This accomplishes 2 goals:
- Gets us off the ancient `source-map` v0.5.7
- Speeds up construction and tracing by ~10x.
  • Loading branch information
jridgewell committed Feb 8, 2022
1 parent 165b735 commit 899be1b
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
"@babel/code-frame": "workspace:^",
"@babel/core": "workspace:^",
"@babel/helper-fixtures": "workspace:^",
"@jridgewell/trace-mapping": "^0.3.2",
"babel-check-duplicated-nodes": "^1.0.0",
"quick-lru": "5.1.0",
"regenerator-runtime": "^0.13.7",
"source-map": "^0.5.0"
"regenerator-runtime": "^0.13.7"
},
"devDependencies": {
"@types/jest": "^25.2.2"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import {
default as getFixtures,
resolveOptionPluginOrPreset,
} from "@babel/helper-fixtures";
import sourceMap from "source-map";
import { codeFrameColumns } from "@babel/code-frame";
import { TraceMap, originalPositionFor } from "@jridgewell/trace-mapping";
import * as helpers from "./helpers";
import assert from "assert";
import fs from "fs";
Expand Down Expand Up @@ -346,12 +346,12 @@ function run(task) {
}

if (task.sourceMappings) {
const consumer = new sourceMap.SourceMapConsumer(result.map);
const consumer = new TraceMap(result.map);

task.sourceMappings.forEach(function (mapping) {
const actual = mapping.original;

const expected = consumer.originalPositionFor(mapping.generated);
const expected = originalPositionFor(consumer, mapping.generated);
expect({ line: expected.line, column: expected.column }).toEqual(actual);
});
}
Expand Down
19 changes: 18 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -956,11 +956,11 @@ __metadata:
"@babel/code-frame": "workspace:^"
"@babel/core": "workspace:^"
"@babel/helper-fixtures": "workspace:^"
"@jridgewell/trace-mapping": ^0.3.2
"@types/jest": ^25.2.2
babel-check-duplicated-nodes: ^1.0.0
quick-lru: 5.1.0
regenerator-runtime: ^0.13.7
source-map: ^0.5.0
languageName: unknown
linkType: soft

Expand Down Expand Up @@ -4091,6 +4091,13 @@ __metadata:
languageName: node
linkType: hard

"@jridgewell/sourcemap-codec@npm:^1.4.10":
version: 1.4.10
resolution: "@jridgewell/sourcemap-codec@npm:1.4.10"
checksum: 247229218edbe165dcf0a5ae0c4b81bff1b5438818bb09221f756681fe158597fdf25c2a803f9260453b299c98c7e01ddebeb1555cda3157d987cd22c08605ef
languageName: node
linkType: hard

"@jridgewell/trace-mapping@npm:^0.2.2":
version: 0.2.5
resolution: "@jridgewell/trace-mapping@npm:0.2.5"
Expand All @@ -4101,6 +4108,16 @@ __metadata:
languageName: node
linkType: hard

"@jridgewell/trace-mapping@npm:^0.3.2":
version: 0.3.2
resolution: "@jridgewell/trace-mapping@npm:0.3.2"
dependencies:
"@jridgewell/resolve-uri": ^3.0.3
"@jridgewell/sourcemap-codec": ^1.4.10
checksum: b58be6b4133cbcb20bfd28c9ca843b8db9efa0bf1d7e0e9e26b2228dace94ad53161c996ab1d762d7c3955dfc398a7734e7b84a2493ae36b451f232234fbb257
languageName: node
linkType: hard

"@mdn/browser-compat-data@npm:^4.0.10":
version: 4.0.10
resolution: "@mdn/browser-compat-data@npm:4.0.10"
Expand Down

0 comments on commit 899be1b

Please sign in to comment.