-
-
Notifications
You must be signed in to change notification settings - Fork 550
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
13 changed files
with
128 additions
and
8 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
15 changes: 15 additions & 0 deletions
15
crates/rspack_binding_options/src/options/raw_builtins/raw_swc_dts_emit.rs
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,15 @@ | ||
use rspack_loader_swc::{SwcDtsEmitOptions}; | ||
use napi_derive::napi; | ||
|
||
#[napi(object, object_to_js = false)] | ||
pub struct RawSwcDtsEmitRspackPluginOptions { | ||
pub root_dir: Option<String>, | ||
} | ||
|
||
impl From<RawSwcDtsEmitRspackPluginOptions> for SwcDtsEmitOptions { | ||
fn from(value: RawSwcDtsEmitRspackPluginOptions) -> Self { | ||
Self { | ||
root_dir: value.root_dir.unwrap(), | ||
} | ||
} | ||
} |
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
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,9 +1,81 @@ | ||
use std::sync::Arc; | ||
|
||
use rspack_core::{ | ||
Compilation, CompilationFinishModules, CompilationParams, CompilerCompilation, Plugin, | ||
PluginContext, | ||
}; | ||
use rspack_error::Result; | ||
use rspack_hook::{plugin, plugin_hook}; | ||
|
||
#[derive(Debug)] | ||
pub struct SwcDtsEmitOptions { | ||
pub root_dir: String, | ||
} | ||
|
||
#[plugin] | ||
#[derive(Debug)] | ||
pub struct PluginCssExtract { | ||
pub(crate) options: Arc<CssExtractOptions>, | ||
pub struct PluginSwcDtsEmit { | ||
pub(crate) options: Arc<SwcDtsEmitOptions>, | ||
} | ||
|
||
impl Eq for PluginSwcDtsEmit {} | ||
|
||
impl PartialEq for PluginSwcDtsEmit { | ||
fn eq(&self, other: &Self) -> bool { | ||
Arc::ptr_eq(&self.options, &other.options) | ||
} | ||
} | ||
|
||
const PLUGIN_NAME: &str = "rspack.SwcDtsEmitPlugin"; | ||
|
||
impl PluginSwcDtsEmit { | ||
pub fn new(options: SwcDtsEmitOptions) -> Self { | ||
Self::new_inner(Arc::new(options)) | ||
} | ||
} | ||
|
||
#[plugin_hook(CompilationFinishModules for PluginSwcDtsEmit)] | ||
async fn finish_modules(&self, compilation: &mut Compilation) -> Result<()> { | ||
let module_graph = compilation.get_module_graph(); | ||
|
||
for (_, a) in module_graph.modules() { | ||
let meta = &a.build_info().expect("fuck").parse_meta; | ||
dbg!(meta); | ||
} | ||
Ok(()) | ||
} | ||
|
||
// #[plugin_hook(CompilerCompilation for PluginSwcDtsEmit)] | ||
// async fn compilation( | ||
// &self, | ||
// compilation: &mut Compilation, | ||
// params: &mut CompilationParams, | ||
// ) -> Result<()> { | ||
// Ok(()) | ||
// } | ||
|
||
impl Plugin for PluginSwcDtsEmit { | ||
fn name(&self) -> &'static str { | ||
PLUGIN_NAME | ||
} | ||
|
||
fn apply( | ||
&self, | ||
ctx: PluginContext<&mut rspack_core::ApplyContext>, | ||
_options: &rspack_core::CompilerOptions, | ||
) -> Result<()> { | ||
// ctx | ||
// .context | ||
// .compiler_hooks | ||
// .compilation | ||
// .tap(compilation::new(self)); | ||
|
||
ctx | ||
.context | ||
.compilation_hooks | ||
.finish_modules | ||
.tap(finish_modules::new(self)); | ||
|
||
Ok(()) | ||
} | ||
} |
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