Commit f04e9ce
Port ES2022 modules to compat and implement VisitMut for CompatCompiler
This commit ports oxc's ES2022 transformer architecture to SWC's AST and
Visitor API, implementing the VisitMut trait for CompatCompiler to enable
composable transformations.
## Changes
### CompatCompiler
- Implemented VisitMut trait with visitor methods for all relevant AST nodes
- Added support for composable transformations by calling VisitMutHook
instances
- Transformations execute in order: TypeScript → Plugins → ES2026 → ES2021
→ ES2020 → ES2019 → ES2018 → ES2017 → ES2016 → ES2015 → RegExp
### ES2022 Module
- Ported class_static_block.rs from oxc to SWC
- Transforms static blocks to private fields with IIFE
- Implements VisitMutHook for composability
- Includes comprehensive unit tests
- Created stub implementation for class_properties
- Full implementation requires ~7000 lines across 13 files
- Documented implementation plan for incremental porting
- Created ES2022 struct that combines class_static_block and
class_properties
### TypeScript Support
- Added `enabled()` method to TypeScriptOptions
### Code Quality
- All changes pass `cargo clippy --all --all-targets -- -D warnings`
- Formatted with `cargo fmt --all`
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>1 parent d77c19b commit f04e9ce
File tree
8 files changed
+893
-455
lines changed- crates/swc_ecma_compiler/src
- compat
- es2022
- class_properties
- typescript
- oxc/es2022
8 files changed
+893
-455
lines changedLines changed: 90 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
0 commit comments