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

Skip to content

Commit 246693f

Browse files
authored
feat: add native plugin example (#262)
1 parent ad962af commit 246693f

3 files changed

Lines changed: 40 additions & 0 deletions

File tree

Cargo.lock

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[package]
2+
name = "rolldown_plugin_hello"
3+
version = "0.1.0"
4+
edition.workspace = true
5+
homepage.workspace = true
6+
license.workspace = true
7+
repository.workspace = true
8+
9+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
10+
11+
[dependencies]
12+
rolldown = { path = "../rolldown" }
13+
async-trait = { workspace = true }
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
use std::borrow::Cow;
2+
3+
use rolldown::{HookNoopReturn, Plugin, PluginContext};
4+
5+
#[derive(Debug)]
6+
pub struct HelloPlugin;
7+
8+
#[async_trait::async_trait]
9+
impl Plugin for HelloPlugin {
10+
fn name(&self) -> Cow<'static, str> {
11+
"hello".into()
12+
}
13+
14+
#[allow(clippy::print_stdout)]
15+
async fn build_start(&self, _ctx: &mut PluginContext) -> HookNoopReturn {
16+
println!("hello");
17+
Ok(())
18+
}
19+
}

0 commit comments

Comments
 (0)