-
-
Notifications
You must be signed in to change notification settings - Fork 622
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(plugin-asset): support
generator['asset'].importMode
for Rslib (…
…#8724) * chore: update * test: update snapshot * test: update snapshot * chore: update comment
- Loading branch information
Showing
28 changed files
with
616 additions
and
143 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
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
65 changes: 65 additions & 0 deletions
65
crates/rspack_plugin_asset/src/asset_exports_dependency.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,65 @@ | ||
use rspack_cacheable::{cacheable, cacheable_dyn}; | ||
use rspack_core::{ | ||
AsContextDependency, AsModuleDependency, Compilation, Dependency, DependencyId, | ||
DependencyTemplate, ExportNameOrSpec, ExportsOfExportsSpec, ExportsSpec, ModuleGraph, | ||
RuntimeSpec, TemplateContext, TemplateReplaceSource, | ||
}; | ||
|
||
#[cacheable] | ||
#[derive(Debug, Clone, Default)] | ||
pub struct AssetExportsDependency { | ||
id: DependencyId, | ||
} | ||
|
||
impl AssetExportsDependency { | ||
pub fn new() -> Self { | ||
Self { | ||
id: DependencyId::new(), | ||
} | ||
} | ||
} | ||
|
||
#[cacheable_dyn] | ||
impl Dependency for AssetExportsDependency { | ||
fn id(&self) -> &rspack_core::DependencyId { | ||
&self.id | ||
} | ||
|
||
fn get_exports(&self, _mg: &ModuleGraph) -> Option<ExportsSpec> { | ||
Some(ExportsSpec { | ||
exports: ExportsOfExportsSpec::Array(vec![ExportNameOrSpec::String("default".into())]), | ||
priority: Some(1), | ||
terminal_binding: Some(true), | ||
..Default::default() | ||
}) | ||
} | ||
|
||
fn could_affect_referencing_module(&self) -> rspack_core::AffectType { | ||
rspack_core::AffectType::False | ||
} | ||
} | ||
|
||
impl AsModuleDependency for AssetExportsDependency {} | ||
impl AsContextDependency for AssetExportsDependency {} | ||
|
||
#[cacheable_dyn] | ||
impl DependencyTemplate for AssetExportsDependency { | ||
fn apply( | ||
&self, | ||
_source: &mut TemplateReplaceSource, | ||
_code_generatable_context: &mut TemplateContext, | ||
) { | ||
} | ||
|
||
fn dependency_id(&self) -> Option<DependencyId> { | ||
Some(self.id) | ||
} | ||
|
||
fn update_hash( | ||
&self, | ||
_hasher: &mut dyn std::hash::Hasher, | ||
_compilation: &Compilation, | ||
_runtime: Option<&RuntimeSpec>, | ||
) { | ||
} | ||
} |
Oops, something went wrong.
33654c7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📝 Benchmark detail: Open
33654c7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📝 Ecosystem CI detail: Open