Skip to content

release: v2.5.1 - #55

Merged
Shinrai merged 6 commits into
masterfrom
release/2.5.1
Oct 27, 2025
Merged

Shinrai merged 6 commits into
masterfrom
release/2.5.1

Conversation

@cldmv-bot

@cldmv-bot cldmv-bot Bot commented Oct 27, 2025 •

Copy link
Copy Markdown
Contributor

🚀 What's Changed

💥 Breaking Changes

No breaking changes

✨ Features

No new features

🐛 Bug Fixes

  • fix(modes): Convert inline imports to top-level imports (3439c73)
  • fix: multi-default export handling bug in both lazy and eager modes (2e4a03d)

🔧 Other Changes

🏷️ Release Information

👥 Contributors

Shinrai and others added 4 commits October 27, 2025 10:50
CRITICAL FIX: Resolves fundamental bug where modules with both default and named exports
were incorrectly processed in multi-default contexts.

Problem:
- processModuleForAPI received processed modules where named exports were always
  attached to default export, making moduleHasDefault always true
- This caused incorrect flattening decisions (e.g., press.mjs exports flattened
  to root instead of preserving default export as namespace)

Solution:
- Modified processModuleForAPI to accept originalAnalysis parameter
- Updated getFlatteningDecision to use originalAnalysis.hasDefault instead of !!mod.default
- Applied fix to both lazy mode (slothlet_lazy.mjs) and eager mode (slothlet_eager.mjs)
- Both modes now call analyzeModule + processModuleFromAnalysis separately to retain analysis data

Result:
- Default exports properly preserved as namespaces (api.press.*)
- Named exports correctly flattened to parent level when appropriate
- No more function conflicts between modules
- Consistent behavior between lazy and eager modes

Files modified:
- src/lib/helpers/api_builder.mjs: Added originalAnalysis parameter support
- src/lib/modes/slothlet_lazy.mjs: Updated to pass analysis data through processing chain
- src/lib/modes/slothlet_eager.mjs: Updated to pass analysis data through processing chain
- .github/copilot-instructions.md: Added --slothletdebug documentation and updated pre-commit chain

Verified with api_adb_test in both modes - press.mjs now correctly creates api.press.*
namespace instead of flattening all exports to root level.
- Move processModuleForAPI and multidefault_analyzeModules imports to top of files
- Remove inline await import() statements for better performance and clarity
- Clean up unused import declarations after refactoring
- Maintain identical functionality in both lazy and eager modes
- Restore listPackages export after testing non-exported function behavior

 All validation passed: test:unit (88 tests), test:node (10 files), build:dist, build:types, test:types (12 exports)
Multi-default export bug fix and code quality improvements

## Critical Bug Fixes
- Fixed multi-default export processing where modules with both default and named exports were incorrectly flattened
- Corrected getFlatteningDecision to use originalAnalysis.hasDefault instead of processed module structure
- Applied fix consistently to both lazy and eager loading modes

## Code Quality Improvements
- Converted inline imports to top-level imports for better performance
- Unified _loadSingleModule usage across loading strategies
- Eliminated code duplication in module analysis and processing
- Enhanced debug capabilities with --slothletdebug flag documentation

## Validation
 88 unit tests passed (lazy/eager modes)
 10 node test files passed (comprehensive API validation)
 Build system: dist + TypeScript definitions generated
 12 package exports validated with TypeScript
 Multi-default export behavior verified with edge case testing

## Breaking Changes
None - fully backward compatible

## Migration Guide
No migration required - existing code continues to work unchanged
@cldmv-bot cldmv-bot Bot added semver: explicit This release uses an explicitly specified version rather than an auto-detected bump release Marks a pull request as a pending release — merge to publish a new version labels Oct 27, 2025
@Shinrai Shinrai self-assigned this Oct 27, 2025
@Shinrai
Shinrai requested a review from Copilot October 27, 2025 18:17

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This release (v2.5.1) fixes bugs related to multi-default export handling in both lazy and eager modes by converting inline imports to top-level imports and improving module analysis data flow.

Key changes:

  • Moved imports to top-level to fix multi-default export handling bugs
  • Enhanced _loadSingleModule to optionally return analysis data alongside processed modules
  • Updated eager and lazy mode implementations to pass original analysis to processModuleForAPI

Reviewed Changes

