Get rid of the "unknown" source-map raw mapping type, use "segments" instead of "raw"

Reviewed By: mjesun

Differential Revision: D6702883

fbshipit-source-id: def36c719eabbcd443b0c643b760a87781977a45
This commit is contained in:
Peter van der Zee 2018-01-12 04:09:48 -08:00 committed by Facebook Github Bot
parent 5c2fb8d327
commit 4697ecf120
6 changed files with 13 additions and 16 deletions

View File

@ -17,9 +17,6 @@ const SourceMap = require('source-map');
import type {BabelSourceMap} from 'babel-core';
import type {BabelSourceMapSegment} from 'babel-generator';
import type {RawMapping as UnknownSourceMapMappingType} from 'source-map';
export type UnknownSourceMapMappingTypes = Array<UnknownSourceMapMappingType>;
type GeneratedCodeMapping = [number, number];
type SourceMapping = [number, number, number, number];

View File

@ -34,7 +34,7 @@ import type {Reporter} from '../lib/reporting';
import type {HasteImpl} from '../node-haste/Module';
import type {BabelSourceMap} from 'babel-core';
import type {
UnknownSourceMapMappingTypes,
MetroSourceMapSegmentTuple,
MetroSourceMap as SourceMap,
} from 'metro-source-map';
@ -255,8 +255,8 @@ class Bundler {
async minifyModule(
path: string,
code: string,
map: UnknownSourceMapMappingTypes,
): Promise<{code: string, map: UnknownSourceMapMappingTypes}> {
map: Array<MetroSourceMapSegmentTuple>,
): Promise<{code: string, map: Array<MetroSourceMapSegmentTuple>}> {
const sourceMap = fromRawMappings([{code, source: code, map, path}]).toMap(
undefined,
{},

View File

@ -30,7 +30,7 @@ import type DependencyGraph from '../node-haste/DependencyGraph';
import type Module from '../node-haste/Module';
import type {Options as BundleOptions, MainOptions} from './';
import type {DependencyEdges} from './traverseDependencies';
import type {UnknownSourceMapMappingTypes} from 'metro-source-map';
import type {MetroSourceMapSegmentTuple} from 'metro-source-map';
export type DeltaEntryType =
| 'asset'
@ -42,7 +42,7 @@ export type DeltaEntryType =
export type DeltaEntry = {|
+code: string,
+id: number,
+map: UnknownSourceMapMappingTypes,
+map: Array<MetroSourceMapSegmentTuple>,
+name: string,
+path: string,
+source: string,
@ -530,7 +530,7 @@ class DeltaTransformer extends EventEmitter {
): Promise<{
+code: string,
+dependencies: Array<string>,
+map: UnknownSourceMapMappingTypes,
+map: Array<MetroSourceMapSegmentTuple>,
+source: string,
}> {
return await module.read(

View File

@ -28,7 +28,7 @@ const {toSegmentTuple} = require('metro-source-map');
import type {LogEntry} from 'metro-core/src/Logger';
import type {BabelSourceMap} from 'babel-core';
import type {UnknownSourceMapMappingTypes} from 'metro-source-map';
import type {MetroSourceMapSegmentTuple} from 'metro-source-map';
import type {LocalPath} from '../../node-haste/lib/toLocalPath';
import type {ResultWithMap} from './minify';
import type {Ast, Plugins as BabelPlugins} from 'babel-core';
@ -36,7 +36,7 @@ import type {Ast, Plugins as BabelPlugins} from 'babel-core';
export type TransformedCode = {
code: string,
dependencies: $ReadOnlyArray<string>,
map: UnknownSourceMapMappingTypes,
map: Array<MetroSourceMapSegmentTuple>,
};
export type TransformArgs<ExtraOptions: {}> = {|

View File

@ -24,7 +24,7 @@ const writeFileAtomicSync = require('write-file-atomic').sync;
import type {Options as WorkerOptions} from '../JSTransformer/worker';
import type {Reporter} from './reporting';
import type {LocalPath} from '../node-haste/lib/toLocalPath';
import type {UnknownSourceMapMappingTypes} from 'metro-source-map';
import type {MetroSourceMapSegmentTuple} from 'metro-source-map';
type CacheFilePaths = {transformedCode: string, metadata: string};
export type GetTransformCacheKey = (options: {}) => string;
@ -34,7 +34,7 @@ const CACHE_SUB_DIR = 'cache';
export type CachedResult = {
code: string,
dependencies: $ReadOnlyArray<string>,
map: UnknownSourceMapMappingTypes,
map: Array<MetroSourceMapSegmentTuple>,
};
export type TransformCacheResult = ?CachedResult;
@ -324,7 +324,7 @@ function readMetadataFileSync(
cachedResultHash: string,
cachedSourceHash: string,
dependencies: Array<string>,
sourceMap: UnknownSourceMapMappingTypes,
sourceMap: Array<MetroSourceMapSegmentTuple>,
} {
const metadataStr = fs.readFileSync(metadataFilePath, 'utf8');
const metadata = tryParseJSON(metadataStr);

View File

@ -35,12 +35,12 @@ import type {Reporter} from '../lib/reporting';
import type DependencyGraphHelpers from './DependencyGraph/DependencyGraphHelpers';
import type ModuleCache from './ModuleCache';
import type {LocalPath} from './lib/toLocalPath';
import type {UnknownSourceMapMappingTypes} from 'metro-source-map';
import type {MetroSourceMapSegmentTuple} from 'metro-source-map';
export type ReadResult = {
+code: string,
+dependencies: $ReadOnlyArray<string>,
+map: UnknownSourceMapMappingTypes,
+map: Array<MetroSourceMapSegmentTuple>,
+source: string,
};