Skip to content

Commit

Permalink
Merge branch 'main' into feat/update_swc_core
Browse files Browse the repository at this point in the history
  • Loading branch information
ClarkXia committed Aug 16, 2023
2 parents 6390162 + 1ae3423 commit efa0755
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/node-transform/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,13 +196,17 @@ impl Fold for NodeTransform {
match specifier {
ImportSpecifier::Named(named) => {
let ImportNamedSpecifier {
local, ..
local, imported, ..
} = named;
let mut property = &local.sym;
if let Some(ModuleExportName::Ident(import_ident)) = imported {
property = &import_ident.sym;
}
new_module_items.push(ModuleItem::Stmt(Stmt::Decl(Decl::Var(Box::new(VarDecl {
span: DUMMY_SP,
kind: VarDeclKind::Const,
declare: false,
decls: vec![create_member_decl(local.clone(), &import_val, &local.sym)],
decls: vec![create_member_decl(local.clone(), &import_val, property)],
})))))
}
ImportSpecifier::Namespace(namespace) => {
Expand Down
3 changes: 3 additions & 0 deletions packages/node-transform/tests/fixture/import-local/input.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { a as b } from 'test';

console.log(b);
3 changes: 3 additions & 0 deletions packages/node-transform/tests/fixture/import-local/output.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const __ice_import_0__ = await __ice_import__("test");
const b = __ice_import_0__.a;
console.log(b);

0 comments on commit efa0755

Please sign in to comment.