Skip to content

Commit ae462f0

Browse files
committed
gen-mapping: encode range mappings in toEncodedMap
1 parent 62cdf45 commit ae462f0

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

packages/gen-mapping/src/gen-mapping.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { SetArray, put, remove } from './set-array';
2-
import { encode } from '@jridgewell/sourcemap-codec';
2+
import { encode, encodeRangeMappings } from '@jridgewell/sourcemap-codec';
33
import { TraceMap, decodedMappings } from '@jridgewell/trace-mapping';
44

55
import {
@@ -290,6 +290,7 @@ export function toEncodedMap(map: GenMapping): EncodedSourceMap {
290290
const decoded = toDecodedMap(map);
291291
const encoded = decoded as unknown as EncodedSourceMap;
292292
encoded.mappings = encode(decoded.mappings as SourceMapSegment[][]);
293+
encoded.rangeMappings = encodeRangeMappings((decoded.rangeMappings || []) as number[][]);
293294
return encoded;
294295
}
295296

packages/gen-mapping/src/types.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,6 @@ export interface SourceMapV3 {
4141
* An optional array of indices of sources that should be ignored.
4242
*/
4343
ignoreList?: readonly number[];
44-
45-
/**
46-
* An optional array of mapping indicies which cover a range of generated
47-
* code and source code.
48-
*/
49-
rangeMappings?: MappingIndex[][];
5044
}
5145

5246
/**
@@ -57,6 +51,11 @@ export interface EncodedSourceMap extends SourceMapV3 {
5751
* The mappings for the sourcemap, encoded as a VLQ string.
5852
*/
5953
mappings: string;
54+
55+
/**
56+
* An optional VLQ encoded string for the range mapping indices.
57+
*/
58+
rangeMappings?: string;
6059
}
6160

6261
/**
@@ -68,6 +67,12 @@ export interface DecodedSourceMap extends SourceMapV3 {
6867
* The mappings for the sourcemap, decoded into our internal format.
6968
*/
7069
mappings: readonly SourceMapSegment[][];
70+
71+
/**
72+
* An optional array of mapping indicies which cover a range of generated
73+
* code and source code.
74+
*/
75+
rangeMappings?: MappingIndex[][];
7176
}
7277

7378
/**

0 commit comments

Comments
 (0)