Skip to content

Commit

Permalink
Impl
Browse files Browse the repository at this point in the history
  • Loading branch information
kdy1 committed Apr 11, 2024
1 parent 624d686 commit fc3d002
Show file tree
Hide file tree
Showing 6 changed files with 96 additions and 283 deletions.
80 changes: 40 additions & 40 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions packages/swc-debug-jsx/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
"name": "@swc/plugin-debug-jsx",
"version": "1.5.121",
"description": "SWC plugin for debugging jsx",
"main": "swc_plugin_swc_magic.wasm",
"main": "swc_plugin_debug_jsx.wasm",
"scripts": {
"prepack": "cp ../../target/wasm32-wasi/release/swc_plugin_swc_magic.wasm ."
"prepack": "cp ../../target/wasm32-wasi/release/swc_plugin_debug_jsx.wasm ."
},
"homepage": "https://swc.rs",
"repository": {
Expand Down
23 changes: 5 additions & 18 deletions packages/swc-debug-jsx/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,30 +1,17 @@
#![allow(clippy::not_unsafe_ptr_arg_deref)]
#![feature(box_patterns)]

use debug_jsx::swc_debug_jsx;
use swc_core::{
ecma::{ast::Program, visit::VisitMutWith},
plugin::{
plugin_transform,
proxies::{PluginCommentsProxy, TransformPluginProgramMetadata},
},
plugin::{plugin_transform, proxies::TransformPluginProgramMetadata},
};

#[plugin_transform]
fn swc_magic_plugin(mut program: Program, data: TransformPluginProgramMetadata) -> Program {
let config = serde_json::from_str::<swc_magic::Config>(
&data
.get_transform_plugin_config()
.expect("failed to get plugin config for swc-magic"),
)
.expect("invalid config for swc-magic");
fn swc_debug_jsx_plugin(mut program: Program, data: TransformPluginProgramMetadata) -> Program {
let cm = data.source_map;

let unresolved_mark = data.unresolved_mark;

program.visit_mut_with(&mut swc_magic::swc_magic(
unresolved_mark,
config,
PluginCommentsProxy,
));
program.visit_mut_with(&mut swc_debug_jsx(Box::new(cm)));

program
}
Loading

0 comments on commit fc3d002

Please sign in to comment.