Unify source map types

Summary: deduplicates / unifies types for source maps across the code base

Reviewed By: jeanlauliac

Differential Revision: D4955924

fbshipit-source-id: 25cb71031dce835dd7d2bc1c27d6b20050906e81
This commit is contained in:
David Aurelio
2017-04-28 12:35:23 -07:00
committed by Facebook Github Bot
parent 6202e02326
commit 58ba7fc075
19 changed files with 92 additions and 110 deletions
+4 -26
View File
@@ -10,37 +10,15 @@
*/
'use strict';
import type {FBSourceMap, IndexMapSection, IndexMap} from '../../lib/SourceMap';
export type {FBSourceMap};
type CreateIndexMapOptions = {|
file?: string,
sections?: Array<IndexMapSection>
|};
type IndexMap = MapBase & {
sections: Array<IndexMapSection>,
};
type IndexMapSection = {
map: IndexMap | MappingsMap,
offset: {line: number, column: number},
};
type MapBase = {
// always the first entry in the source map entry object per
// https://fburl.com/source-map-spec#heading=h.qz3o9nc69um5
version: 3,
file?: string,
};
type MappingsMap = MapBase & {
mappings: string,
names: Array<string>,
sourceRoot?: string,
sources: Array<string>,
sourcesContent?: Array<?string>,
};
export type SourceMap = IndexMap | MappingsMap;
exports.createIndexMap = (opts?: CreateIndexMapOptions): IndexMap => ({
version: 3,
file: opts && opts.file,
+3 -3
View File
@@ -10,7 +10,7 @@
*/
'use strict';
import type {SourceMap} from './output/source-map';
import type {MappingsMap, SourceMap} from '../lib/SourceMap';
import type {Ast} from 'babel-core';
import type {Console} from 'console';
@@ -102,7 +102,7 @@ type ResolveOptions = {
export type TransformerResult = {|
ast: ?Ast,
code: string,
map: ?SourceMap,
map: ?MappingsMap,
|};
export type Transformer = {
@@ -111,7 +111,7 @@ export type Transformer = {
filename: string,
options: ?{},
plugins?: Array<string | Object | [string | Object, any]>,
) => {ast: ?Ast, code: string, map: ?SourceMap}
) => {ast: ?Ast, code: string, map: ?MappingsMap}
};
export type TransformResult = {|