Skip to content

Commit f3d97fc

Browse files
committed
feat: support PluginOrder::PinPost
1 parent 26d804e commit f3d97fc

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

crates/rolldown_plugin/src/plugin_driver/hook_orders.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ impl PluginHookOrders {
118118
) -> Vec<PluginIdx> {
119119
let mut pre_plugins = Vec::new();
120120
let mut post_plugins = Vec::new();
121+
let mut pin_post_plugins = Vec::new();
121122
let mut normal_plugins = Vec::with_capacity(index_plugins.len());
122123
for (idx, plugin) in index_plugins.iter_enumerated() {
123124
let Some(meta) = get_hook_meta(idx, plugin) else { continue };
@@ -126,10 +127,13 @@ impl PluginHookOrders {
126127
Some(meta) => match meta.order {
127128
Some(PluginOrder::Pre) => pre_plugins.push(idx),
128129
Some(PluginOrder::Post) => post_plugins.push(idx),
130+
Some(PluginOrder::PinPost) => pin_post_plugins.push(idx),
129131
None => normal_plugins.push(idx),
130132
},
131133
}
132134
}
133-
[pre_plugins, normal_plugins, post_plugins].concat()
135+
// Reverse so first-seen plugin runs last (pinned to the very end)
136+
pin_post_plugins.reverse();
137+
[pre_plugins, normal_plugins, post_plugins, pin_post_plugins].concat()
134138
}
135139
}

crates/rolldown_plugin/src/types/plugin_hook_meta.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
pub enum PluginOrder {
33
Pre,
44
Post,
5+
/// Runs after all `Post` hooks. Unlike `Post`, earlier plugins run later —
6+
/// so a plugin registered first is guaranteed to run last.
7+
PinPost,
58
}
69

710
#[derive(Debug)]

0 commit comments

Comments
 (0)