-
Notifications
You must be signed in to change notification settings - Fork 548
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
100 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
pub mod bundle; | ||
#[allow(clippy::module_inception)] | ||
pub mod bundler; | ||
mod chunk; | ||
mod chunk_graph; | ||
mod graph; | ||
mod module; | ||
mod module_loader; | ||
pub mod options; | ||
pub mod plugin_driver; | ||
mod renderer; | ||
mod runtime; | ||
pub mod utils; | ||
mod visitors; | ||
|
||
#[allow(clippy::module_inception)] | ||
pub mod bundler; | ||
mod chunk; | ||
mod module_loader; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
use std::sync::Arc; | ||
|
||
use crate::{ | ||
plugin::plugin::BoxPlugin, HookLoadArgs, HookLoadReturn, HookResolveIdArgs, HookResolveIdReturn, | ||
HookTransformArgs, HookTransformReturn, PluginContext, | ||
}; | ||
|
||
pub type SharedPluginDriver = Arc<PluginDriver>; | ||
|
||
pub struct PluginDriver { | ||
_plugins: Vec<BoxPlugin>, | ||
} | ||
|
||
impl PluginDriver { | ||
pub fn new(plugins: Vec<BoxPlugin>) -> Self { | ||
Self { _plugins: plugins } | ||
} | ||
|
||
pub async fn _resolve_id(&self, args: &HookResolveIdArgs<'_>) -> HookResolveIdReturn { | ||
for plugin in &self._plugins { | ||
match plugin.resolve_id(&mut PluginContext::new(), args).await { | ||
Err(e) => return Err(e), | ||
Ok(r) => { | ||
if let Some(r) = r { | ||
return Ok(Some(r)); | ||
} | ||
} | ||
} | ||
} | ||
Ok(None) | ||
} | ||
|
||
pub async fn _load(&self, args: &HookLoadArgs<'_>) -> HookLoadReturn { | ||
for plugin in &self._plugins { | ||
match plugin.load(&mut PluginContext::new(), args).await { | ||
Err(e) => return Err(e), | ||
Ok(r) => { | ||
if let Some(r) = r { | ||
return Ok(Some(r)); | ||
} | ||
} | ||
} | ||
} | ||
Ok(None) | ||
} | ||
|
||
pub async fn _transform(&self, args: &HookTransformArgs<'_>) -> HookTransformReturn { | ||
for plugin in &self._plugins { | ||
match plugin.transform(&mut PluginContext::new(), args).await { | ||
Err(e) => return Err(e), | ||
Ok(r) => { | ||
if let Some(r) = r { | ||
return Ok(Some(r)); | ||
} | ||
} | ||
} | ||
} | ||
Ok(None) | ||
} | ||
} |