mirror of https://github.com/status-im/metro.git
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:
parent
5c2fb8d327
commit
4697ecf120
|
@ -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];
|
||||||
|
|
|
@ -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,
|
||||||
{},
|
{},
|
||||||
|
|
|
@ -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(
|
||||||
|
|
|
@ -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: {}> = {|
|
||||||
|
|
|
@ -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);
|
||||||
|
|
|
@ -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,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue