Rename `BabelRawMapping` to `BabelSourceMapSegment`

Reviewed By: mjesun

Differential Revision: D6702880

fbshipit-source-id: 4c800ef9571bcfed6f3ed8e39d0002a94bd9190f
This commit is contained in:
Peter van der Zee 2018-01-12 04:09:45 -08:00 committed by Facebook Github Bot
parent 4260847ad7
commit 4403f81102
2 changed files with 10 additions and 6 deletions

View File

@ -114,7 +114,7 @@ type TransformResult = {
type GeneratorResult = {
code: string,
map: ?_BabelSourceMap,
rawMappings: ?Array<_RawMapping>,
rawMappings: ?Array<_BabelSourceMapSegment>,
};
type VisitFn = <State>(path: Object, state: State) => any;
@ -146,7 +146,7 @@ declare module 'babel-core' {
): TransformResult;
}
type _RawMapping = {
type _BabelSourceMapSegment = {
generated: {column: number, line: number},
name?: string,
original?: {column: number, line: number},
@ -155,7 +155,7 @@ type _RawMapping = {
// https://github.com/babel/babel/tree/master/packages/babel-generator
declare module 'babel-generator' {
declare export type RawMapping = _RawMapping;
declare export type BabelSourceMapSegment = _BabelSourceMapSegment;
declare export default (
ast: Ast,
options?: GeneratorOptions,

View File

@ -16,7 +16,7 @@ const Generator = require('./Generator');
const SourceMap = require('source-map');
import type {BabelSourceMap} from 'babel-core';
import type {RawMapping as BabelRawMapping} from 'babel-generator';
import type {BabelSourceMapSegment} from 'babel-generator';
import type {RawMapping as UnknownSourceMapMappingType} from 'source-map';
export type UnknownSourceMapMappingTypes = Array<UnknownSourceMapMappingType>;
@ -89,7 +89,9 @@ function fromRawMappings(
* Transforms a standard source map object into a Raw Mappings object, to be
* used across the bundler.
*/
function toRawMappings(sourceMap: BabelSourceMap): Array<BabelRawMapping> {
function toRawMappings(
sourceMap: BabelSourceMap,
): Array<BabelSourceMapSegment> {
const rawMappings = [];
new SourceMap.SourceMapConsumer(sourceMap).eachMapping(map => {
@ -110,7 +112,9 @@ function toRawMappings(sourceMap: BabelSourceMap): Array<BabelRawMapping> {
return rawMappings;
}
function compactMapping(mapping: BabelRawMapping): MetroSourceMapSegmentTuple {
function compactMapping(
mapping: BabelSourceMapSegment,
): MetroSourceMapSegmentTuple {
const {column, line} = mapping.generated;
const {name, original} = mapping;