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 {GetSourceOptions, FinalizeOptions} from './BundleBase';
|
||||
|
||||
export type Unbundle = {
|
||||
startupModules: Array<*>,
|
||||
lazyModules: Array<*>,
|
||||
groups: Map<number, Set<number>>,
|
||||
};
|
||||
|
||||
const SOURCEMAPPING_URL = '\n\/\/# sourceMappingURL=';
|
||||
|
||||
class Bundle extends BundleBase {
|
||||
|
@ -29,7 +35,7 @@ class Bundle extends BundleBase {
|
|||
_inlineSourceMap: string | void;
|
||||
_minify: boolean | void;
|
||||
_numRequireCalls: number;
|
||||
_ramBundle: mixed | void;
|
||||
_ramBundle: Unbundle | null;
|
||||
_ramGroups: Array<string> | void;
|
||||
_shouldCombineSourceMaps: boolean;
|
||||
_sourceMap: boolean;
|
||||
|
@ -144,7 +150,7 @@ class Bundle extends BundleBase {
|
|||
return source;
|
||||
}
|
||||
|
||||
getUnbundle() {
|
||||
getUnbundle(): Unbundle {
|
||||
this.assertFinalized();
|
||||
if (!this._ramBundle) {
|
||||
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
|
||||
const result = new Map(
|
||||
const result: Map<number, Set<number>> = new Map(
|
||||
ramGroups
|
||||
.map(modulePath => {
|
||||
const root = byPath.get(modulePath);
|
||||
|
|
|
@ -19,7 +19,7 @@ export type FinalizeOptions = {
|
|||
};
|
||||
|
||||
export type GetSourceOptions = {
|
||||
inlineSourceMap: boolean,
|
||||
inlineSourceMap?: boolean,
|
||||
dev: boolean,
|
||||
};
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
'use strict';
|
||||
|
||||
import type {SourceMap} from './SourceMap';
|
||||
import type {MixedSourceMap} from './SourceMap';
|
||||
|
||||
type Metadata = {
|
||||
dependencyPairs?: Array<[mixed, {path: string}]>,
|
||||
|
@ -21,25 +21,25 @@ type Metadata = {
|
|||
class ModuleTransport {
|
||||
|
||||
name: string;
|
||||
id: string | number;
|
||||
id: number;
|
||||
code: string;
|
||||
sourceCode: string;
|
||||
sourcePath: string;
|
||||
virtual: ?boolean;
|
||||
meta: ?Metadata;
|
||||
polyfill: ?boolean;
|
||||
map: ?SourceMap;
|
||||
map: ?MixedSourceMap;
|
||||
|
||||
constructor(data: {
|
||||
name: string,
|
||||
id: string | number,
|
||||
id: number,
|
||||
code: string,
|
||||
sourceCode: string,
|
||||
sourcePath: string,
|
||||
virtual?: ?boolean,
|
||||
meta?: ?Metadata,
|
||||
polyfill?: ?boolean,
|
||||
map?: ?SourceMap,
|
||||
map?: ?MixedSourceMap,
|
||||
}) {
|
||||
this.name = data.name;
|
||||
|
||||
|
|
|
@ -20,8 +20,14 @@ export type CombinedSourceMap = {
|
|||
file: string,
|
||||
sections: Array<{
|
||||
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