@swc/plugin-jest 0.1.10 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/Cargo.toml CHANGED
@@ -4,16 +4,15 @@ description = "Jest plugin for https://swc.rs"
4
4
  edition = "2018"
5
5
  license = "Apache-2.0"
6
6
  name = "swc_plugin_jest"
7
- version = "0.1.0"
7
+ version = "0.7.0"
8
8
 
9
9
  [lib]
10
10
  crate-type = ["cdylib", "rlib"]
11
11
 
12
12
  [dependencies]
13
- abi_stable = "0.10.2"
14
13
  phf = {version = "0.10.0", features = ["macros"]}
15
14
  serde = {version = "1.0.130", features = ["derive"]}
16
- swc_atoms = "0.2.7"
17
- swc_common = {version = "0.14.4", features = ["concurrent"]}
18
- swc_ecmascript = {features = ["utils", "visit"], version = "0.84.0"}
19
- swc_plugin = "0.11.0"
15
+ swc_atoms = "0.2.9"
16
+ swc_common = {version = "0.17.5", features = ["concurrent"]}
17
+ swc_ecmascript = {features = ["utils", "visit"], version = "0.113.2"}
18
+ swc_plugin = "0.26.1"
package/package.json CHANGED
@@ -1,30 +1,20 @@
1
1
  {
2
- "author": "강동윤 <kdy1997.dev@gmail.com>",
3
- "bugs": {
4
- "url": "https://github.com/swc-project/plugins/issues"
5
- },
6
- "description": "Jest transform plugin for https://swc.rs",
7
- "homepage": "https://swc.rs",
8
- "keywords": [],
9
- "license": "Apache-2.0",
10
- "main": "index.js",
11
2
  "name": "@swc/plugin-jest",
12
- "optionalDependencies": {
13
- "@swc/plugin-jest-android-arm64": "0.1.10",
14
- "@swc/plugin-jest-darwin-arm64": "0.1.10",
15
- "@swc/plugin-jest-darwin-x64": "0.1.10",
16
- "@swc/plugin-jest-linux-arm-gnueabihf": "0.1.10",
17
- "@swc/plugin-jest-linux-arm64-gnu": "0.1.10",
18
- "@swc/plugin-jest-linux-arm64-musl": "0.1.10",
19
- "@swc/plugin-jest-linux-x64-gnu": "0.1.10",
20
- "@swc/plugin-jest-win32-x64-msvc": "0.1.10"
3
+ "version": "0.2.0",
4
+ "description": "Jest transform plugin for https://swc.rs",
5
+ "main": "swc_plugin_jest.wasm",
6
+ "scripts": {
7
+ "prepack": "cp ../../target/wasm32-wasi/release/swc_plugin_jest.wasm ."
21
8
  },
9
+ "homepage": "https://swc.rs",
22
10
  "repository": {
23
11
  "type": "git",
24
12
  "url": "+https://github.com/swc-project/plugins.git"
25
13
  },
26
- "scripts": {
27
- "test": "echo \"Error: no test specified\" && exit 1"
14
+ "bugs": {
15
+ "url": "https://github.com/swc-project/plugins/issues"
28
16
  },
29
- "version": "0.1.10"
30
- }
17
+ "author": "강동윤 <kdy1997.dev@gmail.com>",
18
+ "keywords": [],
19
+ "license": "Apache-2.0"
20
+ }
package/src/lib.rs CHANGED
@@ -4,10 +4,11 @@ use swc_common::util::take::Take;
4
4
  use swc_ecmascript::{
5
5
  ast::*,
6
6
  utils::{prepend_stmts, StmtLike},
7
- visit::{as_folder, noop_visit_mut_type, Fold, VisitMut, VisitMutWith},
7
+ visit::{noop_visit_mut_type, VisitMut, VisitMutWith},
8
8
  };
9
+ use swc_plugin::plugin_transform;
9
10
 
10
- swc_plugin::define_js_plugin!(jest);
11
+ // swc_plugin::define_js_plugin!(jest);
11
12
 
12
13
  static HOIST_METHODS: phf::Set<&str> = phf_set![
13
14
  "mock",
@@ -17,8 +18,11 @@ static HOIST_METHODS: phf::Set<&str> = phf_set![
17
18
  "deepUnmock"
18
19
  ];
19
20
 
20
- fn jest(_: Config) -> impl Fold + VisitMut {
21
- as_folder(Jest)
21
+ #[plugin_transform]
22
+ fn jest(mut program: Program, _plugin_config: String) -> Program {
23
+ program.visit_mut_with(&mut Jest);
24
+
25
+ program
22
26
  }
23
27
 
24
28
  #[derive(Deserialize)]
@@ -45,27 +49,23 @@ impl Jest {
45
49
  Ok(stmt) => match &stmt {
46
50
  Stmt::Expr(ExprStmt { expr, .. }) => match &**expr {
47
51
  Expr::Call(CallExpr {
48
- callee: ExprOrSuper::Expr(callee),
52
+ callee: Callee::Expr(callee),
49
53
  ..
50
54
  }) => match &**callee {
51
55
  Expr::Member(
52
- callee
53
- @
54
- MemberExpr {
55
- computed: false, ..
56
+ callee @ MemberExpr {
57
+ prop: MemberProp::Ident(prop),
58
+ ..
56
59
  },
57
- ) => match &callee.obj {
58
- ExprOrSuper::Super(_) => new.push(T::from_stmt(stmt)),
59
- ExprOrSuper::Expr(callee_obj) => match &**callee_obj {
60
- Expr::Ident(i) if i.sym == *"jest" => match &*callee.prop {
61
- Expr::Ident(prop) if HOIST_METHODS.contains(&*prop.sym) => {
62
- hoisted.push(T::from_stmt(stmt));
63
- return;
64
- }
65
- _ => new.push(T::from_stmt(stmt)),
66
- },
60
+ ) => match &*callee.obj {
61
+ Expr::Ident(i) if i.sym == *"jest" => match prop {
62
+ _ if HOIST_METHODS.contains(&*prop.sym) => {
63
+ hoisted.push(T::from_stmt(stmt));
64
+ return;
65
+ }
67
66
  _ => new.push(T::from_stmt(stmt)),
68
67
  },
68
+ _ => new.push(T::from_stmt(stmt)),
69
69
  },
70
70
  _ => new.push(T::from_stmt(stmt)),
71
71
  },
Binary file