Files
next.js/turbopack/crates/turbopack-swc-ast-explorer/README.md
hrmny becc655b0e Add 'turbopack/' from commit 'fb033c4917bb1bb98b238f1b4c7a928b66a90887'
git-subtree-dir: turbopack
git-subtree-mainline: 344ddbf093
git-subtree-split: fb033c4917
2024-08-01 16:50:52 +02:00

1.3 KiB

swc-ast-explorer

A small binary to print out SWC Abtract Syntax Trees.

echo "console.log('hello')" | cargo run -p swc-ast-explorer
Script(
  Script {
    body: [
      Expr(
        ExprStmt {
          expr: Call(
            CallExpr {
              callee: Expr(
                Member(
                  MemberExpr {
                    obj: Ident(
                      Ident {
                        sym: Atom('console' type=inline),
                        optional: false,
                      },
                    ),
                    prop: Ident(
                      Ident {
                        sym: Atom('log' type=inline),
                        optional: false,
                      },
                    ),
                  },
                ),
              ),
              args: [
                ExprOrSpread {
                  spread: None,
                  expr: Lit(
                    Str(
                      Str {
                        value: Atom('hello' type=inline),
                        raw: Some(
                          "'hello'",
                        ),
                      },
                    ),
                  ),
                },
              ],
              type_args: None,
            },
          ),
        },
      ),
    ],
    shebang: None,
  },
)