Skip to content

Commit

Permalink
Upgrade gen-mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
jridgewell committed Apr 27, 2022
1 parent ee9a0b0 commit cb14ea8
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 27 deletions.
24 changes: 13 additions & 11 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"typescript": "4.6.3"
},
"dependencies": {
"@jridgewell/gen-mapping": "^0.1.0",
"@jridgewell/gen-mapping": "^0.2.0",
"@jridgewell/trace-mapping": "^0.3.9"
}
}
4 changes: 2 additions & 2 deletions src/source-map.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { decodedMap, encodedMap } from '@jridgewell/gen-mapping';
import { toDecodedMap, toEncodedMap } from '@jridgewell/gen-mapping';

import type { GenMapping } from '@jridgewell/gen-mapping';
import type { DecodedSourceMap, EncodedSourceMap, Options } from './types';
Expand All @@ -17,7 +17,7 @@ export default class SourceMap {
declare version: 3;

constructor(map: GenMapping, options: Options) {
const out = options.decodedMappings ? decodedMap(map) : encodedMap(map);
const out = options.decodedMappings ? toDecodedMap(map) : toEncodedMap(map);
this.version = out.version; // SourceMap spec says this should be first.
this.file = out.file;
this.mappings = out.mappings as SourceMap['mappings'];
Expand Down
26 changes: 13 additions & 13 deletions test/unit/source-map-tree.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { decodedMap } from '@jridgewell/gen-mapping';
import { toDecodedMap } from '@jridgewell/gen-mapping';
import { TraceMap } from '@jridgewell/trace-mapping';

import {
Expand Down Expand Up @@ -44,7 +44,7 @@ describe('MapSource', () => {
};

const tree = MapSource(new TraceMap(map), [child]);
const traced = decodedMap(traceMappings(tree));
const traced = toDecodedMap(traceMappings(tree));
expect(traced.mappings).toEqual([[[0, 0, 1, 1], [5]]]);
});

Expand All @@ -60,7 +60,7 @@ describe('MapSource', () => {
};

const tree = MapSource(new TraceMap(map), [child]);
const traced = decodedMap(traceMappings(tree));
const traced = toDecodedMap(traceMappings(tree));
expect(traced.mappings).toEqual([[[0, 0, 1, 1], [5]]]);
});

Expand All @@ -74,7 +74,7 @@ describe('MapSource', () => {
};

const tree = MapSource(new TraceMap(map), [child]);
const traced = decodedMap(traceMappings(tree));
const traced = toDecodedMap(traceMappings(tree));
expect(traced.mappings).toEqual([]);
});

Expand All @@ -91,7 +91,7 @@ describe('MapSource', () => {
};

const tree = MapSource(new TraceMap(map), [child]);
const traced = decodedMap(traceMappings(tree));
const traced = toDecodedMap(traceMappings(tree));
expect(traced.mappings).toEqual([[[0, 0, 0, 0, 0]]]);
expect(traced).toMatchObject({
names: [name],
Expand All @@ -108,7 +108,7 @@ describe('MapSource', () => {
};

const tree = MapSource(new TraceMap(map), [child]);
const traced = decodedMap(traceMappings(tree));
const traced = toDecodedMap(traceMappings(tree));
expect(traced.mappings).toEqual([[[0, 0, 1, 1]]]);
});

Expand All @@ -122,7 +122,7 @@ describe('MapSource', () => {
};

const tree = MapSource(new TraceMap(map), [child]);
const traced = decodedMap(traceMappings(tree));
const traced = toDecodedMap(traceMappings(tree));
expect(traced.mappings).toEqual([[[0, 0, 0, 0, 0]]]);
expect(traced).toMatchObject({
names: ['child'],
Expand All @@ -142,7 +142,7 @@ describe('MapSource', () => {
};

const tree = MapSource(new TraceMap(map), [child]);
const traced = decodedMap(traceMappings(tree));
const traced = toDecodedMap(traceMappings(tree));
expect(traced).toMatchObject(extras);
});

Expand All @@ -153,7 +153,7 @@ describe('MapSource', () => {
};

const tree = MapSource(new TraceMap(map), [child]);
const traced = decodedMap(traceMappings(tree));
const traced = toDecodedMap(traceMappings(tree));
expect(traced).toMatchObject({
// TODO: support sourceRoot
sourceRoot: undefined,
Expand All @@ -169,7 +169,7 @@ describe('MapSource', () => {
};

const tree = MapSource(new TraceMap(map), [child]);
const traced = decodedMap(traceMappings(tree));
const traced = toDecodedMap(traceMappings(tree));
expect(traced.mappings).toEqual([[[0, 0, 0, 0]]]);
});

Expand All @@ -181,7 +181,7 @@ describe('MapSource', () => {
};

const tree = MapSource(new TraceMap(map), [child]);
const traced = decodedMap(traceMappings(tree));
const traced = toDecodedMap(traceMappings(tree));
expect(traced.mappings).toEqual([]);
});

Expand All @@ -198,7 +198,7 @@ describe('MapSource', () => {
};

const tree = MapSource(new TraceMap(map), [child]);
const traced = decodedMap(traceMappings(tree));
const traced = toDecodedMap(traceMappings(tree));
expect(traced.mappings).toEqual([[[0, 0, 0, 0]]]);
});

Expand All @@ -209,7 +209,7 @@ describe('MapSource', () => {
};

const tree = MapSource(new TraceMap(map), [child]);
const traced = decodedMap(traceMappings(tree));
const traced = toDecodedMap(traceMappings(tree));
expect(traced.mappings).toEqual([[[0, 0, 0, 0]], [[0, 0, 0, 0]]]);
});
});
Expand Down

0 comments on commit cb14ea8

Please sign in to comment.