Skip to content

Commit 4768b58

Browse files
committed
Re-encode bench mark source maps
This commit adds a small converter tool that can read scopes in an older format and output it in the new format.
1 parent 37e60ea commit 4768b58

10 files changed

+51
-8
lines changed

bench/convert_maps.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// Copyright 2025 The Chromium Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
/**
6+
* @fileoverview Small utility that converts the scopes encoding of the
7+
* source maps in the "maps/" directory from a given version to the currently
8+
* checked out version.
9+
*
10+
* The given version must be a released version on JSR.
11+
*/
12+
13+
import { expandGlob } from "jsr:@std/fs";
14+
import { parseArgs } from "jsr:@std/cli/parse-args";
15+
import { encode } from "../src/mod.ts";
16+
17+
if (import.meta.main) {
18+
const flags = parseArgs(Deno.args, {
19+
string: ["from"]
20+
});
21+
22+
if (!flags.from) {
23+
throw new Error("--from is mandatory");
24+
}
25+
26+
const oldCodec = await import(`jsr:@chrome-devtools/source-map-scopes-codec@${flags.from}`);
27+
28+
for await (
29+
const file of expandGlob("maps/*.js.map", { root: import.meta.dirname })
30+
) {
31+
const mapContent = Deno.readTextFileSync(file.path);
32+
const mapJson = JSON.parse(mapContent);
33+
const info = oldCodec.decode(mapJson);
34+
35+
encode(info, mapJson);
36+
37+
Deno.writeTextFileSync(file.path, JSON.stringify(mapJson));
38+
}
39+
}

bench/maps/common-formatted.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bench/maps/common.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bench/maps/sdk-formatted.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bench/maps/sdk.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bench/maps/simple-formatted.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bench/maps/simple.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bench/maps/typescript-formatted.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bench/maps/typescript.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

deno.lock

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)