6 stable releases

Uses old Rust 2015

2.2.0 May 16, 2018
2.1.1 May 8, 2018
2.0.0 May 6, 2018
1.1.0 Mar 8, 2018
1.0.1 Mar 6, 2018

#880 in Filesystem

Download history 116/week @ 2023-12-18 29/week @ 2023-12-25 57/week @ 2024-01-01 56/week @ 2024-01-08 56/week @ 2024-01-15 91/week @ 2024-01-22 116/week @ 2024-01-29 98/week @ 2024-02-05 105/week @ 2024-02-12 86/week @ 2024-02-19 106/week @ 2024-02-26 139/week @ 2024-03-04 149/week @ 2024-03-11 158/week @ 2024-03-18 83/week @ 2024-03-25 222/week @ 2024-04-01

623 downloads per month
Used in hai_pal

Apache-2.0

18KB
320 lines

node-resolve

node-resolve on crates.io

Rust implementation of the Node.js module resolution algorithm.

Missing features:

  • async?
  • maybe more

Install

Add to your Cargo.toml:

[dependencies]
node-resolve = "2.2.0"

Usage

See docs.rs/node-resolve.

License

Apache-2.0


lib.rs:

Resolve module identifiers in a Node-style require() to a full file path.

use node_resolve::{resolve, resolve_from};

resolve("abc");
// → Ok("/path/to/cwd/node_modules/abc/index.js")
resolve_from("abc", PathBuf::from("/other/path"));
// → Ok("/other/path/node_modules/abc/index.js")

Dependencies

~360–760KB
~17K SLoC