Files
bun.sh/test_global_constructor.js
Claude Bot f3e5848549 Identify and document LazyClassStructure constructor export issue
## What was achieved
-  Fixed SyntheticModuleType enum generation by running bundle-modules.ts
-  Successfully build and load node:sqlite module with all exports
-  Module correctly exports backup, constants, DatabaseSync, StatementSync
-  Identified root cause of constructor instantiation issue

## Constructor Export Issue Analysis
- 🔍 **Root Cause**: LazyClassStructure timing conflict with native module exports
- 🔍 **Assertion**: `putDirectCustomAccessor` fails during module initialization
- 🔍 **Affects**: Both direct constructor export and wrapper function approaches
- 🔍 **Timing**: Occurs when accessing JSNodeSQLiteDatabaseSyncStructure() during module init

## Implementation Status
-  Module loading works: `require('node:sqlite')`
-  Proper API surface: DatabaseSync, StatementSync, constants, backup
-  Build system integration complete
- ⚠️ Constructor instantiation blocked by JSC assertion
- ⚠️ StatementSync properly designed to require database instance

## Files changed
- STATUS.md: Updated with detailed analysis and current status
- NodeSQLiteModule.cpp: Implemented constructor wrappers (blocked by JSC issue)
- NodeSQLiteModule.h: Updated exports to use wrapper functions
- test_*.js: Created test files to isolate the issue

## Next Steps
- Requires JSC/LazyClassStructure expert knowledge
- Alternative: Implement constructors without LazyClassStructure system
- Current workaround: Placeholders with error messages

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-06 14:30:22 +00:00

22 lines
776 B
JavaScript

#!/usr/bin/env node
// Test if constructors are accessible globally
try {
console.log('Testing global constructor access...');
// Test if they're in global scope
console.log('typeof globalThis.NodeSQLiteDatabaseSync:', typeof globalThis.NodeSQLiteDatabaseSync);
console.log('typeof globalThis.NodeSQLiteStatementSync:', typeof globalThis.NodeSQLiteStatementSync);
// Try accessing them directly
if (typeof NodeSQLiteDatabaseSync !== 'undefined') {
console.log('NodeSQLiteDatabaseSync found globally:', NodeSQLiteDatabaseSync.name);
}
if (typeof NodeSQLiteStatementSync !== 'undefined') {
console.log('NodeSQLiteStatementSync found globally:', NodeSQLiteStatementSync.name);
}
} catch (error) {
console.error('Error:', error.message);
}