Skip to content

Commit

Permalink
feat: update
Browse files Browse the repository at this point in the history
  • Loading branch information
Allen Zhang (张涛) committed Oct 18, 2024
1 parent 2f3cdcc commit ef1788c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion plugins/swc-plugin-canyon/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "swc-plugin-canyon",
"version": "0.0.2-alpha.1",
"version": "0.0.2-alpha.2",
"description": "Canyon SWC plugin, for debugging",
"main": "swc_plugin_canyon.wasm",
"scripts": {
Expand Down
8 changes: 7 additions & 1 deletion plugins/swc-plugin-canyon/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ use swc_plugin_macro::plugin_transform;

#[plugin_transform]
fn plugin(program: Program, metadata: TransformPluginProgramMetadata) -> Program {
println!("打印");
// 需要提供 `TransformPluginMetadataContextKind` 参数给 `get_context` 方法
if let Some(context) = metadata.get_context(&swc_core::plugin::metadata::TransformPluginMetadataContextKind::Filename) {
// 处理返回的 `Option<String>`
println!("当前文件的路径: {}", context);
} else {
println!("无法获取文件路径");
}
program
}

0 comments on commit ef1788c

Please sign in to comment.