Skip to content

Commit

Permalink
feat: add native plugin example (#262)
Browse files Browse the repository at this point in the history
  • Loading branch information
hyf0 authored Nov 15, 2023
1 parent ad962af commit 246693f
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Cargo.lock

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

13 changes: 13 additions & 0 deletions crates/rolldown_plugin_hello/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[package]
name = "rolldown_plugin_hello"
version = "0.1.0"
edition.workspace = true
homepage.workspace = true
license.workspace = true
repository.workspace = true

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
rolldown = { path = "../rolldown" }
async-trait = { workspace = true }
19 changes: 19 additions & 0 deletions crates/rolldown_plugin_hello/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
use std::borrow::Cow;

use rolldown::{HookNoopReturn, Plugin, PluginContext};

#[derive(Debug)]
pub struct HelloPlugin;

#[async_trait::async_trait]
impl Plugin for HelloPlugin {
fn name(&self) -> Cow<'static, str> {
"hello".into()
}

#[allow(clippy::print_stdout)]
async fn build_start(&self, _ctx: &mut PluginContext) -> HookNoopReturn {
println!("hello");
Ok(())
}
}

0 comments on commit 246693f

Please sign in to comment.