Repository navigation
release: v2.4.3 - #53
Conversation
…iminate config double nesting
Critical Fixes:
- Fixed self-referential default export handling across both lazy and eager modes
- Eliminated config.config double nesting in subfolder processing
- Resolved API duplication where config modules created both namespace AND flattened exports
Technical Improvements:
- Enhanced multi-default export detection to exclude self-referential cases (export const config = {...}; export default config;)
- Implemented raw module import detection to see actual exports before slothlet processing
- Added selfReferentialFiles Set tracking for consistent behavior across modes
- Fixed _buildCategory method in slothlet.mjs to handle self-referential objects correctly
- Updated both lazy and eager modes with identical self-referential detection logic
Development Tools:
- Fixed inspect tool duplicate callable paths (eliminated double entries in output)
- Enhanced inspect tool with _materialize() method support for lazy folder materialization
- Added skipSelf parameter to prevent recursive function path additions
- Improved debug output for better development experience
Module Updates:
- Bumped lazy mode version to 1.3.0 (enhanced self-referential handling)
- Bumped eager mode version to 1.3.0 (consistent API structure generation)
- Updated package.json moduleVersions to reflect significant improvements
Testing & Validation:
- All tests passing (91 paths validated, no NaN results or call errors)
- APIs structurally identical between eager and lazy modes
- Debug script validates all function calls and argument forwarding
- TypeScript definitions validated successfully (10 exports tested)
- Build process completed successfully (dist, types, validation)
Architecture Consistency:
- Ensured consistent self-referential export treatment across both loading strategies
- Maintained API shape consistency between lazy and eager modes
- Preserved function name preference logic and sanitization behavior
- Fixed both function processing and object processing code paths
Before: api.subfolder.config.config.getConfig() (double nesting)
After: api.subfolder.config.getConfig() (clean structure)
This release resolves the core issue where self-referential exports (files where default export points to a named export) were incorrectly treated as multi-default scenarios, causing API structure inconsistencies and unwanted double nesting in subfolder processing.
…files Security Fixes: - Added FORBIDDEN_KEYS protection against prototype pollution in config.update() methods - Prevents assignment to dangerous properties: __proto__, constructor, prototype - Silently ignores forbidden keys to maintain functionality while blocking exploitation - Applied fix to both root and subfolder config.mjs test files Protection Details: - Guards against property chain attacks in dot-notation key assignment - Validates both intermediate and final property names in nested object creation - Maintains existing functionality for legitimate configuration updates - Zero impact on normal usage patterns Addresses CodeQL security warnings for prototype-polluting functions.
There was a problem hiding this comment.
Pull Request Overview
This release (v2.4.3) fixes a critical issue with self-referential default export handling in the slothlet module loader. The main fix prevents double-nesting of configuration objects when a module exports both a named export and a default export that references the same object (e.g., export const config = {...}; export default config;). Additionally, the release includes security improvements to prevent prototype pollution vulnerabilities in configuration update methods.
- Fixed self-referential default export detection to avoid double-nesting issues
- Added prototype pollution protection in config.mjs files
- Enhanced debugging tools for lazy folder materialization
Reviewed Changes
Copilot reviewed 18 out of 33 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| types/*.d.mts | Added type declaration files for test utilities |
| types/api_tests/api_test_root_issue/*.d.mts | Added type declarations for config and connection modules |
| tools/inspect-api-structure.mjs | Added lazy folder materialization utilities and improved debugging |
| src/slothlet.mjs | Implemented self-referential default export detection to prevent config double-nesting |
| src/lib/modes/slothlet_lazy.mjs | Added self-referential handling in lazy mode module loading |
| src/lib/modes/slothlet_eager.mjs | Added self-referential handling in eager mode module loading |
| package.json | Bumped version to 2.4.3 and updated module versions to 1.3.0 |
| api_tests/api_test_root_issue/config.mjs | Added prototype pollution protection in configuration update method |
| api_tests/api_test_root_issue/subfolder/config.mjs | Added prototype pollution protection (duplicate of root config.mjs) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
🔧 Formatting Fixes: - Fixed incorrect indentation in config.mjs files - Moved misplaced comments to proper positions above conditional blocks - Removed trailing whitespace from comment lines
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 18 out of 33 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Implement rawModuleCache Map in _buildCategory to cache raw imports - Optimize lazy mode first pass to load raw modules only once - Reuse already-loaded modules in second pass processing - Prevent duplicate I/O operations for modules with side effects - Maintain self-referential detection accuracy while improving performance - Add mandatory pre-commit validation chain to copilot instructions Performance impact: - Eliminates duplicate loading of each module (raw import + processed load) - Reduces I/O overhead especially for modules with initialization side effects - Maintains all existing functionality and API structure consistency
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 18 out of 33 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Performance optimizations: - Fix duplicate module loading in eager mode (_buildCategory) - Load processed modules during first pass for non-self-referential defaults - Reuse already-loaded modules in second pass to avoid duplicate _loadSingleModule calls - Maintain rawModuleCache for self-referential detection while eliminating duplicate I/O - Lazy mode already optimized correctly with proper caching strategy Bug fixes: - Fix runtime error in config.createManufacturerConfig methods - Change this.get() to this.getConfig() in both root and subfolder config files - Prevent method call errors that would break manufacturer config creation Development improvements: - Add mandatory pre-commit validation chain to copilot instructions - Require: debug test:node build:dist build:types test:types - Ensures code integrity and deployment readiness before any commit Validation results: - All 91 API paths validated successfully - All 8 test files pass - All 10 TypeScript exports validated - Performance improved while maintaining functionality - API structure remains identical between eager/lazy modes Impact: Eliminates duplicate loading overhead for modules with side effects while fixing critical runtime errors in config functionality.
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 18 out of 33 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…efaults Safety improvement in eager mode: - Add type check before assigning named exports to default exports - Only assign properties if mod.default is an object that can receive properties - Prevents runtime errors when mod.default is a primitive value (string, number, boolean, null) - Maintains functionality while preventing potential TypeError exceptions Fix applied: - Added condition: if (mod.default && typeof mod.default === 'object' && mod.default !== null) - Only assigns named exports as properties when default export can receive them - Lazy mode already safe: similar code path is within typeof mod.default === 'function' condition
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 18 out of 33 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 18 out of 33 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Fix architectural issue where named exports were being incorrectly assigned as properties of default export objects, which could fail with frozen/sealed objects. Named exports now go directly to API namespace for consistency. Changes: - Fix property assignment pattern in slothlet_eager.mjs - Change from api[apiKey][key] = value to api[key] = value for named exports - Ensure consistent behavior with 'No default export' case pattern - Prevent potential runtime errors with frozen/sealed default exports - Maintain API structure compatibility between eager and lazy modes
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 18 out of 33 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…ger mode Extracted eager_addNamedExportsToApi helper function to reduce duplication in multi-default export handling. The same logic for adding named exports to both api and rootNamedExports was duplicated in two code paths.
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 18 out of 33 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.
release: v2.4.3 - Performance Optimization, Runtime Safety, and Code Quality Refactoring
🚀 PERFORMANCE OPTIMIZATION AND DUPLICATE IMPORT ELIMINATION
• Implement rawModuleCache Map in _buildCategory method to eliminate duplicate module imports and prevent side effects
• Add first-pass raw module loading optimization with processedModuleCache in lazy mode for enhanced performance
• Eliminate redundant I/O operations through intelligent module caching reducing startup overhead significantly
• Performance improvements maintain identical API functionality while reducing resource consumption
• Enhanced module loading efficiency across both eager and lazy loading strategies without breaking changes
🛡️ RUNTIME SAFETY AND ARCHITECTURAL IMPROVEMENTS
• Fix architectural issue where named exports were incorrectly assigned as properties of default export objects
• Prevent potential runtime errors with frozen/sealed default export objects through proper API namespace assignment
• Change property assignment pattern from api[apiKey][key] = value to api[key] = value for named exports
• Ensure consistent behavior with "No default export" case pattern across all module export scenarios
• Enhanced null check logic optimization addressing JavaScript typeof null === 'object' quirk for improved reliability
🔧 SELF-REFERENTIAL EXPORT DETECTION AND BUG FIXES
• Implement comprehensive self-referential export detection using raw module imports vs processed modules
• Fix critical config.mjs double nesting bug where config appeared both as api.config.getConfig AND api.getConfig
• Enhanced multi-default export handling with exclusion of self-referential cases from flattening behavior
• Resolve export const config = {...}; export default config; pattern detection preventing namespace duplication
• Security fixes in api_test_root_issue/config.mjs replacing this.get() with this.getConfig() for runtime stability
🧹 CODE QUALITY AND MAINTAINABILITY IMPROVEMENTS
• Extract eager_addNamedExportsToApi helper function eliminating code duplication in multi-default export handling
• Replace duplicated for loops with single helper function calls improving maintainability and consistency
• Enhanced JSDoc documentation with proper @description tag formatting and comprehensive function documentation
• Improved function naming conventions with prefixes (lazy_, eager_, runtime_) for better debugging visibility
• Consistent architectural patterns ensuring named exports are added to API namespace rather than default export properties
🏗️ VALIDATION INFRASTRUCTURE AND TESTING ENHANCEMENTS
• Establish mandatory pre-commit validation chain: debug → test:node → build:dist → build:types → test:types
• Comprehensive validation across all 91 API paths ensuring structural consistency between eager and lazy modes
• Enhanced debug script with function execution analysis and argument forwarding verification through proxy chains
• TypeScript definitions validated for all 10 package exports maintaining type safety and deployment readiness
• Cross-mode API structure consistency validation confirming identical behavior regardless of loading strategy
📊 TECHNICAL INFRASTRUCTURE AND MODULE VERSIONING
• Package version progression: 2.4.2 → 2.4.3 representing significant performance and reliability improvements
• Enhanced module caching architecture with rawModuleCache and processedModuleCache implementations
• Improved build pipeline with mandatory validation requirements ensuring release quality standards
• Enhanced development guidelines with copilot-instructions.md updates including pre-commit validation requirements
• TypeScript build and validation pipeline improvements maintaining type safety across all export scenarios
🔒 API COMPATIBILITY AND CONSISTENCY GUARANTEES
• Zero breaking changes - all performance optimizations maintain full backward compatibility
• Enhanced robustness through architectural improvements while preserving existing API contracts
• Consistent namespace behavior across all file structures and export patterns without functional changes
• Improved error handling patterns preventing runtime failures with various object property assignment scenarios
• Cross-loading-mode consistency ensuring identical API behavior regardless of chosen loading strategy
Breaking Changes: None - performance optimizations and architectural improvements maintain full backward compatibility
Performance Impact: Significant startup performance improvement through duplicate import elimination with identical runtime characteristics
This release addresses critical performance bottlenecks, runtime safety issues, and code quality concerns identified through
comprehensive AI code analysis while maintaining the core v2.4.2 functionality and ensuring consistent behavior across
all loading modes and export patterns with enhanced reliability and maintainability standards.
---------
Co-authored-by: Nate - CLDMV <[email protected]>
🚀 What's Changed
💥 Breaking Changes
No breaking changes
✨ Features
No new features
🐛 Bug Fixes
🔧 Other Changes
🏷️ Release Information
👥 Contributors