{"library":"oxc-resolver","title":"Oxc Resolver","description":"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.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install oxc-resolver"],"cli":null},"imports":["import { resolveSync } from 'oxc-resolver'","import { ResolverFactory } from 'oxc-resolver'","import type { ResolveOptions, ResolveResult } from 'oxc-resolver'"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { ResolverFactory, resolveSync } from 'oxc-resolver';\nimport * as path from 'path';\nimport * as fs from 'fs';\n\nasync function runResolutionExample() {\n  const tempDir = path.join(process.cwd(), 'temp_oxc_resolver_test');\n  \n  // Setup: Create a temporary directory structure and tsconfig.json\n  fs.mkdirSync(path.join(tempDir, 'src', 'app'), { recursive: true });\n  fs.writeFileSync(\n    path.join(tempDir, 'tsconfig.json'),\n    JSON.stringify({\n      compilerOptions: {\n        baseUrl: '.',\n        paths: {\n          '@app/*': ['src/app/*'],\n        },\n      },\n    }, null, 2)\n  );\n  fs.writeFileSync(path.join(tempDir, 'src', 'app', 'moduleA.ts'), 'export const a = 1;');\n  \n  // 1. Basic synchronous resolution (directory-based context)\n  const simpleResolvedPath = resolveSync(tempDir, './src/app/moduleA.ts');\n  console.log('Simple resolved path (sync):', simpleResolvedPath?.path);\n\n  // 2. Advanced resolution using ResolverFactory with file-based context and TSConfig discovery\n  const resolver = new ResolverFactory();\n  const sourceFilePath = path.join(tempDir, 'src', 'main.ts');\n  fs.writeFileSync(sourceFilePath, 'import { a } from \"@app/moduleA\";'); // Dummy file for context\n\n  const fileBasedResolvedPath = await resolver.resolveFileAsync(sourceFilePath, '@app/moduleA');\n  console.log('File-based resolved path (async with tsconfig):', fileBasedResolvedPath?.path);\n\n  // Cleanup\n  fs.unlinkSync(path.join(tempDir, 'src', 'app', 'moduleA.ts'));\n  fs.unlinkSync(path.join(tempDir, 'tsconfig.json'));\n  fs.unlinkSync(sourceFilePath);\n  fs.rmdirSync(path.join(tempDir, 'src', 'app'));\n  fs.rmdirSync(path.join(tempDir, 'src'));\n  fs.rmdirSync(tempDir);\n}\n\nrunResolutionExample().catch(console.error);","lang":"typescript","description":"Demonstrates both basic synchronous module resolution and advanced asynchronous file-based resolution with automatic TypeScript configuration (paths) discovery using `ResolverFactory`.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}