2021-06-24 09:32:09 +03:00
|
|
|
use swc_common::FileName;
|
2021-08-10 09:36:10 +03:00
|
|
|
use swc_ecma_loader::resolvers::node::NodeModulesResolver;
|
2021-06-24 09:32:09 +03:00
|
|
|
use swc_ecma_transforms_module::path::{ImportResolver, NodeImportResolver};
|
|
|
|
use testing::run_test2;
|
2021-08-10 09:36:10 +03:00
|
|
|
type TestProvider = NodeImportResolver<NodeModulesResolver>;
|
2021-06-24 09:32:09 +03:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn node_modules() {
|
|
|
|
let provider = TestProvider::default();
|
|
|
|
|
|
|
|
run_test2(false, |cm, _| {
|
|
|
|
let fm = cm.new_source_file(FileName::Real("foo".into()), "".into());
|
|
|
|
|
|
|
|
let resolved = provider
|
|
|
|
.resolve_import(&fm.name, "core-js")
|
|
|
|
.expect("should success");
|
|
|
|
|
|
|
|
assert_eq!(&*resolved, "core-js");
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
})
|
|
|
|
.unwrap();
|
|
|
|
}
|