Skip to content

feat: implement dynamic builtin module detection (fixes #50)#51

Open
konard wants to merge 3 commits intomainfrom
issue-50-05d4b42f950f
Open

feat: implement dynamic builtin module detection (fixes #50)#51
konard wants to merge 3 commits intomainfrom
issue-50-05d4b42f950f

Conversation

@konard
Copy link
Member

@konard konard commented Dec 25, 2025

Summary

This PR implements dynamic built-in module detection using Node.js module.isBuiltin() API, replacing the hardcoded supportedBuiltins list.

Changes:

  • Dynamic detection: Uses module.isBuiltin() (Node.js 18.6.0+) with fallback to module.builtinModules for older versions
  • Reduced code: Removes ~200+ lines of hardcoded module definitions
  • Special handling preserved: Maintains special handling only for modules that need it:
    • Browser polyfills (console, crypto, url, performance)
    • Bun/Deno compatibility (fs/promises, process)
    • Special export handling (events, stream, buffer, assert)
    • Explicit browser error messages (fs, path, os, child_process, http, https, net, dns, zlib, util, querystring)
  • Case study: Added documentation in docs/case-studies/issue-50/README.md
  • New tests: Added tests for dynamically detected modules (tty, cluster, readline, string_decoder, timers, worker_threads, vm, punycode)

Benefits:

  • Automatically supports all 70+ Node.js built-in modules instead of just ~25
  • Future-proof: New Node.js built-in modules are supported automatically
  • Smaller codebase: Less maintenance burden
  • All existing tests pass: 264 of 266 tests pass (2 unrelated typescript test failures due to npm global package conflicts)

Test plan

  • Run existing unit tests (npm test)
  • Verify all builtin tests pass
  • Verify browser tests pass
  • Test dynamically detected modules (tty, cluster, readline, etc.)
  • Verify special handling still works (fs/promises, process for Deno, events with EventEmitter, etc.)

Fixes #50

🤖 Generated with Claude Code

Adding CLAUDE.md with task information for AI processing.
This file will be removed when the task is complete.

Issue: #50
@konard konard self-assigned this Dec 25, 2025
Replaces hardcoded supportedBuiltins list with dynamic detection using
Node.js module.isBuiltin() API. This change:

- Uses module.isBuiltin() (Node.js 18.6.0+) for dynamic detection
- Falls back to module.builtinModules for older Node.js versions
- Keeps special handling only for modules that need it:
  - Browser polyfills (console, crypto, url, performance)
  - Bun/Deno compatibility (fs/promises, process)
  - Special export handling (events, stream, buffer, assert)
  - Browser error messages (fs, path, os, etc.)

Benefits:
- Automatically supports all 70+ Node.js built-in modules
- Future-proof: new modules are supported automatically
- Smaller codebase with less maintenance burden
- All existing tests continue to pass

Adds tests for dynamically detected modules like tty, cluster,
readline, string_decoder, timers, worker_threads, vm, and punycode.

Fixes #50

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

Co-Authored-By: Claude <noreply@anthropic.com>
@konard konard changed the title [WIP] do not hardcode builtins feat: implement dynamic builtin module detection (fixes #50) Dec 25, 2025
@konard konard marked this pull request as ready for review December 25, 2025 10:59
@konard
Copy link
Member Author

konard commented Dec 25, 2025

🤖 Solution Draft Log

This log file contains the complete execution trace of the AI solution draft process.

💰 Cost estimation:

  • Public pricing estimate: $7.846246 USD
  • Calculated by Anthropic: $5.578319 USD
  • Difference: $-2.267927 (-28.90%)
    📎 Log file uploaded as GitHub Gist (1122KB)
    🔗 View complete solution draft log

Now working session is ended, feel free to review and add any feedback on the solution draft.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

do not hardcode builtins

1 participant