This commit is contained in:
강동윤 2019-02-13 11:56:45 +09:00 committed by GitHub
parent bf128d295f
commit 74858c3b66
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -77,9 +77,30 @@ impl Fold<Vec<ModuleItem>> for Strip {
| ModuleItem::ModuleDecl(ModuleDecl::ExportDefaultDecl(
ExportDefaultDecl::TsInterfaceDecl(..),
))
| ModuleItem::ModuleDecl(ModuleDecl::TsImportEquals(..))
| ModuleItem::ModuleDecl(ModuleDecl::TsNamespaceExport(..)) => None,
ModuleItem::ModuleDecl(ModuleDecl::TsImportEquals(import)) => {
if !import.is_export {
return None;
}
Some(ModuleItem::ModuleDecl(
ModuleDecl::ExportNamed(NamedExport {
span: DUMMY_SP,
specifiers: vec![ExportSpecifier::Named(NamedExportSpecifier {
span: DUMMY_SP,
exported: Some(import.id),
orig: match import.module_ref {
TsModuleRef::TsEntityName(TsEntityName::Ident(i)) => i,
_ => unimplemented!("export import A = B where B != Ident"),
},
})],
src: None,
})
.fold_with(self),
))
}
ModuleItem::ModuleDecl(ModuleDecl::TsExportAssignment(export)) => Some(
ModuleItem::ModuleDecl(ModuleDecl::ExportDefaultExpr(export.expr).fold_with(self)),
),
@ -191,7 +212,7 @@ mod tests {
}"
);
// to!(export_import, "export import A = B", "export { B as A }");
to!(export_import, "export import A = B", "export { B as A }");
to!(export_equals, "export = Foo", "export default Foo");
}