Copilot reviewed 35 out of 55 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
package.json Version bump from 2.5.0 to 2.5.1
src/slothlet.mjs Enhanced _loadSingleModule to support returning analysis data and removed unused import
src/lib/modes/slothlet_lazy.mjs Moved multidefault import to top-level and updated module loading to use analysis data
src/lib/modes/slothlet_eager.mjs Moved imports to top-level and updated module loading to pass analysis data
src/lib/helpers/api_builder.mjs Added originalAnalysis parameter to processModuleForAPI for improved multi-default handling
types/src/lib/helpers/api_builder.d.mts Updated TypeScript definitions with formatting changes and new originalAnalysis parameter
types/src/lib/helpers/multidefault.d.mts Formatting improvements to function signatures
api_tests/api_adb_test/*.mjs Added new test API files for testing multi-default export scenarios

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/lib/helpers/api_builder.mjs Resolved
Comment thread src/slothlet.mjs Resolved
…lback behavior

- Add comprehensive JSDoc for _loadSingleModule returnAnalysis parameter
- Document when and why returnAnalysis is needed for multi-default export handling
- Clarify return type structure based on returnAnalysis boolean
- Document !!mod.default fallback limitations and when it's used
- Add inline comments explaining legacy caller compatibility
- Improve getFlatteningDecision parameter documentation for moduleHasDefault accuracy
@Shinrai
Shinrai requested a review from Copilot October 27, 2025 18:25

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 35 out of 55 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Shinrai
Shinrai merged commit ce4d60c into master Oct 27, 2025
@Shinrai
Shinrai deleted the release/2.5.1 branch December 8, 2025 04:41
Shinrai added a commit that referenced this pull request Feb 11, 2026
release: v2.5.1 - Critical Multi-Default Export Fix and Code Quality Enhancement

🔧 CRITICAL BUG FIXES AND ARCHITECTURAL IMPROVEMENTS
• Fix critical multi-default export processing bug where modules with both default and named exports were incorrectly flattened
• Correct getFlatteningDecision to use originalAnalysis.hasDefault instead of processed module structure preventing incorrect API flattening
• Apply multi-default export fix consistently to both lazy and eager loading modes ensuring identical behavior
• Resolve press.mjs and similar modules incorrectly losing namespace structure in multi-default contexts
• Enhanced debug capabilities with --slothletdebug flag documentation for multi-default processing visibility

🏗️ CODE QUALITY AND CONSISTENCY IMPROVEMENTS  
• Convert inline imports to top-level imports for better performance and clarity in both lazy and eager modes
• Move processModuleForAPI and multidefault_analyzeModules imports to file headers eliminating await import() overhead
• Unified _loadSingleModule usage across loading strategies with returnAnalysis parameter for consistent module processing
• Eliminate code duplication in module analysis and processing through enhanced uniform loading approach
• Clean up unused import declarations after refactoring maintaining proper lint compliance

⚡ PERFORMANCE AND ARCHITECTURAL ENHANCEMENTS
• Enhanced _loadSingleModule method with returnAnalysis parameter enabling uniform usage across both loading modes
• Preserve original analysis data flow for accurate flattening decisions preventing multi-default processing errors
• Maintain identical functionality while improving code consistency and eliminating duplicate analysis/processing calls
• Better startup performance with top-level imports vs inline await import() statements
• Consistent module loading patterns shared between lazy and eager strategies

📋 COMPREHENSIVE VALIDATION AND TESTING
• Complete validation pipeline: 88 unit tests passed (lazy/eager modes)
• Comprehensive node test suite: 10 test files passed with 17+ seconds of API structure validation
• Multi-default export behavior verified with edge case testing including non-exported function validation
• Build system validation: distribution files and TypeScript definitions generated successfully
• Type safety validation: all 12 package exports validated with TypeScript compiler
• Debug flag testing confirming correct analysis data flow and flattening decision logic

🎯 MULTI-DEFAULT EXPORT FIX DETAILS
• Root cause: processModuleFromAnalysis always attaches named exports to default exports, making !!mod.default inaccurate
• Solution: Pass originalAnalysis parameter to processModuleForAPI ensuring getFlatteningDecision uses correct hasDefault value
• Impact: Modules like press.mjs now correctly create api.press.* namespace instead of flattening to root level
• Verification: Both lazy and eager modes produce identical correct API structures with proper namespace preservation
• Edge cases: Confirmed non-exported functions don't participate in flattening logic as expected

📚 ENHANCED DOCUMENTATION AND MAINTAINABILITY
• Comprehensive JSDoc documentation for returnAnalysis parameter explaining when and why it should be used
• Document return type structure changes based on returnAnalysis boolean parameter for internal method clarity  
• Clear documentation of !!mod.default fallback limitations and legacy caller compatibility requirements
• Inline comments explaining multi-default export handling and original analysis data preservation needs
• Improved getFlatteningDecision parameter documentation addressing accuracy concerns with processed modules

🛡️ RELIABILITY AND DEBUGGING ENHANCEMENTS
• Enhanced debug output with --slothletdebug flag showing analyzeModule() results and flattening decisions
• Critical debug information includes hasDefault detection, multi-default context identification, and API assignment operations
• Verification of originalAnalysis data flow ensuring hasDefault preservation throughout processing pipeline
• Named export behavior validation confirming correct flattening vs namespace preservation logic
• Comprehensive edge case testing with listPackages function export/non-export scenarios

⚙️ TECHNICAL IMPLEMENTATION DETAILS
• analyzeModule() + processModuleFromAnalysis() approach replaced with uniform _loadSingleModule(path, true) pattern
• originalAnalysis parameter ensures accurate multi-default processing decisions before module structure modification
• Consistent import patterns across both loading modes eliminating inline import performance overhead
• Proper handling of both default and named export combinations in multi-default contexts
• Maintained backward compatibility while fixing fundamental architectural issue

Breaking Changes: None - fully backward compatible bug fix release
Performance Impact: Enhanced startup performance with top-level imports, maintained runtime characteristics
API Compatibility: Complete preservation of existing API contracts with corrected multi-default export behavior

This release addresses a critical architectural bug in multi-default export processing while improving code quality, consistency, and maintainability. The fix ensures that modules with both default and named exports maintain proper namespace structure across both lazy and eager loading modes, providing the reliable and predictable API behavior that slothlet users expect.

Validation: ✅ 88 unit tests ✅ 10 node test files ✅ Build system ✅ TypeScript definitions ✅ 12 package exports
Co-authored-by: Nate - CLDMV <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release Marks a pull request as a pending release — merge to publish a new version semver: explicit This release uses an explicitly specified version rather than an auto-detected bump

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants