Skip to content

feat: use nodejs-built-in-modules crate to remove duplicated code#81

Merged
Boshen merged 1 commit intomainfrom
feat/use-nodejs-built-in-modules-crate
Dec 24, 2025
Merged

feat: use nodejs-built-in-modules crate to remove duplicated code#81
Boshen merged 1 commit intomainfrom
feat/use-nodejs-built-in-modules-crate

Conversation

@Boshen
Copy link
Collaborator

@Boshen Boshen commented Dec 24, 2025

Summary

Replace the local src/builtins.rs module with the nodejs-built-in-modules crate to eliminate code duplication and leverage a shared, up-to-date list of Node.js built-in modules.

Motivation

This change is part of an effort to remove duplicated code across the Rust ecosystem, similar to the work done in oxc-project/oxc-resolver#940.

Multiple Rust projects were maintaining their own hardcoded lists of Node.js built-in modules, which:

  • Creates maintenance burden when Node.js adds new built-in modules
  • Leads to inconsistencies between projects
  • Duplicates code unnecessarily

Benefits

  1. Updated Node.js v24 support: The crate includes newly added Node.js v24 built-in modules like:

    • inspector/promises
    • wasi
    • Various internal modules (_http_*, _stream_*, _tls_*)
  2. Handles node: prefix requirement: The crate correctly handles the built-in modules with mandatory node: prefix:

    • sea
    • sqlite
    • test
    • test/reporters
  3. Reduces maintenance: Future updates to Node.js built-in modules only require updating the shared crate version.

  4. Code reduction: Removes ~60 lines of duplicated code from this repository.

Changes

  • Added nodejs-built-in-modules = "0.0.1" dependency
  • Removed src/builtins.rs file
  • Updated src/lib.rs to use nodejs_built_in_modules::is_nodejs_builtin_module()

Testing

All existing tests pass:

test result: ok. 37 passed; 0 failed; 0 ignored; 0 measured

@github-actions
Copy link
Contributor

Benchmark for 67901c7

Click to view benchmark
Test Base PR %
vpath_edge_cases 2.1±0.14µs 2.1±0.09µs 0.00%
vpath_mixed_workload 4.6±0.16µs 4.6±0.14µs 0.00%
vpath_native 1396.7±45.82ns 1362.1±36.31ns -2.48%
vpath_virtual 3.4±0.11µs 3.4±0.11µs 0.00%
vpath_virtual_zip 2.9±0.10µs 2.9±0.09µs 0.00%
vpath_zip 1900.8±69.92ns 1830.5±52.53ns -3.70%

@Boshen Boshen merged commit c61eced into main Dec 24, 2025
6 checks passed
@Boshen Boshen deleted the feat/use-nodejs-built-in-modules-crate branch December 24, 2025 11:35
@github-actions github-actions bot mentioned this pull request Dec 14, 2025
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.

1 participant