Enable Virtual Module Resolution
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 5.6k
- Forks
- 696
- Avg merge
- 8m
- Merged PRs (30d)
- 7
Description
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;
}>;
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing Metro's custom resolveRequest hook and the Resolution types shown in the issue. Review how existing file, asset, and empty resolutions are handled, then define and test the behavior for a virtual resolution whose content comes from a module that does not exist on disk.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- build-system, tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100