Skip to content

Commit b649e11

Browse files
committed
exponentation_operator
1 parent 99eaf19 commit b649e11

File tree

2 files changed

+23
-9
lines changed

2 files changed

+23
-9
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
use swc_ecma_hooks::VisitMutHook;
2+
3+
use crate::TraverseCtx;
4+
5+
pub fn hook() -> impl VisitMutHook<TraverseCtx> {
6+
ExponentiationOperatorPass::default()
7+
}
8+
9+
#[derive(Default)]
10+
struct ExponentiationOperatorPass {}
11+
12+
impl VisitMutHook<TraverseCtx> for ExponentiationOperatorPass {}

crates/swc_ecma_transformer/src/es2016/mod.rs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
1+
mod exponentation_operator;
2+
13
use swc_ecma_hooks::VisitMutHook;
24

3-
use crate::TraverseCtx;
5+
use crate::{hook_utils::OptionalHook, TraverseCtx};
46

57
#[derive(Debug, Default)]
68
#[non_exhaustive]
7-
pub struct Es2016Options {}
8-
9-
pub fn hook(options: Es2016Options) -> impl VisitMutHook<TraverseCtx> {
10-
Es2016Pass { options }
9+
pub struct Es2016Options {
10+
pub exponentation_operator: bool,
1111
}
1212

13-
struct Es2016Pass {
14-
options: Es2016Options,
13+
pub fn hook(options: Es2016Options) -> impl VisitMutHook<TraverseCtx> {
14+
OptionalHook(if options.exponentation_operator {
15+
Some(self::exponentation_operator::hook())
16+
} else {
17+
None
18+
})
1519
}
16-
17-
impl VisitMutHook<TraverseCtx> for Es2016Pass {}

0 commit comments

Comments
 (0)