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§

CompiledJsxRule
One config JSX import source with its compiled include and exclude globs.
InlineLoaderRequest
One parsed webpack inline loader request.
MissingExportTarget
The missing paths that the exports map of a project package names for one unresolved bare specifier.
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.
ResolveWork
Work counts for import resolution.
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.
UnreadableAutoImportRead
One file that reads an auto-import virtual module in a way the graph cannot follow to single names, such as a spread of a #components namespace.

Enums§

ResolveResult
Result of resolving an import specifier.
ResolvedSourceEdge
Any source-bearing module edge that resolves one literal specifier.

Constants§

MISSING_ONLY_OUTPUT_DIRS
Output directory names that map to src/ only when the target is absent.
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§

compile_jsx_rules
Compile the globs of each rule. A rule without a valid include glob matches no file, so it is dropped. An exclude glob that does not compile is skipped.
directory_index_entry
Return the first index.<ext> file in the directory resolved.
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.
normalize_npm_specifier
Normalize the body of a Deno npm: specifier into a plain npm package reference by dropping the @<version> selector while preserving the package name (including scope) and any subpath.
output_entry_to_source_path
Map an output directory entry to its same-stem source file.
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.
unreadable_auto_import_reads
The reads of an auto-import virtual module that the graph cannot narrow to single names, in file order. Each one credits every name of its module and earns the file a plugin-effect-not-modeled diagnostic.