Overview of swc_estree_ast
mainswc_estree_ast crate provides a Rust representation of the Babel AST (Abstract Syntax Tree). The definitions in this crate are derived from the Babel AST types found in the Babel repository.repository·main·Indexed 20 days ago
https://github.com/nodejs/amaroA WebAssembly-based TypeScript parser wrapper built on @swc/wasm-typescript that provides type stripping capabilities. Used internally by Node.js and available as a standalone package, it allows users to manage their own TypeScript transpiler versions. It supports TypeScript 5.5.4 and provides a transformSync function for programmatic type stripping.
swc_estree_ast crate provides a Rust representation of the Babel AST (Abstract Syntax Tree). The definitions in this crate are derived from the Babel AST types found in the Babel repository.The swc_bundler is a bundler designed for the SWC project. It provides high-performance bundling capabilities with a focus on generating clean code that is easy for subsequent optimization steps. Key features include:
require syntax.swc_css_parser is a CSS parser designed for the SWC project. It is used to transform CSS source code into a parsed Abstract Syntax Tree (AST).The swc_ecma_regexp crate provides an implementation of the ECMAScript® 2024 Language Specification for Regular Expressions. It supports standard ECMAScript 2024 features and includes support for Stage 4 proposals, specifically:
proposal-duplicate-named-capturing-groupsproposal-regexp-modifiersThe @swc/wasm-typescript package provides a WebAssembly (Wasm) binding specifically for performing TypeScript transforms. It allows you to leverage SWC's TypeScript transformation capabilities within environments that support Wasm.
Supported TypeScript Version: Currently supports TypeScript 5.5.4.
Note on Decorators: The stage 3 decorator proposal is currently not supported.
better_scoped_tls crate provides an opinionated version of the scoped-tls crate. It maintains the exact same syntax as the original scoped-tls but improves error handling. If a scoped thread local variable is accessed outside of the closure provided by the .set method, the crate will panic with a descriptive error message indicating that the operation must be performed within the .set closure.swc_estree_compat crate provides functionality to convert the SWC Abstract Syntax Tree (AST) into a Babel-compatible AST (ESTree). This is useful when you need to interface SWC-based tools with the broader ecosystem of tools that expect the ESTree format used by Babel.The SWC bindings (including @swc/core, swc_cli, and @swc/wasm) are built using the publicly published swc_core SDK. This ensures that the host binaries are deterministic for specific changes.
Note that these bindings are intentionally excluded from the main Cargo workspace build process to prevent dependency version conflicts that occur when a workspace contains unpublished packages.
The test suite for swc_css_parser is organized into several functional categories to ensure parsing accuracy and error handling:
/tests/fuxture: Validates the full transformation pipeline: CSS $\rightarrow$ Parsed AST $\rightarrow$ JSON./tests/error: Focuses on error reporting and how the parser handles invalid CSS./tests/identity: Ensures consistency by verifying that input.css and input.explicit.css are parsed identically. These tests are adapted from esbuild.Note: Test names follow the format base64_url(md5(name)).
The swc_plugin crate, which previously served as the entrypoint SDK for authoring SWC plugins, is now deprecated.
Instead of using swc_plugin, you should use swc_core. swc_core has become the meta entrypoint for all features provided by SWC, including plugin development.
To avoid passing --import flags every time, you can register Amaro in a bootstrap file using node:module's register function. This makes TypeScript work automatically for the rest of your application's lifecycle.
```mjs
// bootstrap.mjs
import { register } from "node:module";
register("amaro/strip", import.meta.url);
await import("./src/index.ts");Then run your application via the bootstrap file:
node --watch ./bootstrap.mjsNote: For transform mode, use amaro/transform instead of amaro/strip and run Node with --enable-source-maps.