Skip to main content

Module resolve

Module resolve 

Source
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: ES import declarations
  • dynamic_imports: import() expressions and glob-based dynamic patterns
  • require_imports: CommonJS require() calls
  • re_exports: export { x } from './y' re-export sources
  • upgrades: 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§

PlatformFamilyKey
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.
ResolveAllImportsInput
Inputs used to resolve imports for a complete extracted project.
ResolvedImport
A resolved import with its target.
ResolvedModule
Fully resolved module with all imports mapped to targets.
ResolvedProject
Resolver output for one extracted project.
ResolvedReExport
A resolved re-export with its target.
ResolvedReplacedModuleTarget
One project-internal module replacement resolved from its declaring source file.
ResolverSession
Reusable per-project resolver state: the resolver instances, package manifests, and workspace canonicalization that do not depend on the specific modules being resolved.

Enums§

ResolveResult
Result of resolving an import specifier.
ResolvedSourceEdge
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 with src/ (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/pkg lodash/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 path by 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 prebuilt ResolverSession.