pub fn import<M, N>(module: M, name: N) -> Import
Expand description
The import of a JavaScript type import {foo} from "module.js"
.
ยงExamples
use genco::prelude::*;
let default_vec = js::import("collections", "defaultVec").into_default();
let all = js::import("collections", "all").into_wildcard();
let vec = js::import("collections", "vec");
let vec_as_list = js::import("collections", "vec").with_alias("list");
let toks = quote! {
$default_vec
$all
$vec
$vec_as_list
};
assert_eq!(
vec![
"import * as all from \"collections\";",
"import defaultVec, {vec, vec as list} from \"collections\";",
"",
"defaultVec",
"all",
"vec",
"list",
],
toks.to_file_vec()?
);