@bacons/expo-metro-runtime
Version:
Tools for making experimental Metro bundler features work
24 lines (23 loc) • 1.16 kB
TypeScript
declare type MetroRequire = {
(id: number): any;
importAll: (id: number) => any;
};
/**
* Must satisfy the requirements of the Metro bundler.
* https://github.com/facebook/metro/blob/f9fe277986ff7e7e53ae0418040f3aa1eb1c7056/packages/metro/src/ModuleGraph/worker/collectDependencies.js#L629-L639
*
* And https://github.com/facebook/metro/blob/fc29a1177f883144674cf85a813b58567f69d545/packages/metro/src/lib/getAppendScripts.js#L54-L56
*/
declare type AsyncRequire = {
<TModule>(moduleID: number, moduleName?: string, options?: {
isPrefetchOnly: boolean;
}): Promise<TModule | void> | TModule;
prefetch(moduleID: number, moduleName: string): void;
/** NOTE(EvanBacon): Unclear what this should return `__jsResource` ?? */
resource(moduleID: number, moduleName: string): never;
/** Register the 'moduleID<>bundle path' that can be loaded via `asyncRequire(moduleID)` */
addImportBundleNames(names: Record<string, string>): void;
};
/** Create an `asyncRequire` function in the expected shape for Metro bundler. */
export declare function buildAsyncRequire(metroRequire: MetroRequire): AsyncRequire;
export {};