-
Notifications
You must be signed in to change notification settings - Fork 15
/
debug.js
84 lines (75 loc) · 1.54 KB
/
debug.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
// For debugging issues write minimal reproduction here...
const SourceMap = require('./').default;
const assert = require('assert');
const SIMPLE_SOURCE_MAP = {
version: 3,
file: 'helloworld.js',
sources: ['helloworld.coffee'],
names: [],
mappings: 'AAAA;AAAA,EAAA,OAAO,CAAC,GAAR,CAAY,aAAZ,CAAA,CAAA;AAAA',
};
async function run() {
let originalMap = new SourceMap('/test-root');
originalMap.addIndexedMappings([
{
source: 'index.js',
name: 'A',
original: {
line: 1,
column: 0,
},
generated: {
line: 6,
column: 15,
},
},
]);
let newMap = new SourceMap('/test-root');
newMap.addIndexedMappings([
{
source: 'index.js',
name: 'B',
original: {
line: 6,
column: 15,
},
generated: {
line: 5,
column: 12,
},
},
]);
newMap.extends(originalMap.toBuffer());
let mappings = newMap.getMap().mappings;
assert.equal(mappings.length, 1);
assert.deepEqual(mappings[0], {
source: 0,
name: 1,
original: {
line: 1,
column: 0,
},
generated: {
line: 5,
column: 12,
},
});
let stringifiedMap = JSON.parse(
await newMap.stringify({
file: 'index.js.map',
sourceRoot: '/',
})
);
assert.deepEqual(stringifiedMap, {
version: 3,
file: 'index.js.map',
sourceRoot: '/',
sources: ['index.js'],
sourcesContent: [null],
names: ['B', 'A'],
mappings: ';;;;YAAAC',
});
}
run().catch((err) => {
console.error(err);
});