Skip to content

Commit 2fb65b6

Browse files
committed
fix: upgrade swc_core
1 parent 09fcc74 commit 2fb65b6

File tree

15 files changed

+734
-870
lines changed

15 files changed

+734
-870
lines changed

Cargo.lock

Lines changed: 597 additions & 746 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,23 @@ members = [
66
"packages/node-transform"
77
]
88

9+
[workspace.dependencies]
10+
anyhow = "1.0.83"
11+
fxhash = "0.2.1"
12+
serde = "1.0.203"
13+
serde_json = "1.0.117"
14+
swc_atoms = "2.0.0"
15+
swc_common = "1.0.0"
16+
swc_core = "1.0.0"
17+
swc_ecma_ast = "1.0.0"
18+
swc_ecma_parser = "1.0.0"
19+
swc_ecma_utils = "1.0.0"
20+
swc_ecma_visit = "1.0.0"
21+
swc_plugin_macro = "1.0.0"
22+
swc_plugin_proxy = "1.0.0"
23+
testing = "1.0.0"
24+
tracing = "0.1.40"
25+
926
[profile.release]
1027
# This removes more dead code
1128
codegen-units = 1

packages/keep-export/Cargo.toml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,20 @@ edition = "2021"
77
crate-type = ["cdylib", "rlib"]
88

