Expand description
Import specifier resolution using oxc_resolver.
Orchestrates the resolution pipeline: for every extracted module, resolves all
import specifiers in parallel (via rayon) to an ResolveResult, internal file,
npm package, external file, or unresolvable. The entry point is resolve_all_imports.
Resolution is split into submodules by import kind:
static_imports: ESimportdeclarationsdynamic_imports:import()expressions and glob-based dynamic patternsrequire_imports: CommonJSrequire()callsre_exports:export { x } from './y're-export sourcesupgrades: post-resolution pass fixing non-deterministic bare specifier results
Handles tsconfig path aliases (auto-discovered per file), pnpm virtual store paths,
React Native platform extensions, and package.json exports subpath resolution with
output-to-source directory fallback.
Structs§
- Platform
Family Key - Where a source file sits in a Metro platform-extension family: the
directory and base stem shared by
<stem>.<platform><ext>and<stem><ext>, plus whether this member carries a platform segment. - Resolve
AllImports Input - Inputs used to resolve imports for a complete extracted project.
- Resolved
Import - A resolved import with its target.
- Resolved
Module - Fully resolved module with all imports mapped to targets.
- Resolved
Project - Resolver output for one extracted project.
- Resolved
ReExport - A resolved re-export with its target.
- Resolved
Replaced Module Target - One project-internal module replacement resolved from its declaring source file.
- Resolver
Session - Reusable per-project resolver state: the resolver instances, package manifests, and workspace canonicalization that do not depend on the specific modules being resolved.
Enums§
- Resolve
Result - Result of resolving an import specifier.
- Resolved
Source Edge - Any source-bearing module edge that resolves one literal specifier.
Constants§
- OUTPUT_
DIRS - Known output directory names that may appear in exports map targets.
When an exports map points to
./dist/utils.js, we try replacing these prefixes withsrc/(the conventional source directory) to find the tracked source file.
Functions§
- extract_
package_ name - Extract the npm package name from a specifier.
@scope/pkg/foo/bar->@scope/pkglodash/merge->lodash - extract_
package_ name_ from_ node_ modules_ path - Extract npm package name from a resolved path inside
node_modules. - has_
react_ native_ plugin - Whether the React Native or Expo plugin is active, the gate for every Metro platform-extension behavior in the resolver and its consumers.
- is_
bare_ specifier - Check if a specifier is a bare specifier (npm package or Node.js imports map entry).
- is_
path_ alias - Check if a bare specifier looks like a path alias rather than an npm package.
- is_
valid_ package_ name - Check if a string looks like a valid npm package name.
- platform_
family_ key - Classify
pathby its Metro platform-extension family. - resolve_
all_ imports - Resolve all imports across all modules in parallel.
- resolve_
all_ imports_ with_ session - Resolve all imports for
input, reusing a prebuiltResolverSession.