inset ImportDecl after transform changed to named import #5899
Answered
by
kdy1
liaoyinglong
asked this question in
Q&A
-
this is plugin code impl VisitMut for AutoImport {
fn visit_mut_module(&mut self, module: &mut Module) {
module.visit_mut_children_with(self);
module.body.insert(
0,
ModuleItem::ModuleDecl(ModuleDecl::Import(ImportDecl {
span: Default::default(),
specifiers: vec![ImportSpecifier::Named(ImportNamedSpecifier {
span: Default::default(),
local: quote_ident!("Trans"),
imported: None,
is_type_only: false,
})],
src: Str::from("@scope/lib"),
type_only: false,
asserts: None,
})),
)
}
} testinput code <Trans>Refresh inbox</Trans>; in test_fixture is expected, rust sideexpect output(in test_fixture is correct) import { Trans } from "@scope/lib";
<Trans>Refresh inbox</Trans>; build to wasm , and use by
|
Beta Was this translation helpful? Give feedback.
Answered by
kdy1
Sep 19, 2022
Replies: 1 comment 1 reply
-
https://swc.rs/docs/plugin/ecmascript/cheatsheet#apply-resolver-while-testing |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
kdy1
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://swc.rs/docs/plugin/ecmascript/cheatsheet#apply-resolver-while-testing