mirror of https://github.com/status-im/metro.git
Stop using `as SourceMap` and just use `MetroSourceMap` instead
Reviewed By: rafeca Differential Revision: D6702882 fbshipit-source-id: ef4a58569719bd8aeb8f1869943929c255f89595
This commit is contained in:
parent
4697ecf120
commit
a05eb11cab
|
@ -35,7 +35,7 @@ import type {HasteImpl} from '../node-haste/Module';
|
|||
import type {BabelSourceMap} from 'babel-core';
|
||||
import type {
|
||||
MetroSourceMapSegmentTuple,
|
||||
MetroSourceMap as SourceMap,
|
||||
MetroSourceMap,
|
||||
} from 'metro-source-map';
|
||||
|
||||
export type BundlingOptions = {|
|
||||
|
@ -73,9 +73,9 @@ export type PostMinifyProcess = ({
|
|||
|
||||
export type PostProcessBundleSourcemap = ({
|
||||
code: Buffer | string,
|
||||
map: SourceMap,
|
||||
map: MetroSourceMap,
|
||||
outFileName: string,
|
||||
}) => {code: Buffer | string, map: SourceMap | string};
|
||||
}) => {code: Buffer | string, map: MetroSourceMap | string};
|
||||
|
||||
export type Options = {|
|
||||
+assetExts: Array<string>,
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
import type {Ast} from 'babel-core';
|
||||
import type {BabelSourceMap} from 'babel-core';
|
||||
import type {Console} from 'console';
|
||||
import type {FBSourceMap, MetroSourceMap as SourceMap} from 'metro-source-map';
|
||||
import type {FBSourceMap, MetroSourceMap} from 'metro-source-map';
|
||||
|
||||
export type {Transformer} from '../JSTransformer/worker';
|
||||
|
||||
|
@ -106,7 +106,9 @@ export type PostProcessModules = (
|
|||
entryPoints: Array<string>,
|
||||
) => Iterable<Module>;
|
||||
|
||||
export type OutputFn<M: FBSourceMap | SourceMap = FBSourceMap | SourceMap> = ({|
|
||||
export type OutputFn<
|
||||
M: FBSourceMap | MetroSourceMap = FBSourceMap | MetroSourceMap,
|
||||
> = ({|
|
||||
filename: string,
|
||||
idsForPath: IdsForPathFn,
|
||||
modules: Iterable<Module>,
|
||||
|
@ -114,7 +116,7 @@ export type OutputFn<M: FBSourceMap | SourceMap = FBSourceMap | SourceMap> = ({|
|
|||
sourceMapPath?: ?string,
|
||||
|}) => OutputResult<M>;
|
||||
|
||||
type OutputResult<M: FBSourceMap | SourceMap> = {|
|
||||
type OutputResult<M: FBSourceMap | MetroSourceMap> = {|
|
||||
code: string | Buffer,
|
||||
extraFiles?: Iterable<[string, string | Buffer]>,
|
||||
map: M,
|
||||
|
|
|
@ -24,7 +24,7 @@ const sourceMap = require('source-map');
|
|||
|
||||
import type {TransformedSourceFile, TransformResult} from '../types.flow';
|
||||
import type {BabelSourceMap} from 'babel-core';
|
||||
import type {MetroSourceMap as SourceMap} from 'metro-source-map';
|
||||
import type {MetroSourceMap} from 'metro-source-map';
|
||||
import type {PostMinifyProcess} from '../../Bundler/index.js';
|
||||
|
||||
export type OptimizationOptions = {|
|
||||
|
@ -111,8 +111,8 @@ function optimizeCode(code, map, filename, inliningOptions) {
|
|||
|
||||
function mergeSourceMaps(
|
||||
file: string,
|
||||
originalMap: SourceMap,
|
||||
secondMap: SourceMap,
|
||||
originalMap: MetroSourceMap,
|
||||
secondMap: MetroSourceMap,
|
||||
): BabelSourceMap {
|
||||
const merged = new sourceMap.SourceMapGenerator();
|
||||
const inputMap = new sourceMap.SourceMapConsumer(originalMap);
|
||||
|
|
|
@ -40,7 +40,7 @@ import type {
|
|||
PostMinifyProcess,
|
||||
PostProcessBundleSourcemap,
|
||||
} from '../Bundler';
|
||||
import type {MetroSourceMap as SourceMap} from 'metro-source-map';
|
||||
import type {MetroSourceMap} from 'metro-source-map';
|
||||
import type {TransformCache} from '../lib/TransformCaching';
|
||||
import type {Symbolicate} from './symbolicate';
|
||||
import type {AssetData} from '../Assets';
|
||||
|
@ -731,7 +731,7 @@ class Server {
|
|||
);
|
||||
}
|
||||
|
||||
async _sourceMapForURL(reqUrl: string): Promise<SourceMap> {
|
||||
async _sourceMapForURL(reqUrl: string): Promise<MetroSourceMap> {
|
||||
const options: DeltaBundlerOptions = this._getOptionsFromUrl(reqUrl);
|
||||
|
||||
return await Serializers.fullSourceMapObject(this._deltaBundler, {
|
||||
|
|
|
@ -20,12 +20,12 @@ const xpipe = require('xpipe');
|
|||
const {LazyPromise, LockingPromise} = require('./util');
|
||||
const {fork} = require('child_process');
|
||||
|
||||
import type {MetroSourceMap as SourceMap} from 'metro-source-map';
|
||||
import type {MetroSourceMap} from 'metro-source-map';
|
||||
|
||||
export type Stack = Array<{file: string, lineNumber: number, column: number}>;
|
||||
export type Symbolicate = (
|
||||
Stack,
|
||||
Iterable<[string, SourceMap]>,
|
||||
Iterable<[string, MetroSourceMap]>,
|
||||
) => Promise<Stack>;
|
||||
|
||||
const affixes = {prefix: 'metro-symbolicate', suffix: '.sock'};
|
||||
|
|
|
@ -14,10 +14,10 @@
|
|||
|
||||
const path = require('path');
|
||||
|
||||
import type {MetroSourceMap as SourceMap} from 'metro-source-map';
|
||||
import type {MetroSourceMap} from 'metro-source-map';
|
||||
|
||||
function relativizeSourceMapInternal(
|
||||
sourceMap: SourceMap,
|
||||
sourceMap: MetroSourceMap,
|
||||
sourcesRoot: string,
|
||||
) {
|
||||
if (sourceMap.mappings === undefined) {
|
||||
|
@ -32,9 +32,9 @@ function relativizeSourceMapInternal(
|
|||
}
|
||||
|
||||
function relativizeSourceMap(
|
||||
sourceMap: SourceMap,
|
||||
sourceMap: MetroSourceMap,
|
||||
sourcesRoot?: string,
|
||||
): SourceMap {
|
||||
): MetroSourceMap {
|
||||
if (!sourcesRoot) {
|
||||
return sourceMap;
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ const relativizeSourceMap = require('../../lib/relativizeSourceMap');
|
|||
const writeFile = require('./writeFile');
|
||||
|
||||
import type {OutputOptions, RequestOptions} from '../types.flow';
|
||||
import type {MetroSourceMap as SourceMap} from 'metro-source-map';
|
||||
import type {MetroSourceMap} from 'metro-source-map';
|
||||
|
||||
function buildBundle(
|
||||
packagerClient: Server,
|
||||
|
@ -38,10 +38,10 @@ function createCodeWithMap(
|
|||
bundle: {code: string, map: string},
|
||||
dev: boolean,
|
||||
sourceMapSourcesRoot?: string,
|
||||
): {code: string, map: SourceMap} {
|
||||
): {code: string, map: MetroSourceMap} {
|
||||
const map = bundle.map;
|
||||
const sourceMap = relativizeSourceMap(
|
||||
(JSON.parse(map): SourceMap),
|
||||
(JSON.parse(map): MetroSourceMap),
|
||||
sourceMapSourcesRoot,
|
||||
);
|
||||
return {
|
||||
|
|
|
@ -16,11 +16,7 @@ const invariant = require('fbjs/lib/invariant');
|
|||
import type {RamModule} from '../../../DeltaBundler/Serializers';
|
||||
import type {ModuleGroups, ModuleTransportLike} from '../../types.flow';
|
||||
import type {BabelSourceMap} from 'babel-core';
|
||||
import type {
|
||||
FBIndexMap,
|
||||
IndexMap,
|
||||
MetroSourceMap as SourceMap,
|
||||
} from 'metro-source-map';
|
||||
import type {FBIndexMap, IndexMap, MetroSourceMap} from 'metro-source-map';
|
||||
|
||||
const newline = /\r\n?|\n|\u2028|\u2029/g;
|
||||
// fastest implementation
|
||||
|
@ -48,7 +44,7 @@ function lineToLineSourceMap(
|
|||
|
||||
const wrapperEnd = wrappedCode => wrappedCode.indexOf('{') + 1;
|
||||
|
||||
const Section = (line: number, column: number, map: SourceMap) => ({
|
||||
const Section = (line: number, column: number, map: MetroSourceMap) => ({
|
||||
map,
|
||||
offset: {line, column},
|
||||
});
|
||||
|
|
|
@ -22,12 +22,12 @@ import type {TransformCache} from '../lib/TransformCaching';
|
|||
import type {Reporter} from '../lib/reporting';
|
||||
import type {HasteImpl} from '../node-haste/Module';
|
||||
import type {
|
||||
MetroSourceMap as SourceMap,
|
||||
MetroSourceMap,
|
||||
MetroSourceMapSegmentTuple,
|
||||
} from 'metro-source-map';
|
||||
|
||||
type BundleType = 'bundle' | 'delta' | 'map' | 'ram' | 'cli' | 'hmr' | 'todo';
|
||||
type SourceMapOrMappings = SourceMap | Array<MetroSourceMapSegmentTuple>;
|
||||
type SourceMapOrMappings = MetroSourceMap | Array<MetroSourceMapSegmentTuple>;
|
||||
|
||||
export type BundleOptions = {
|
||||
+assetPlugins: Array<string>,
|
||||
|
|
Loading…
Reference in New Issue