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 {BabelSourceMap} from 'babel-core';
import type {BabelSourceMapSegment} from 'babel-generator'; import type {BabelSourceMapSegment} from 'babel-generator';
import type {RawMapping as UnknownSourceMapMappingType} from 'source-map';
export type UnknownSourceMapMappingTypes = Array<UnknownSourceMapMappingType>;
type GeneratedCodeMapping = [number, number]; type GeneratedCodeMapping = [number, number];
type SourceMapping = [number, number, 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 {HasteImpl} from '../node-haste/Module';
import type {BabelSourceMap} from 'babel-core'; import type {BabelSourceMap} from 'babel-core';
import type { import type {
UnknownSourceMapMappingTypes, MetroSourceMapSegmentTuple,
MetroSourceMap as SourceMap, MetroSourceMap as SourceMap,
} from 'metro-source-map'; } from 'metro-source-map';
@ -255,8 +255,8 @@ class Bundler {
async minifyModule( async minifyModule(
path: string, path: string,
code: string, code: string,
map: UnknownSourceMapMappingTypes, map: Array<MetroSourceMapSegmentTuple>,
): Promise<{code: string, map: UnknownSourceMapMappingTypes}> { ): Promise<{code: string, map: Array<MetroSourceMapSegmentTuple>}> {
const sourceMap = fromRawMappings([{code, source: code, map, path}]).toMap( const sourceMap = fromRawMappings([{code, source: code, map, path}]).toMap(
undefined, undefined,
{}, {},

View File

@ -30,7 +30,7 @@ import type DependencyGraph from '../node-haste/DependencyGraph';
import type Module from '../node-haste/Module'; import type Module from '../node-haste/Module';
import type {Options as BundleOptions, MainOptions} from './'; import type {Options as BundleOptions, MainOptions} from './';
import type {DependencyEdges} from './traverseDependencies'; import type {DependencyEdges} from './traverseDependencies';
import type {UnknownSourceMapMappingTypes} from 'metro-source-map'; import type {MetroSourceMapSegmentTuple} from 'metro-source-map';
export type DeltaEntryType = export type DeltaEntryType =
| 'asset' | 'asset'
@ -42,7 +42,7 @@ export type DeltaEntryType =
export type DeltaEntry = {| export type DeltaEntry = {|
+code: string, +code: string,
+id: number, +id: number,
+map: UnknownSourceMapMappingTypes, +map: Array<MetroSourceMapSegmentTuple>,
+name: string, +name: string,
+path: string, +path: string,
+source: string, +source: string,
@ -530,7 +530,7 @@ class DeltaTransformer extends EventEmitter {
): Promise<{ ): Promise<{
+code: string, +code: string,
+dependencies: Array<string>, +dependencies: Array<string>,
+map: UnknownSourceMapMappingTypes, +map: Array<MetroSourceMapSegmentTuple>,
+source: string, +source: string,
}> { }> {
return await module.read( 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 {LogEntry} from 'metro-core/src/Logger';
import type {BabelSourceMap} from 'babel-core'; 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 {LocalPath} from '../../node-haste/lib/toLocalPath';
import type {ResultWithMap} from './minify'; import type {ResultWithMap} from './minify';
import type {Ast, Plugins as BabelPlugins} from 'babel-core'; 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 = { export type TransformedCode = {
code: string, code: string,
dependencies: $ReadOnlyArray<string>, dependencies: $ReadOnlyArray<string>,
map: UnknownSourceMapMappingTypes, map: Array<MetroSourceMapSegmentTuple>,
}; };
export type TransformArgs<ExtraOptions: {}> = {| 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 {Options as WorkerOptions} from '../JSTransformer/worker';
import type {Reporter} from './reporting'; import type {Reporter} from './reporting';
import type {LocalPath} from '../node-haste/lib/toLocalPath'; 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}; type CacheFilePaths = {transformedCode: string, metadata: string};
export type GetTransformCacheKey = (options: {}) => string; export type GetTransformCacheKey = (options: {}) => string;
@ -34,7 +34,7 @@ const CACHE_SUB_DIR = 'cache';
export type CachedResult = { export type CachedResult = {
code: string, code: string,
dependencies: $ReadOnlyArray<string>, dependencies: $ReadOnlyArray<string>,
map: UnknownSourceMapMappingTypes, map: Array<MetroSourceMapSegmentTuple>,
}; };
export type TransformCacheResult = ?CachedResult; export type TransformCacheResult = ?CachedResult;
@ -324,7 +324,7 @@ function readMetadataFileSync(
cachedResultHash: string, cachedResultHash: string,
cachedSourceHash: string, cachedSourceHash: string,
dependencies: Array<string>, dependencies: Array<string>,
sourceMap: UnknownSourceMapMappingTypes, sourceMap: Array<MetroSourceMapSegmentTuple>,
} { } {
const metadataStr = fs.readFileSync(metadataFilePath, 'utf8'); const metadataStr = fs.readFileSync(metadataFilePath, 'utf8');
const metadata = tryParseJSON(metadataStr); const metadata = tryParseJSON(metadataStr);

View File

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