Skip to content

Conversation

@konard
Copy link
Member

@konard konard commented Sep 10, 2025

Summary

This pull request implements support for yarn as a resolver, addressing issue #19. The yarn resolver allows use-m to install and resolve packages using yarn instead of npm or other resolvers.

🔧 Implementation Details

New yarn resolver features:

  • Package installation: Uses yarn global add for package installation
  • Global directory detection: Uses yarn global dir to find the correct installation path
  • Version management: Checks installed package versions to avoid unnecessary reinstalls
  • Module resolution: Follows yarn's simpler global directory structure (packages installed directly by name)
  • Full compatibility: Supports all module specifier formats:

Code changes:

  • Added yarn resolver to both use.mjs and use.cjs
  • Added comprehensive test coverage in tests/resolvers.test.mjs
  • Created demo script examples/yarn-resolver-demo.mjs to showcase functionality
  • Bumped version to 8.14.0

🧪 Test Coverage

📋 Usage Example

import { makeUse } from 'use-m';

// Create a use function with yarn resolver
const use = await makeUse({
  specifierResolver: 'yarn'
});

// Use packages installed via yarn
const lodash = await use('[email protected]');
const yargHelpers = await use('[email protected]/helpers');

🎯 Key Differences from npm/bun resolvers

  • Simpler directory structure: Yarn installs packages directly by their original names rather than using versioned aliases
  • Version checking: Reads package.json to verify installed version matches requested version
  • Global directory handling: Uses yarn global dir command to detect the correct global installation path

✅ Verification

  • All existing tests continue to pass
  • New yarn resolver tests pass successfully
  • Demo script demonstrates working functionality
  • Integration with existing codebase is seamless

Fixes #19


This implementation follows the established patterns from existing resolvers while accommodating yarn's unique global package management approach.

Adding CLAUDE.md with task information for AI processing.
This file will be removed when the task is complete.

Issue: #19
@konard konard self-assigned this Sep 10, 2025
konard and others added 2 commits September 10, 2025 07:47
This commit implements support for yarn as a resolver, allowing use-m to install and resolve packages using yarn instead of npm.

Features:
- New yarn resolver that uses 'yarn global add' for package installation
- Supports all module specifier formats (package@version, scoped packages, subpaths)
- Follows yarn's global directory structure using 'yarn global dir'
- Version checking to avoid unnecessary reinstalls
- Comprehensive test coverage for yarn resolver functionality

Changes:
- Added yarn resolver to both use.mjs and use.cjs
- Added yarn resolver tests to resolvers.test.mjs
- Created yarn-resolver-demo.mjs example script
- Bumped version to 8.14.0

Fixes #19

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
@konard konard changed the title [WIP] Support yarn as resolver Add yarn resolver support Sep 10, 2025
@konard konard marked this pull request as ready for review September 10, 2025 04:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support yarn as resolver

2 participants