-
-
Notifications
You must be signed in to change notification settings - Fork 769
refactor: use newtype for alias artifact #12754
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
crates/rspack_core/src/artifacts/async_modules_artifact.rs
This file contains hidden or 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,47 @@ | ||
| use std::ops::{Deref, DerefMut}; | ||
|
|
||
| use rspack_collections::IdentifierSet; | ||
|
|
||
| #[derive(Debug, Default, Clone)] | ||
| pub struct AsyncModulesArtifact(IdentifierSet); | ||
|
|
||
| impl Deref for AsyncModulesArtifact { | ||
| type Target = IdentifierSet; | ||
|
|
||
| fn deref(&self) -> &Self::Target { | ||
| &self.0 | ||
| } | ||
| } | ||
|
|
||
| impl DerefMut for AsyncModulesArtifact { | ||
| fn deref_mut(&mut self) -> &mut Self::Target { | ||
| &mut self.0 | ||
| } | ||
| } | ||
|
|
||
| impl From<IdentifierSet> for AsyncModulesArtifact { | ||
| fn from(value: IdentifierSet) -> Self { | ||
| Self(value) | ||
| } | ||
| } | ||
|
|
||
| impl From<AsyncModulesArtifact> for IdentifierSet { | ||
| fn from(value: AsyncModulesArtifact) -> Self { | ||
| value.0 | ||
| } | ||
| } | ||
|
|
||
| impl FromIterator<<IdentifierSet as IntoIterator>::Item> for AsyncModulesArtifact { | ||
| fn from_iter<T: IntoIterator<Item = <IdentifierSet as IntoIterator>::Item>>(iter: T) -> Self { | ||
| Self(IdentifierSet::from_iter(iter)) | ||
| } | ||
| } | ||
|
|
||
| impl IntoIterator for AsyncModulesArtifact { | ||
| type Item = <IdentifierSet as IntoIterator>::Item; | ||
| type IntoIter = <IdentifierSet as IntoIterator>::IntoIter; | ||
|
|
||
| fn into_iter(self) -> Self::IntoIter { | ||
| self.0.into_iter() | ||
| } | ||
| } | ||
55 changes: 55 additions & 0 deletions
55
crates/rspack_core/src/artifacts/cgc_runtime_requirements_artifact.rs
This file contains hidden or 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,55 @@ | ||
| use std::ops::{Deref, DerefMut}; | ||
|
|
||
| use rspack_collections::UkeyMap; | ||
|
|
||
| use crate::{ChunkUkey, RuntimeGlobals}; | ||
|
|
||
| #[derive(Debug, Default, Clone)] | ||
| pub struct CgcRuntimeRequirementsArtifact(UkeyMap<ChunkUkey, RuntimeGlobals>); | ||
|
|
||
| impl Deref for CgcRuntimeRequirementsArtifact { | ||
| type Target = UkeyMap<ChunkUkey, RuntimeGlobals>; | ||
|
|
||
| fn deref(&self) -> &Self::Target { | ||
| &self.0 | ||
| } | ||
| } | ||
|
|
||
| impl DerefMut for CgcRuntimeRequirementsArtifact { | ||
| fn deref_mut(&mut self) -> &mut Self::Target { | ||
| &mut self.0 | ||
| } | ||
| } | ||
|
|
||
| impl From<UkeyMap<ChunkUkey, RuntimeGlobals>> for CgcRuntimeRequirementsArtifact { | ||
| fn from(value: UkeyMap<ChunkUkey, RuntimeGlobals>) -> Self { | ||
| Self(value) | ||
| } | ||
| } | ||
|
|
||
| impl From<CgcRuntimeRequirementsArtifact> for UkeyMap<ChunkUkey, RuntimeGlobals> { | ||
| fn from(value: CgcRuntimeRequirementsArtifact) -> Self { | ||
| value.0 | ||
| } | ||
| } | ||
|
|
||
| impl FromIterator<<UkeyMap<ChunkUkey, RuntimeGlobals> as IntoIterator>::Item> | ||
| for CgcRuntimeRequirementsArtifact | ||
| { | ||
| fn from_iter< | ||
| T: IntoIterator<Item = <UkeyMap<ChunkUkey, RuntimeGlobals> as IntoIterator>::Item>, | ||
| >( | ||
| iter: T, | ||
| ) -> Self { | ||
| Self(UkeyMap::from_iter(iter)) | ||
| } | ||
| } | ||
|
|
||
| impl IntoIterator for CgcRuntimeRequirementsArtifact { | ||
| type Item = <UkeyMap<ChunkUkey, RuntimeGlobals> as IntoIterator>::Item; | ||
| type IntoIter = <UkeyMap<ChunkUkey, RuntimeGlobals> as IntoIterator>::IntoIter; | ||
|
|
||
| fn into_iter(self) -> Self::IntoIter { | ||
| self.0.into_iter() | ||
| } | ||
| } |
This file contains hidden or 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,55 @@ | ||
| use std::ops::{Deref, DerefMut}; | ||
|
|
||
| use rspack_collections::UkeyMap; | ||
|
|
||
| use crate::{ChunkRenderResult, ChunkUkey}; | ||
|
|
||
| #[derive(Debug, Default, Clone)] | ||
| pub struct ChunkRenderArtifact(UkeyMap<ChunkUkey, ChunkRenderResult>); | ||
|
|
||
| impl Deref for ChunkRenderArtifact { | ||
| type Target = UkeyMap<ChunkUkey, ChunkRenderResult>; | ||
|
|
||
| fn deref(&self) -> &Self::Target { | ||
| &self.0 | ||
| } | ||
| } | ||
|
|
||
| impl DerefMut for ChunkRenderArtifact { | ||
| fn deref_mut(&mut self) -> &mut Self::Target { | ||
| &mut self.0 | ||
| } | ||
| } | ||
|
|
||
| impl From<UkeyMap<ChunkUkey, ChunkRenderResult>> for ChunkRenderArtifact { | ||
| fn from(value: UkeyMap<ChunkUkey, ChunkRenderResult>) -> Self { | ||
| Self(value) | ||
| } | ||
| } | ||
|
|
||
| impl From<ChunkRenderArtifact> for UkeyMap<ChunkUkey, ChunkRenderResult> { | ||
| fn from(value: ChunkRenderArtifact) -> Self { | ||
| value.0 | ||
| } | ||
| } | ||
|
|
||
| impl FromIterator<<UkeyMap<ChunkUkey, ChunkRenderResult> as IntoIterator>::Item> | ||
| for ChunkRenderArtifact | ||
| { | ||
| fn from_iter< | ||
| T: IntoIterator<Item = <UkeyMap<ChunkUkey, ChunkRenderResult> as IntoIterator>::Item>, | ||
| >( | ||
| iter: T, | ||
| ) -> Self { | ||
| Self(UkeyMap::from_iter(iter)) | ||
| } | ||
| } | ||
|
|
||
| impl IntoIterator for ChunkRenderArtifact { | ||
| type Item = <UkeyMap<ChunkUkey, ChunkRenderResult> as IntoIterator>::Item; | ||
| type IntoIter = <UkeyMap<ChunkUkey, ChunkRenderResult> as IntoIterator>::IntoIter; | ||
|
|
||
| fn into_iter(self) -> Self::IntoIter { | ||
| self.0.into_iter() | ||
| } | ||
| } | ||
hardfist marked this conversation as resolved.
Show resolved
Hide resolved
|
||
58 changes: 58 additions & 0 deletions
58
crates/rspack_core/src/artifacts/dependencies_diagnostics_artifact.rs
This file contains hidden or 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,58 @@ | ||
| use std::ops::{Deref, DerefMut}; | ||
|
|
||
| use rspack_collections::IdentifierMap; | ||
| use rspack_error::Diagnostic; | ||
|
|
||
| #[derive(Debug, Default, Clone)] | ||
| pub struct DependenciesDiagnosticsArtifact(IdentifierMap<Vec<Diagnostic>>); | ||
|
|
||
| impl DependenciesDiagnosticsArtifact { | ||
| pub fn into_values(self) -> impl Iterator<Item = Vec<Diagnostic>> { | ||
| self.0.into_values() | ||
| } | ||
| } | ||
|
|
||
| impl Deref for DependenciesDiagnosticsArtifact { | ||
| type Target = IdentifierMap<Vec<Diagnostic>>; | ||
|
|
||
| fn deref(&self) -> &Self::Target { | ||
| &self.0 | ||
| } | ||
| } | ||
|
|
||
| impl DerefMut for DependenciesDiagnosticsArtifact { | ||
| fn deref_mut(&mut self) -> &mut Self::Target { | ||
| &mut self.0 | ||
| } | ||
| } | ||
|
|
||
| impl From<IdentifierMap<Vec<Diagnostic>>> for DependenciesDiagnosticsArtifact { | ||
| fn from(value: IdentifierMap<Vec<Diagnostic>>) -> Self { | ||
| Self(value) | ||
| } | ||
| } | ||
|
|
||
| impl From<DependenciesDiagnosticsArtifact> for IdentifierMap<Vec<Diagnostic>> { | ||
| fn from(value: DependenciesDiagnosticsArtifact) -> Self { | ||
| value.0 | ||
| } | ||
| } | ||
|
|
||
| impl FromIterator<<IdentifierMap<Vec<Diagnostic>> as IntoIterator>::Item> | ||
| for DependenciesDiagnosticsArtifact | ||
| { | ||
| fn from_iter<T: IntoIterator<Item = <IdentifierMap<Vec<Diagnostic>> as IntoIterator>::Item>>( | ||
| iter: T, | ||
| ) -> Self { | ||
| Self(IdentifierMap::from_iter(iter)) | ||
| } | ||
| } | ||
|
|
||
| impl IntoIterator for DependenciesDiagnosticsArtifact { | ||
| type Item = <IdentifierMap<Vec<Diagnostic>> as IntoIterator>::Item; | ||
| type IntoIter = <IdentifierMap<Vec<Diagnostic>> as IntoIterator>::IntoIter; | ||
|
|
||
| fn into_iter(self) -> Self::IntoIter { | ||
| self.0.into_iter() | ||
| } | ||
| } |
47 changes: 47 additions & 0 deletions
47
crates/rspack_core/src/artifacts/imported_by_defer_modules_artifact.rs
This file contains hidden or 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,47 @@ | ||
| use std::ops::{Deref, DerefMut}; | ||
|
|
||
| use rspack_collections::IdentifierSet; | ||
|
|
||
| #[derive(Debug, Default, Clone)] | ||
| pub struct ImportedByDeferModulesArtifact(IdentifierSet); | ||
|
|
||
| impl Deref for ImportedByDeferModulesArtifact { | ||
| type Target = IdentifierSet; | ||
|
|
||
| fn deref(&self) -> &Self::Target { | ||
| &self.0 | ||
| } | ||
| } | ||
|
|
||
| impl DerefMut for ImportedByDeferModulesArtifact { | ||
| fn deref_mut(&mut self) -> &mut Self::Target { | ||
| &mut self.0 | ||
| } | ||
| } | ||
|
|
||
| impl From<IdentifierSet> for ImportedByDeferModulesArtifact { | ||
| fn from(value: IdentifierSet) -> Self { | ||
| Self(value) | ||
| } | ||
| } | ||
|
|
||
| impl From<ImportedByDeferModulesArtifact> for IdentifierSet { | ||
| fn from(value: ImportedByDeferModulesArtifact) -> Self { | ||
| value.0 | ||
| } | ||
| } | ||
|
|
||
| impl FromIterator<<IdentifierSet as IntoIterator>::Item> for ImportedByDeferModulesArtifact { | ||
| fn from_iter<T: IntoIterator<Item = <IdentifierSet as IntoIterator>::Item>>(iter: T) -> Self { | ||
| Self(IdentifierSet::from_iter(iter)) | ||
| } | ||
| } | ||
|
|
||
| impl IntoIterator for ImportedByDeferModulesArtifact { | ||
| type Item = <IdentifierSet as IntoIterator>::Item; | ||
| type IntoIter = <IdentifierSet as IntoIterator>::IntoIter; | ||
|
|
||
| fn into_iter(self) -> Self::IntoIter { | ||
| self.0.into_iter() | ||
| } | ||
| } |
This file contains hidden or 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,31 +1,31 @@ | ||
| use rspack_collections::{IdentifierMap, IdentifierSet, UkeyMap}; | ||
| use rspack_error::Diagnostic; | ||
|
|
||
| use crate::{ChunkRenderResult, ChunkUkey, ModuleId, RuntimeGlobals}; | ||
|
|
||
| mod async_modules_artifact; | ||
| mod cgc_runtime_requirements_artifact; | ||
| mod cgm_hash_artifact; | ||
| mod cgm_runtime_requirement_artifact; | ||
| mod chunk_hashes_artifact; | ||
| mod chunk_ids_artifact; | ||
| mod chunk_render_artifact; | ||
| mod chunk_render_cache_artifact; | ||
| mod code_generation_results; | ||
| mod dependencies_diagnostics_artifact; | ||
| mod imported_by_defer_modules_artifact; | ||
| mod module_graph_cache_artifact; | ||
| mod module_ids_artifact; | ||
| mod module_static_cache_artifact; | ||
| mod side_effects_do_optimize_artifact; | ||
|
|
||
| pub use async_modules_artifact::AsyncModulesArtifact; | ||
| pub use cgc_runtime_requirements_artifact::CgcRuntimeRequirementsArtifact; | ||
| pub use cgm_hash_artifact::*; | ||
| pub use cgm_runtime_requirement_artifact::*; | ||
| pub use chunk_hashes_artifact::*; | ||
| pub use chunk_ids_artifact::*; | ||
| pub use chunk_render_artifact::ChunkRenderArtifact; | ||
| pub use chunk_render_cache_artifact::ChunkRenderCacheArtifact; | ||
| pub use code_generation_results::*; | ||
| pub use dependencies_diagnostics_artifact::DependenciesDiagnosticsArtifact; | ||
| pub use imported_by_defer_modules_artifact::ImportedByDeferModulesArtifact; | ||
| pub use module_graph_cache_artifact::*; | ||
| pub use module_ids_artifact::ModuleIdsArtifact; | ||
| pub use module_static_cache_artifact::*; | ||
| pub use side_effects_do_optimize_artifact::*; | ||
|
|
||
| pub type AsyncModulesArtifact = IdentifierSet; | ||
| pub type ImportedByDeferModulesArtifact = IdentifierSet; | ||
| pub type DependenciesDiagnosticsArtifact = IdentifierMap<Vec<Diagnostic>>; | ||
| pub type ModuleIdsArtifact = IdentifierMap<ModuleId>; | ||
| pub type CgcRuntimeRequirementsArtifact = UkeyMap<ChunkUkey, RuntimeGlobals>; | ||
| pub type ChunkRenderArtifact = UkeyMap<ChunkUkey, ChunkRenderResult>; |
This file contains hidden or 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,51 @@ | ||
| use std::ops::{Deref, DerefMut}; | ||
|
|
||
| use rspack_collections::IdentifierMap; | ||
|
|
||
| use crate::ModuleId; | ||
|
|
||
| #[derive(Debug, Default, Clone)] | ||
| pub struct ModuleIdsArtifact(IdentifierMap<ModuleId>); | ||
|
|
||
| impl Deref for ModuleIdsArtifact { | ||
| type Target = IdentifierMap<ModuleId>; | ||
|
|
||
| fn deref(&self) -> &Self::Target { | ||
| &self.0 | ||
| } | ||
| } | ||
|
|
||
| impl DerefMut for ModuleIdsArtifact { | ||
| fn deref_mut(&mut self) -> &mut Self::Target { | ||
| &mut self.0 | ||
| } | ||
| } | ||
|
|
||
| impl From<IdentifierMap<ModuleId>> for ModuleIdsArtifact { | ||
| fn from(value: IdentifierMap<ModuleId>) -> Self { | ||
| Self(value) | ||
| } | ||
| } | ||
|
|
||
| impl From<ModuleIdsArtifact> for IdentifierMap<ModuleId> { | ||
| fn from(value: ModuleIdsArtifact) -> Self { | ||
| value.0 | ||
| } | ||
| } | ||
|
|
||
| impl FromIterator<<IdentifierMap<ModuleId> as IntoIterator>::Item> for ModuleIdsArtifact { | ||
| fn from_iter<T: IntoIterator<Item = <IdentifierMap<ModuleId> as IntoIterator>::Item>>( | ||
| iter: T, | ||
| ) -> Self { | ||
| Self(IdentifierMap::from_iter(iter)) | ||
| } | ||
| } | ||
|
|
||
| impl IntoIterator for ModuleIdsArtifact { | ||
| type Item = <IdentifierMap<ModuleId> as IntoIterator>::Item; | ||
| type IntoIter = <IdentifierMap<ModuleId> as IntoIterator>::IntoIter; | ||
|
|
||
| fn into_iter(self) -> Self::IntoIter { | ||
| self.0.into_iter() | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.