diff --git a/react-packager/src/Bundler/Bundle.js b/react-packager/src/Bundler/Bundle.js index 37b6f5e6..bf406696 100644 --- a/react-packager/src/Bundler/Bundle.js +++ b/react-packager/src/Bundler/Bundle.js @@ -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>, +}; + 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 | 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, lazyModules) { }); // build a map of group root IDs to an array of module IDs in the group - const result = new Map( + const result: Map> = new Map( ramGroups .map(modulePath => { const root = byPath.get(modulePath); diff --git a/react-packager/src/Bundler/BundleBase.js b/react-packager/src/Bundler/BundleBase.js index 35c8a56d..a39a14f6 100644 --- a/react-packager/src/Bundler/BundleBase.js +++ b/react-packager/src/Bundler/BundleBase.js @@ -19,7 +19,7 @@ export type FinalizeOptions = { }; export type GetSourceOptions = { - inlineSourceMap: boolean, + inlineSourceMap?: boolean, dev: boolean, }; diff --git a/react-packager/src/lib/ModuleTransport.js b/react-packager/src/lib/ModuleTransport.js index 51a77802..1222ac93 100644 --- a/react-packager/src/lib/ModuleTransport.js +++ b/react-packager/src/lib/ModuleTransport.js @@ -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; diff --git a/react-packager/src/lib/SourceMap.js b/react-packager/src/lib/SourceMap.js index a10ab619..5ffa42f0 100644 --- a/react-packager/src/lib/SourceMap.js +++ b/react-packager/src/lib/SourceMap.js @@ -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}; + +export type MixedSourceMap + = SourceMap + | CombinedSourceMap + | (SourceMap & FBExtensions) + | (CombinedSourceMap & FBExtensions);