Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable Virtual Module Resolution #1422

Open
oktaysenkan opened this issue Dec 29, 2024 · 0 comments
Open

Enable Virtual Module Resolution #1422

oktaysenkan opened this issue Dec 29, 2024 · 0 comments

Comments

@oktaysenkan
Copy link

Overview

To implement a custom resolution system that allows resolving virtual modules and handles cases where files have not been created yet, you can extend the Metro resolver with a custom resolveRequest function. This function will provide a VirtualResolution for modules that don’t exist physically but are dynamically generated or virtualized.

resolveRequest?: CustomResolver;

export type CustomResolver = (
  context: CustomResolutionContext,
  moduleName: string,
  platform: string | null,
) => Resolution;

export type Resolution = FileResolution | VirtualResolution 
 | Readonly<{type: 'empty'}>;

export type FileResolution = AssetResolution | SourceFileResolution;

export type AssetResolution = Readonly<{
  type: 'assetFiles';
  filePaths: AssetFileResolution;
}>;

export type SourceFileResolution = Readonly<{
  type: 'sourceFile';
  filePath: string;
}>;

export type VirtualResolution = Readonly<{
  type: 'virtual';
  content: string;
}>;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants