Crate nodejs_resolver
source ·Expand description
nodejs_resolver
How to use?
// |-- node_modules
// |---- foo
// |------ index.js
// | src
// |-- foo.ts
// |-- foo.js
// | tests
use nodejs_resolver::Resolver;
let cwd = std::env::current_dir().unwrap();
let resolver = Resolver::new(Default::default());
resolver.resolve(&cwd.join("./src"), "foo");
// -> ResolveResult::Info(ResolveInfo {
// path: PathBuf::from("<cwd>/node_modules/foo/index.js")
// request: Request {
// target: "",
// fragment: "",
// query: ""
// }
// })
//
resolver.resolve(&cwd.join("./src"), "./foo");
// -> ResolveResult::Info(ResolveInfo {
// path: PathBuf::from("<cwd>/src/foo.js")
// request: Request {
// target: "",
// fragment: "",
// query: ""
// }
// })
//