Repository navigation
release: v2.5.1 - #55
Merged
Merged
Conversation
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
There was a problem hiding this comment.
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
_loadSingleModuleto 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.
…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
There was a problem hiding this comment.
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
approved these changes
Oct 27, 2025
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]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🚀 What's Changed
💥 Breaking Changes
No breaking changes
✨ Features
No new features
🐛 Bug Fixes
🔧 Other Changes
🏷️ Release Information
👥 Contributors