mirror of https://github.com/status-im/metro.git
Expose some private methods from the Bundler and the DependencyGraph
Reviewed By: jeanlauliac Differential Revision: D5755556 fbshipit-source-id: cff95e3464154883fd872bf8ab916276a1f09027
This commit is contained in:
parent
70a0916dd2
commit
8c8cfb364f
|
@ -153,7 +153,7 @@ const {hasOwnProperty} = Object;
|
||||||
|
|
||||||
class Bundler {
|
class Bundler {
|
||||||
_opts: Options;
|
_opts: Options;
|
||||||
_getModuleId: (opts: Module) => number;
|
_getModuleId: ({path: string}) => number;
|
||||||
_transformer: Transformer;
|
_transformer: Transformer;
|
||||||
_resolverPromise: Promise<Resolver>;
|
_resolverPromise: Promise<Resolver>;
|
||||||
_projectRoots: $ReadOnlyArray<string>;
|
_projectRoots: $ReadOnlyArray<string>;
|
||||||
|
@ -284,6 +284,10 @@ class Bundler {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getGetModuleIdFn(): ({path: string}) => number {
|
||||||
|
return this._getModuleId;
|
||||||
|
}
|
||||||
|
|
||||||
_sourceHMRURL(platform: ?string, hmrpath: string) {
|
_sourceHMRURL(platform: ?string, hmrpath: string) {
|
||||||
return this._hmrURL('', platform, 'bundle', hmrpath);
|
return this._hmrURL('', platform, 'bundle', hmrpath);
|
||||||
}
|
}
|
||||||
|
@ -765,7 +769,7 @@ class Bundler {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
_generateAssetObjAndCode(
|
generateAssetObjAndCode(
|
||||||
module: Module,
|
module: Module,
|
||||||
assetPlugins: Array<string>,
|
assetPlugins: Array<string>,
|
||||||
platform: ?string = null,
|
platform: ?string = null,
|
||||||
|
@ -854,7 +858,7 @@ class Bundler {
|
||||||
) {
|
) {
|
||||||
return Promise.all([
|
return Promise.all([
|
||||||
module.getName(),
|
module.getName(),
|
||||||
this._generateAssetObjAndCode(module, assetPlugins, platform),
|
this.generateAssetObjAndCode(module, assetPlugins, platform),
|
||||||
]).then(([name, {asset, code, meta}]) => {
|
]).then(([name, {asset, code, meta}]) => {
|
||||||
bundle.addAsset(asset);
|
bundle.addAsset(asset);
|
||||||
return new ModuleTransport({
|
return new ModuleTransport({
|
||||||
|
|
|
@ -250,7 +250,7 @@ class DependencyGraph extends EventEmitter {
|
||||||
recursive: boolean,
|
recursive: boolean,
|
||||||
}): Promise<ResolutionResponse<Module, T>> {
|
}): Promise<ResolutionResponse<Module, T>> {
|
||||||
platform = this._getRequestPlatform(entryPath, platform);
|
platform = this._getRequestPlatform(entryPath, platform);
|
||||||
const absPath = this._getAbsolutePath(entryPath);
|
const absPath = this.getAbsolutePath(entryPath);
|
||||||
const req = new ResolutionRequest({
|
const req = new ResolutionRequest({
|
||||||
moduleResolver: this._moduleResolver,
|
moduleResolver: this._moduleResolver,
|
||||||
entryPath: absPath,
|
entryPath: absPath,
|
||||||
|
@ -289,7 +289,7 @@ class DependencyGraph extends EventEmitter {
|
||||||
return platform;
|
return platform;
|
||||||
}
|
}
|
||||||
|
|
||||||
_getAbsolutePath(filePath: string) {
|
getAbsolutePath(filePath: string) {
|
||||||
if (isAbsolutePath(filePath)) {
|
if (isAbsolutePath(filePath)) {
|
||||||
return path.resolve(filePath);
|
return path.resolve(filePath);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue