Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 15393c3

Browse files
committed
update swc imports plugin dependencies
1 parent 193260f commit 15393c3

File tree

7 files changed

+64
-61
lines changed

7 files changed

+64
-61
lines changed

packages/swc-plugin-transform-cx-imports/.cargo/config

Lines changed: 0 additions & 4 deletions
This file was deleted.

packages/swc-plugin-transform-cx-imports/.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,6 @@ Cargo.lock
1111
**/*.rs.bk
1212

1313
# MSVC Windows builds of rustc generate these, which store debugging information
14-
*.pdb
14+
*.pdb
15+
16+
pkg/swc_plugin_transform_cx_imports*

packages/swc-plugin-transform-cx-imports/Cargo.toml

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,34 +9,21 @@ description = "Rewrite Cx imports for simplicity and optimal output size."
99
crate-type = ["cdylib", "rlib"]
1010

1111
[profile.release]
12-
# This removes more dead code
1312
codegen-units = 1
1413
lto = true
15-
# Optimize for size
16-
# Optimize for performance, this is default so you don't need to specify it
17-
# opt-level = "z"
18-
19-
# Strip debug symbols
2014
strip = "symbols"
2115

2216
[dependencies]
2317
lazy_static = "1.4.0"
2418
regex = "1.10.3"
25-
serde = { version = "1.0.130", features = ["derive"] }
26-
swc_common = { version = "0.33.17", features = ["concurrent"] }
27-
swc_core = { version = "0.90.6", features = ["ecma_plugin_transform"] }
28-
swc_ecma_ast = "0.112.2"
29-
swc_ecma_utils = "0.127.3"
30-
swc_ecma_visit = "0.98.2"
31-
serde_json = "1"
32-
swc_ecma_parser = "0.143.3"
19+
swc_common = { version = "14.0.4", features = ["concurrent"] }
20+
swc_core = { version = "42.1.0", features = ["ecma_plugin_transform"] }
21+
swc_ecma_ast = "15.0.0"
22+
swc_ecma_utils = "21.0.0"
23+
swc_ecma_visit = "15.0.0"
24+
serde_json = "1.0.145"
25+
swc_ecma_parser = "24.0.1"
3326
wasm-bindgen = "0.2"
3427

3528
[dev-dependencies]
36-
testing = "0.35.18"
37-
38-
39-
40-
# .cargo/config defines few alias to build plugin.
41-
# cargo build-wasi generates wasm-wasi32 binary
42-
# cargo build-wasm32 generates wasm32-unknown-unknown binary.
29+
testing = "15.0.0"

packages/swc-plugin-transform-cx-imports/package.json

Lines changed: 0 additions & 21 deletions
This file was deleted.
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"name": "swc-plugin-transform-cx-imports",
3+
"version": "24.9.0",
4+
"description": "Rewrite Cx imports for simplicity and optimal output size.",
5+
"repository": {
6+
"type": "git",
7+
"url": "git+https://github.com/codaxy/cxjs.git"
8+
},
9+
"author": "Codaxy",
10+
"license": "SEE LICENSE IN LICENSE.md",
11+
"main": "swc_plugin_transform_cx_imports.js",
12+
"homepage": "https://cxjs.io",
13+
"scripts": {
14+
"test": "cargo test",
15+
"build": "cargo build --release --target wasm32-wasip1",
16+
"prepublishOnly": "cargo build-wasi --release"
17+
},
18+
"files": [
19+
"swc_plugin_transform_cx_imports_bg.wasm",
20+
"swc_plugin_transform_cx_imports.js",
21+
"swc_plugin_transform_cx_imports_bg.js",
22+
"swc_plugin_transform_cx_imports.d.ts"
23+
],
24+
"module": "swc_plugin_transform_cx_imports.js",
25+
"types": "swc_plugin_transform_cx_imports.d.ts",
26+
"keywords": [
27+
"swc-plugin",
28+
"swc",
29+
"es2015",
30+
"es2016",
31+
"cx",
32+
"jsx"
33+
],
34+
"bugs": {
35+
"url": "https://github.com/codaxy/cxjs/issues"
36+
}
37+
}
656 KB
Binary file not shown.

packages/swc-plugin-transform-cx-imports/src/lib.rs

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use swc_ecma_ast::{
99
ImportDecl, ImportPhase, ImportSpecifier, ModuleDecl, ModuleExportName, ModuleItem, Program,
1010
Str,
1111
};
12-
use swc_ecma_visit::{as_folder, FoldWith, VisitMut, VisitMutWith};
12+
use swc_ecma_visit::{visit_mut_pass, VisitMut, VisitMutWith};
1313

1414
lazy_static! {
1515
static ref QUOTES_REGEX: Regex = Regex::new(r#""|'"#).unwrap();
@@ -194,9 +194,12 @@ impl VisitMut for TransformVisitor {
194194
}
195195

196196
#[plugin_transform]
197-
pub fn process_transform(program: Program, _metadata: TransformPluginProgramMetadata) -> Program {
197+
pub fn process_transform(
198+
mut program: Program,
199+
metadata: TransformPluginProgramMetadata,
200+
) -> Program {
198201
let manifest: HashMap<String, HashMap<String, String>>;
199-
let config_string_opt = _metadata.get_transform_plugin_config();
202+
let config_string_opt = metadata.get_transform_plugin_config();
200203

201204
if config_string_opt.is_none() {
202205
panic!("Unable to deserialize the config.")
@@ -240,13 +243,15 @@ pub fn process_transform(program: Program, _metadata: TransformPluginProgramMeta
240243
Err(err) => panic!("Could not read manifest. {}", err),
241244
}
242245

243-
program.fold_with(&mut as_folder(TransformVisitor {
246+
program.visit_mut_with(&mut visit_mut_pass(TransformVisitor {
244247
imports: HashSet::new(),
245248
scss_imports: HashSet::new(),
246249
manifest,
247250
use_src,
248251
sass,
249-
}))
252+
}));
253+
254+
program
250255
}
251256

252257
#[cfg(test)]
@@ -262,24 +267,21 @@ fn exec(input: std::path::PathBuf) {
262267
serde_json::from_str(value.as_str()).unwrap();
263268

264269
swc_core::ecma::transforms::testing::test_fixture(
265-
swc_ecma_parser::Syntax::Typescript(swc_ecma_parser::TsConfig {
266-
tsx: true,
267-
..Default::default()
268-
}),
270+
swc_ecma_parser::Syntax::Typescript(Default::default()),
269271
&|_| {
270-
swc_common::chain!(
272+
(
271273
swc_core::ecma::transforms::base::resolver(
272274
Default::default(),
273275
Default::default(),
274-
true
276+
true,
275277
),
276-
as_folder(TransformVisitor {
278+
visit_mut_pass(TransformVisitor {
277279
imports: HashSet::new(),
278280
scss_imports: HashSet::new(),
279281
manifest: manifest.to_owned(),
280282
use_src: true,
281-
sass: false
282-
})
283+
sass: false,
284+
}),
283285
)
284286
},
285287
&input,

0 commit comments

Comments
 (0)