Skip to content

Commit

Permalink
build(macros): Drop pmutil to improve compile time (#8404)
Browse files Browse the repository at this point in the history
**Description:**

`pmutil` born to die. Now almost all useful features are merged into `syn` and `quote`, so it's now just a compile-time bloat. (Although I didn't send PRs to them, sorry)
  • Loading branch information
kdy1 committed Dec 8, 2023
1 parent dbeb869 commit 835151e
Show file tree
Hide file tree
Showing 43 changed files with 838 additions and 1,132 deletions.
13 changes: 0 additions & 13 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion crates/ast_node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ bench = false
proc-macro = true

[dependencies]
pmutil = "0.6.1"
proc-macro2 = "1"
quote = "1"

Expand Down
27 changes: 10 additions & 17 deletions crates/ast_node/src/ast_node_macro.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use pmutil::{smart_quote, Quote};
use swc_macros_common::prelude::*;
use syn::{
self,
Expand All @@ -22,22 +21,16 @@ pub fn expand_struct(args: Args, i: DeriveInput) -> Vec<ItemImpl> {
let generics = i.generics.clone();
// let item_ident = Ident::new("Item", i.ident.span());

items.push(
Quote::new_call_site()
.quote_with(smart_quote!(
Vars {
Type: i.ident.clone(),
type_str: args.ty
},
{
impl ::swc_common::AstNode for Type {
const TYPE: &'static str = type_str;
}
}
))
.parse::<ItemImpl>()
.with_generics(generics),
);
{
let ty = &i.ident;
let type_str = &args.ty;
let item: ItemImpl = parse_quote!(
impl ::swc_common::AstNode for #ty {
const TYPE: &'static str = #type_str;
}
);
items.push(item.with_generics(generics));
}

// let ident = i.ident.clone();
// let cloned = i.clone();
Expand Down

0 comments on commit 835151e

Please sign in to comment.