Skip to content

Commit

Permalink
feat: update swc_core to 4.0.0 (#246)
Browse files Browse the repository at this point in the history
  • Loading branch information
SevereCloud authored Nov 5, 2024
1 parent 4976c1f commit d9a164d
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 51 deletions.
81 changes: 40 additions & 41 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ md4 = { version = "0.10", default-features = false }
md-5 = { version = "0.10", default-features = false }
sha1 = { version = "0.10", default-features = false }
sha2 = { version = "0.10", default-features = false }
twox-hash = "1"
twox-hash = "2"

# digest
base16ct = { version = "0.2", features = ["alloc"] }
Expand All @@ -32,15 +32,15 @@ serde_json = "1"
serde-inline-default = "0.2.0"
regex = "1"
lazy_static = "1"
swc_core = { version = "1", features = [
swc_core = { version = "4", features = [
"ecma_plugin_transform",
"ecma_parser",
] }

ts-rs = "10"

[dev-dependencies]
testing = "1"
testing = "3"
# .cargo/config defines few alias to build plugin.
# cargo build-wasip1 generates wasm-wasi32 binary
# cargo build-wasm32 generates wasm32-unknown-unknown binary.
7 changes: 2 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@ pub mod loader_utils;

pub use config::Config;
pub use injector::Injector;
use swc_core::ecma::{
ast::Program,
visit::{as_folder, FoldWith},
};
use swc_core::ecma::{ast::Program, visit::visit_mut_pass};
use swc_core::plugin::metadata::TransformPluginMetadataContextKind;
use swc_core::plugin::{plugin_transform, proxies::TransformPluginProgramMetadata};

Expand All @@ -29,7 +26,7 @@ pub fn process_transform(program: Program, metadata: TransformPluginProgramMetad
.get_context(&TransformPluginMetadataContextKind::Cwd)
.expect("failed to get cwd");

program.fold_with(&mut as_folder(Injector::new(
program.apply(visit_mut_pass(Injector::new(
cwd.as_str(),
filepath.as_str(),
config,
Expand Down
4 changes: 2 additions & 2 deletions tests/fixture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::{env, fs, path::PathBuf};
use swc_core::ecma::{
parser::{EsSyntax, Syntax},
transforms::testing::test_fixture,
visit::as_folder,
visit::visit_mut_pass,
};
use swc_plugin_css_modules::{Config, Injector};

Expand All @@ -28,7 +28,7 @@ fn fixture(input: PathBuf) {
test_fixture(
syntax(),
&|_| {
as_folder(Injector::new(
visit_mut_pass(Injector::new(
cwd.to_str().unwrap(),
input.to_str().unwrap(),
config.clone(),
Expand Down

0 comments on commit d9a164d

Please sign in to comment.