rspack_core/plugin/
mod.rs1mod context;
2mod plugin_driver;
3
4use std::fmt;
5
6pub use context::*;
7pub use plugin_driver::*;
8use rspack_error::Result;
9
10use crate::compiler::CompilationId;
11
12pub trait Plugin: fmt::Debug + Send + Sync {
13 fn name(&self) -> &'static str {
14 "unknown"
15 }
16
17 fn apply(&self, _ctx: &mut ApplyContext) -> Result<()> {
18 Ok(())
19 }
20
21 fn clear_cache(&self, _id: CompilationId) {}
22}
23
24pub type BoxPlugin = Box<dyn Plugin>;
25
26pub trait PluginExt {
27 fn boxed(self) -> BoxPlugin;
28}
29
30impl<T: Plugin + 'static> PluginExt for T {
31 fn boxed(self) -> BoxPlugin {
32 Box::new(self)
33 }
34}