Skip to content

feat: replace cosmiconfig with c12 for configuration management #262

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 1 commit into from
Mar 14, 2025

Conversation

bhouston
Copy link
Member

Replace cosmiconfig with c12 for configuration management

This PR replaces cosmiconfig with c12 for better TypeScript support and additional configuration features, as requested in issue #260.

Changes

  • Replaced cosmiconfig with c12 for configuration loading
  • Added configuration watching capability via watchConfigForChanges function
  • Removed dependency on cosmiconfig
  • Maintained backward compatibility with existing configuration files
  • Fixed type issues when working with c12's configuration types

Benefits of c12 over cosmiconfig

  1. TypeScript Support: c12 has built-in TypeScript support without requiring custom loaders
  2. More Configuration Formats: Supports JSONC, JSON5, TOML in addition to standard formats
  3. Configuration Directory: Supports a .config/ directory for organizing configuration files
  4. Environment-specific Configurations: Allows for environment-specific configuration files
  5. Extended Configurations: Supports extending configurations from other files or packages
  6. Configuration Watching: Built-in support for watching configuration files for changes
  7. Dotenv Support: Built-in support for loading environment variables from .env files
  8. Active Development: Part of the UnJS ecosystem, actively maintained

Testing

  • All tests pass with the new implementation
  • The API remains compatible with existing code

Closes #260

- Replace cosmiconfig with c12 for better TypeScript support
- Add configuration watching capability
- Remove dependency on cosmiconfig
- Maintain backward compatibility with existing config files
- Closes #260
@bhouston bhouston merged commit cc17315 into main Mar 14, 2025
1 check failed
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Adopt UnJS/c12 instead of cosmiconfig
1 participant