99
[dependencies]
10-
serde = "1"
11-
fxhash= "0.2.1"
12-
easy-error = "1.0.0"
13-
tracing = { version="0.1.34", features = ["release_max_level_info"] }
14-
swc_core = {version = "0.79.56", features = [
10+
serde ={ workspace = true }
11+
fxhash= { workspace = true }
12+
tracing = { workspace = true, features = ["release_max_level_info"] }
13+
swc_core = { workspace = true, features = [
1514
"ecma_plugin_transform",
1615
"ecma_utils",
1716
"ecma_visit",
1817
"ecma_ast",
1918
"common",
2019
]}
21-
swc_common = { version = "0.31.18", features = ["concurrent"] }
22-
serde_json = {version = "1", features = ["unbounded_depth"]}
20+
swc_common = { workspace = true, features = ["concurrent"] }
21+
serde_json = { workspace = true, features = ["unbounded_depth"]}
22+
swc_plugin_macro = { workspace = true }
23+
swc_plugin_proxy = { workspace = true }
2324

2425
[dev-dependencies]
25-
testing = "0.33.21"
26+
testing = { workspace = true }

packages/keep-export/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@ice/swc-plugin-keep-export",
3-
"version": "0.2.0",
3+
"version": "0.3.0",
44
"license": "MIT",
55
"keywords": ["swc-plugin"],
66
"main": "swc_plugin_keep_export.wasm",

packages/keep-export/src/lib.rs

Lines changed: 10 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1+
#![allow(clippy::not_unsafe_ptr_arg_deref)]
12
use fxhash::FxHashSet;
23
use std::mem::take;
34
use swc_common::pass::{Repeat, Repeated};
45
use swc_common::DUMMY_SP;
5-
use swc_core::{
6-
ecma::{
7-
ast::*,
8-
visit::{Fold, FoldWith, noop_fold_type},
9-
},
10-
plugin::{plugin_transform, proxies::TransformPluginProgramMetadata},
6+
use swc_core::ecma::{
7+
ast::*,
8+
visit::{Fold, FoldWith, noop_fold_type},
119
};
10+
use swc_plugin_proxy::TransformPluginProgramMetadata;
11+
use swc_plugin_macro::plugin_transform;
1212

1313
/// Note: This paths requires running `resolver` **before** running this.
1414
pub fn keep_exprs(keep_exports: Vec<String>) -> impl Fold {
1515
Repeat::new(KeepExportsExprs {
1616
state: State {
17-
keep_exports: keep_exports,
17+
keep_exports,
1818
..Default::default()
1919
},
2020
in_lhs_of_var: false,
@@ -379,7 +379,7 @@ impl Fold for KeepExportsExprs {
379379
tracing::trace!(
380380
"Dropping import `{}{:?}` because it should be removed",
381381
local.sym,
382-
local.span.ctxt
382+
local.span
383383
);
384384

385385
self.state.should_run_again = true;
@@ -421,7 +421,7 @@ impl Fold for KeepExportsExprs {
421421
specifiers: Vec::new(),
422422
src: None,
423423
type_only: false,
424-
asserts: None
424+
with: None
425425
})));
426426
}
427427

@@ -509,7 +509,7 @@ impl Fold for KeepExportsExprs {
509509
tracing::trace!(
510510
"Dropping var `{}{:?}` because it should be removed",
511511
name.id.sym,
512-
name.id.span.ctxt
512+
name.id.span
513513
);
514514

515515
return Pat::Invalid(Invalid { span: DUMMY_SP });
@@ -630,26 +630,6 @@ impl Fold for KeepExportsExprs {
630630
}
631631
}
632632

633-
634-
/// An example plugin function with macro support.
635-
/// `plugin_transform` macro interop pointers into deserialized structs, as well
636-
/// as returning ptr back to host.
637-
///
638-
/// It is possible to opt out from macro by writing transform fn manually via
639-
/// `__plugin_process_impl(
640-
/// ast_ptr: *const u8,
641-
/// ast_ptr_len: i32,
642-
/// config_str_ptr: *const u8,
643-
/// config_str_ptr_len: i32,
644-
/// context_str_ptr: *const u8,
645-
/// context_str_ptr_len: i32) ->
646-
/// i32 /* 0 for success, fail otherwise.
647-
/// Note this is only for internal pointer interop result,
648-
/// not actual transform result */
649-
///
650-
/// if plugin need to handle low-level ptr directly. However, there are
651-
/// important steps manually need to be performed like sending transformed
652-
/// results back to host. Refer swc_plugin_macro how does it work internally.
653633
#[plugin_transform]
654634
pub fn process_transform(program: Program, _metadata: TransformPluginProgramMetadata) -> Program {
655635
let tr = serde_json::from_str::<Vec<String>>(

packages/keep-platform/Cargo.toml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,21 @@ edition = "2021"
77
crate-type = ["cdylib", "rlib"]
88

99
[dependencies]
10-
serde = "1"
11-
fxhash= "0.2.1"
10+
serde = { workspace = true }
11+
fxhash= { workspace = true }
1212
lazy_static = "1.4.0"
13-
easy-error = "1.0.0"
14-
tracing = { version="0.1.34", features = ["release_max_level_info"] }
15-
swc_core = { version = "0.79.56", features = [
13+
tracing = { workspace = true, features = ["release_max_level_info"] }
14+
swc_core = { workspace = true, features = [
1615
"ecma_plugin_transform",
1716
"ecma_utils",
1817
"ecma_visit",
1918
"ecma_ast",
2019
"common",
2120
]}
22-
swc_common = { version = "0.31.18", features = ["concurrent"] }
23-
serde_json = {version = "1", features = ["unbounded_depth"]}
21+
swc_common = { workspace = true, features = ["concurrent"] }
22+
serde_json = { workspace = true, features = ["unbounded_depth"]}
23+
swc_plugin_macro = { workspace = true }
24+
swc_plugin_proxy = { workspace = true }
2425

2526
[dev-dependencies]
26-
testing = "0.33.21"
27+
testing = "1.0.0"

packages/keep-platform/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@ice/swc-plugin-keep-platform",
3-
"version": "0.2.0",
3+
"version": "0.3.0",
44
"license": "MIT",
55
"keywords": ["swc-plugin"],
66
"main": "swc_plugin_keep_platform.wasm",

packages/keep-platform/src/lib.rs

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
use lazy_static::lazy_static;
22
use serde::{Deserialize, Serialize};
33
use std::collections::HashMap;
4-
use swc_common::DUMMY_SP;
5-
use swc_core::{
6-
ecma::{
7-
ast::*,
8-
atoms::JsWord,
9-
visit::{Fold, FoldWith},
10-
},
11-
plugin::{plugin_transform, proxies::TransformPluginProgramMetadata},
4+
use swc_common::{SyntaxContext, DUMMY_SP};
5+
use swc_core::ecma::{
6+
ast::*,
7+
atoms::JsWord,
8+
visit::{Fold, FoldWith},
129
};
10+
use swc_plugin_proxy::TransformPluginProgramMetadata;
11+
use swc_plugin_macro::plugin_transform;
1312

1413
#[derive(Debug, Deserialize, Default, Clone)]
1514
pub struct KeepPlatformPatcher {
@@ -169,18 +168,18 @@ fn insert_decls_into_module_items(decls: Vec<VarDeclarator>, module_items: &mut
169168
span: DUMMY_SP,
170169
kind: VarDeclKind::Var,
171170
declare: false,
172-
decls: decls,
171+
decls,
172+
ctxt: SyntaxContext::empty()
173173
})))),
174174
)
175175
}
176176
}
177177

178178
// Create Ident by jsword.
179-
fn create_jsword_ident(value: &str) -> Ident {
180-
Ident {
179+
fn create_jsword_ident(value: &str) -> IdentName {
180+
IdentName {
181181
span: DUMMY_SP,
182-
sym: JsWord::from(value),
183-
optional: Default::default(),
182+
sym: JsWord::from(value)
184183
}
185184
}
186185

packages/node-transform/Cargo.toml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,20 @@ edition = "2021"
77
crate-type = ["cdylib", "rlib"]
88

99
[dependencies]
10-
serde = "1"
11-
fxhash= "0.2.1"
12-
easy-error = "1.0.0"
13-
tracing = { version="0.1.34", features = ["release_max_level_info"] }
14-
swc_core = { version = "0.79.56", features = [
10+
serde = { workspace = true }
11+
fxhash= { workspace = true }
12+
tracing = { workspace = true, features = ["release_max_level_info"] }
13+
swc_core = { workspace = true, features = [
1514
"ecma_plugin_transform",
1615
"ecma_utils",
1716
"ecma_visit",
1817
"ecma_ast",
1918
"common",
2019
]}
21-
swc_common = { version = "0.31.18", features = ["concurrent"] }
22-
serde_json = {version = "1", features = ["unbounded_depth"]}
20+
swc_common = { workspace = true, features = ["concurrent"] }
21+
serde_json = { workspace = true, features = ["unbounded_depth"]}
22+
swc_plugin_macro = { workspace = true }
23+
swc_plugin_proxy = { workspace = true }
2324

2425
[dev-dependencies]
25-
testing = "0.33.21"
26+
testing = { workspace = true }

packages/node-transform/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@ice/swc-plugin-node-transform",
3-
"version": "0.2.0",
3+
"version": "0.3.0",
44
"license": "MIT",
55
"keywords": ["swc-plugin"],
66
"main": "swc_plugin_node_transform.wasm",

0 commit comments

Comments
 (0)