npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@infinite-list/metro-infinite-list-resolver

v0.0.6

Published

A Metro resolver utility for the Infinite List project that helps resolve module mappings for monorepo packages. This tool analyzes package.json files and creates mapping records for efficient module resolution in Metro bundler configurations.

Readme

metro-infinite-list-resolver

A Metro resolver utility for the Infinite List project that helps resolve module mappings for monorepo packages. This tool analyzes package.json files and creates mapping records for efficient module resolution in Metro bundler configurations.

Features

  • Automatic Package Discovery: Scans target directories to find all packages
  • Export Mapping: Resolves package exports and creates proper import mappings
  • Dependency Resolution: Recursively processes dependencies to build complete mapping trees
  • Path Cleaning: Handles complex path scenarios including scoped packages and relative paths
  • Flexible Configuration: Supports custom resolution strategies through plugins

Installation

npm install @infinite-list/metro-infinite-list-resolver

Usage

Basic Usage

import { resolveModules } from '@infinite-list/metro-infinite-list-resolver';

const mapping = resolveModules({
  rootPath: '/path/to/your/project',
  targetDir: 'packages',
});

console.log(mapping);
// Output: {
//   '@infinite-list/core': '/path/to/your/project/packages/core/index.js',
//   '@infinite-list/react': '/path/to/your/project/packages/react/index.js',
//   ...
// }

Advanced Usage with Custom Resolution

import { resolveModules } from '@infinite-list/metro-infinite-list-resolver';

const customResolveModulePath = (pkgOptions, packageName, modulePath) => {
  const mapping = {};

  // Custom logic for resolving modules
  if (pkgOptions.exports) {
    for (const [key, value] of Object.entries(pkgOptions.exports)) {
      if (value.import) {
        mapping[`${packageName}/${key}`] = path.join(modulePath, value.import);
      }
    }
  }

  return mapping;
};

const mapping = resolveModules({
  rootPath: '/path/to/your/project',
  targetDir: 'packages',
  resolveModulePath: customResolveModulePath,
});

API Reference

resolveModules(options?: ResolveModulesOptions): MappingRecord | undefined

Main function that resolves all modules in a target directory.

Parameters

  • options (optional): Configuration object
    • rootPath (string, optional): Root directory path. Defaults to current directory
    • targetDir (string, required): Target directory containing packages to resolve
    • resolveModulePath (function, optional): Custom module resolution function

Returns

  • MappingRecord: Object mapping package names to their resolved file paths
  • undefined: If target directory doesn't exist or other errors occur

cleanPackagePath(packagePath: string): string

Utility function that cleans package paths by removing unnecessary ./ parts and handling ../ backtracks.

Parameters

  • packagePath (string): The package path to clean

Returns

  • string: Cleaned package path

Types

ResolveModulesOptions

interface ResolveModulesOptions {
  rootPath?: string;
  targetDir: string;
  resolveModulePath?: ResolveModulePath;
}

MappingRecord

interface MappingRecord {
  [key: string]: string;
}

PkgOptions

interface PkgOptions {
  main: string;
  module?: string;
  exports?: {
    [key: string]: {
      import?: string;
      default?: string;
      types?: string;
    };
  };
}

How It Works

  1. Directory Scanning: Scans the target directory for subdirectories (packages)
  2. Package.json Analysis: Reads each package's package.json file
  3. Export Resolution: Processes exports field to create import mappings
  4. Main/Module Resolution: Falls back to main or module fields if exports aren't available
  5. Dependency Processing: Recursively processes dependencies to build complete mapping tree
  6. Path Cleaning: Handles complex path scenarios and scoped packages

Metro Integration

This resolver is designed to work with Metro bundler's resolver.alias configuration:

// metro.config.js
const {
  resolveModules,
} = require('@infinite-list/metro-infinite-list-resolver');

module.exports = {
  resolver: {
    alias: resolveModules({
      rootPath: __dirname,
      targetDir: 'packages',
    }),
  },
};

Examples

Monorepo Structure

my-project/
├── packages/
│   ├── core/
│   │   ├── package.json
│   │   └── index.js
│   ├── react/
│   │   ├── package.json
│   │   └── index.js
│   └── utils/
│       ├── package.json
│       └── index.js
└── metro.config.js

Generated Mapping

{
  '@my-project/core': '/path/to/my-project/packages/core/index.js',
  '@my-project/react': '/path/to/my-project/packages/react/index.js',
  '@my-project/utils': '/path/to/my-project/packages/utils/index.js',
  '@my-project/core/utils': '/path/to/my-project/packages/core/utils.js'
}

Error Handling

The resolver gracefully handles:

  • Missing target directories
  • Invalid package.json files
  • Non-existent dependency paths
  • Circular dependencies (prevents infinite loops)

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. Submit a pull request

License

MIT