Oxc Resolver is a high-performance, Rust-ported module resolver designed for Node.js environments, mimicking the behavior of `enhanced-resolve`, `tsconfig-paths-webpack-plugin`, and `tsconfck`. It provides a comprehensive implementation of both ESM and CommonJS module resolution algorithms as specified by Node.js. Currently stable at version 11.19.1, it receives frequent updates with minor version bumps and bug fixes, indicating active development. Key features include built-in support for TypeScript's `tsconfig.json` paths, project references, and automatic `tsconfig` discovery, making it a robust alternative for bundlers, linters, and language servers. It boasts significant performance improvements, such as being 28x faster than `webpack/enhanced-resolve`, and supports an in-memory file system and `tracing` instrumentation, distinguishing it from purely JavaScript-based resolvers.
npm install oxc-resolverVerified import paths — ran on the pinned version, not inferred.
Demonstrates both basic synchronous module resolution and advanced asynchronous file-based resolution with automatic TypeScript configuration (paths) discovery using `ResolverFactory`.
If your project relies on `NODE_PATH`, explicitly set the `node_path` option to `true` in `ResolveOptions` to maintain prior behavior, or ensure your module paths are otherwise resolvable.
For accurate resolution within a TypeScript project, especially for bundlers or linters, prefer `resolver.resolveFileSync` (or `resolveFileAsync`) as it correctly handles `tsconfig.json` discovery and `paths` based on the file's location. Only use `sync` if you intend to resolve strictly from a directory context without automatic `tsconfig` discovery.
Ensure that your `ResolveOptions` include appropriate `conditionNames` (e.g., `['node', 'require']` for CommonJS consumers) when resolving modules that define an `exports` field, especially for subpath exports.
Verify that your environment is correctly configured for Yarn PnP when using `oxc-resolver`. Ensure the `yarn_pnp` option is enabled in `ResolveOptions` if you intend to use it, and that the `.pnp.cjs` file is discoverable. Errors related to PnP are often shown as-is rather than generic `NotFound` errors, providing specific debugging cues.
Configure `ResolveOptions` with `conditionNames: ['node', 'require']` (for CommonJS) or `['node', 'import']` (for ESM) to match the expected resolution conditions for the `exports` field. This tells the resolver which export conditions to consider.
Verify the module path, ensuring all segments are correct. Check `ResolveOptions` for `extensions`, `alias`, `modules`, `mainFields`, and `mainFiles`. If using TypeScript `paths`, ensure you are using `resolveFileSync` or `resolveFileAsync` to trigger `tsconfig.json` discovery.
Ensure your project is configured for ESM (e.g., `"type": "module"` in `package.json` or `.mjs` extension) and use `import { ... } from 'oxc-resolver';`. If you must use CommonJS, ensure your Node.js version supports ESM interop for CJS, or check if the library provides a CJS entry point.No dependency data recorded yet.