mirror of https://github.com/status-im/metro.git
Add flow types for output modules
Summary: Adds flow types for output functionality for easier maintenance and interop with new code Reviewed By: matryoshcow Differential Revision: D4211863 fbshipit-source-id: 591407d3a6d49536054ae94ba31125c18a1e1fa1
This commit is contained in:
parent
038cfa8ebe
commit
7d998e6f58
|
@ -21,6 +21,12 @@ const crypto = require('crypto');
|
||||||
import type {SourceMap, CombinedSourceMap, MixedSourceMap} from '../lib/SourceMap';
|
import type {SourceMap, CombinedSourceMap, MixedSourceMap} from '../lib/SourceMap';
|
||||||
import type {GetSourceOptions, FinalizeOptions} from './BundleBase';
|
import type {GetSourceOptions, FinalizeOptions} from './BundleBase';
|
||||||
|
|
||||||
|
export type Unbundle = {
|
||||||
|
startupModules: Array<*>,
|
||||||
|
lazyModules: Array<*>,
|
||||||
|
groups: Map<number, Set<number>>,
|
||||||
|
};
|
||||||
|
|
||||||
const SOURCEMAPPING_URL = '\n\/\/# sourceMappingURL=';
|
const SOURCEMAPPING_URL = '\n\/\/# sourceMappingURL=';
|
||||||
|
|
||||||
class Bundle extends BundleBase {
|
class Bundle extends BundleBase {
|
||||||
|
@ -29,7 +35,7 @@ class Bundle extends BundleBase {
|
||||||
_inlineSourceMap: string | void;
|
_inlineSourceMap: string | void;
|
||||||
_minify: boolean | void;
|
_minify: boolean | void;
|
||||||
_numRequireCalls: number;
|
_numRequireCalls: number;
|
||||||
_ramBundle: mixed | void;
|
_ramBundle: Unbundle | null;
|
||||||
_ramGroups: Array<string> | void;
|
_ramGroups: Array<string> | void;
|
||||||
_shouldCombineSourceMaps: boolean;
|
_shouldCombineSourceMaps: boolean;
|
||||||
_sourceMap: boolean;
|
_sourceMap: boolean;
|
||||||
|
@ -144,7 +150,7 @@ class Bundle extends BundleBase {
|
||||||
return source;
|
return source;
|
||||||
}
|
}
|
||||||
|
|
||||||
getUnbundle() {
|
getUnbundle(): Unbundle {
|
||||||
this.assertFinalized();
|
this.assertFinalized();
|
||||||
if (!this._ramBundle) {
|
if (!this._ramBundle) {
|
||||||
const modules = this.getModules().slice();
|
const modules = this.getModules().slice();
|
||||||
|
@ -419,7 +425,7 @@ function createGroups(ramGroups: Array<string>, lazyModules) {
|
||||||
});
|
});
|
||||||
|
|
||||||
// build a map of group root IDs to an array of module IDs in the group
|
// build a map of group root IDs to an array of module IDs in the group
|
||||||
const result = new Map(
|
const result: Map<number, Set<number>> = new Map(
|
||||||
ramGroups
|
ramGroups
|
||||||
.map(modulePath => {
|
.map(modulePath => {
|
||||||
const root = byPath.get(modulePath);
|
const root = byPath.get(modulePath);
|
||||||
|
|
|
@ -19,7 +19,7 @@ export type FinalizeOptions = {
|
||||||
};
|
};
|
||||||
|
|
||||||
export type GetSourceOptions = {
|
export type GetSourceOptions = {
|
||||||
inlineSourceMap: boolean,
|
inlineSourceMap?: boolean,
|
||||||
dev: boolean,
|
dev: boolean,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
import type {SourceMap} from './SourceMap';
|
import type {MixedSourceMap} from './SourceMap';
|
||||||
|
|
||||||
type Metadata = {
|
type Metadata = {
|
||||||
dependencyPairs?: Array<[mixed, {path: string}]>,
|
dependencyPairs?: Array<[mixed, {path: string}]>,
|
||||||
|
@ -21,25 +21,25 @@ type Metadata = {
|
||||||
class ModuleTransport {
|
class ModuleTransport {
|
||||||
|
|
||||||
name: string;
|
name: string;
|
||||||
id: string | number;
|
id: number;
|
||||||
code: string;
|
code: string;
|
||||||
sourceCode: string;
|
sourceCode: string;
|
||||||
sourcePath: string;
|
sourcePath: string;
|
||||||
virtual: ?boolean;
|
virtual: ?boolean;
|
||||||
meta: ?Metadata;
|
meta: ?Metadata;
|
||||||
polyfill: ?boolean;
|
polyfill: ?boolean;
|
||||||
map: ?SourceMap;
|
map: ?MixedSourceMap;
|
||||||
|
|
||||||
constructor(data: {
|
constructor(data: {
|
||||||
name: string,
|
name: string,
|
||||||
id: string | number,
|
id: number,
|
||||||
code: string,
|
code: string,
|
||||||
sourceCode: string,
|
sourceCode: string,
|
||||||
sourcePath: string,
|
sourcePath: string,
|
||||||
virtual?: ?boolean,
|
virtual?: ?boolean,
|
||||||
meta?: ?Metadata,
|
meta?: ?Metadata,
|
||||||
polyfill?: ?boolean,
|
polyfill?: ?boolean,
|
||||||
map?: ?SourceMap,
|
map?: ?MixedSourceMap,
|
||||||
}) {
|
}) {
|
||||||
this.name = data.name;
|
this.name = data.name;
|
||||||
|
|
||||||
|
|
|
@ -20,8 +20,14 @@ export type CombinedSourceMap = {
|
||||||
file: string,
|
file: string,
|
||||||
sections: Array<{
|
sections: Array<{
|
||||||
offset: {line: number, column: number},
|
offset: {line: number, column: number},
|
||||||
map: SourceMap,
|
map: MixedSourceMap,
|
||||||
}>,
|
}>,
|
||||||
};
|
};
|
||||||
|
|
||||||
export type MixedSourceMap = SourceMap | CombinedSourceMap;
|
type FBExtensions = {x_facebook_offsets?: Array<number>};
|
||||||
|
|
||||||
|
export type MixedSourceMap
|
||||||
|
= SourceMap
|
||||||
|
| CombinedSourceMap
|
||||||
|
| (SourceMap & FBExtensions)
|
||||||
|
| (CombinedSourceMap & FBExtensions);
|
||||||
|
|
Loading…
Reference in New Issue