MCPcopy
hub / github.com/mozilla/source-map / composeSourceMaps

Function composeSourceMaps

test/test-nested-consumer-usage.js:38–74  ·  view source on GitHub ↗
(tsMap, babelMap, tsFileName)

Source from the content-addressed store, hash-verified

36};
37
38async function composeSourceMaps(tsMap, babelMap, tsFileName) {
39 const tsConsumer = await new SourceMapConsumer(tsMap);
40 const babelConsumer = await new SourceMapConsumer(babelMap);
41 const map = new SourceMapGenerator();
42 babelConsumer.eachMapping(
43 ({
44 source,
45 generatedLine,
46 generatedColumn,
47 originalLine,
48 originalColumn,
49 name,
50 }) => {
51 if (originalLine) {
52 const original = tsConsumer.originalPositionFor({
53 line: originalLine,
54 column: originalColumn,
55 });
56 if (original.line) {
57 map.addMapping({
58 generated: {
59 line: generatedLine,
60 column: generatedColumn,
61 },
62 original: {
63 line: original.line,
64 column: original.column,
65 },
66 source: tsFileName,
67 name,
68 });
69 }
70 }
71 }
72 );
73 return map.toJSON();
74}
75
76exports["test nested consumer usage"] = async function (assert) {
77 await composeSourceMaps(TS_MAP, BABEL_MAP, "blah.tsx");

Callers 1

Calls 4

addMappingMethod · 0.95
toJSONMethod · 0.95
eachMappingMethod · 0.65
originalPositionForMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…