Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 55 additions & 31 deletions crates/rspack_core/src/artifacts/module_graph_cache_artifact.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,44 +157,68 @@ pub struct NormalReexportItem {
pub export_info: ExportInfo,
}

#[derive(Debug, PartialEq, Eq, Clone, Copy)]
pub enum ExportModeType {
#[derive(Debug, Clone)]
pub enum ExportMode {
Missing,
Unused,
EmptyStar,
ReexportDynamicDefault,
ReexportNamedDefault,
ReexportNamespaceObject,
ReexportFakeNamespaceObject,
ReexportUndefined,
NormalReexport,
DynamicReexport,
Unused(ExportModeUnused),
EmptyStar(ExportModeEmptyStar),
ReexportDynamicDefault(ExportModeReexportDynamicDefault),
ReexportNamedDefault(ExportModeReexportNamedDefault),
ReexportNamespaceObject(ExportModeReexportNamespaceObject),
ReexportFakeNamespaceObject(ExportModeFakeNamespaceObject),
ReexportUndefined(ExportModeReexportUndefined),
NormalReexport(ExportModeNormalReexport),
DynamicReexport(Box<ExportModeDynamicReexport>),
}

#[derive(Debug, Clone)]
pub struct ExportMode {
/// corresponding to `type` field in webpack's `EpxortMode`
pub ty: ExportModeType,
pub items: Option<Vec<NormalReexportItem>>,
pub name: Option<Atom>,
pub fake_type: u8,
pub partial_namespace_export_info: Option<ExportInfo>,
pub ignored: Option<HashSet<Atom>>,
pub struct ExportModeUnused {
pub name: Atom,
}

#[derive(Debug, Clone)]
pub struct ExportModeEmptyStar {
pub hidden: Option<HashSet<Atom>>,
}

impl ExportMode {
pub fn new(ty: ExportModeType) -> Self {
Self {
ty,
items: None,
name: None,
fake_type: 0,
partial_namespace_export_info: None,
ignored: None,
hidden: None,
}
}
#[derive(Debug, Clone)]
pub struct ExportModeReexportDynamicDefault {
pub name: Atom,
}

#[derive(Debug, Clone)]
pub struct ExportModeReexportNamedDefault {
pub name: Atom,
pub partial_namespace_export_info: ExportInfo,
}

#[derive(Debug, Clone)]
pub struct ExportModeReexportNamespaceObject {
pub name: Atom,
pub partial_namespace_export_info: ExportInfo,
}

#[derive(Debug, Clone)]
pub struct ExportModeFakeNamespaceObject {
pub name: Atom,
pub fake_type: u8,
pub partial_namespace_export_info: ExportInfo,
}

#[derive(Debug, Clone)]
pub struct ExportModeReexportUndefined {
pub name: Atom,
}

#[derive(Debug, Clone)]
pub struct ExportModeNormalReexport {
pub items: Vec<NormalReexportItem>,
}

#[derive(Debug, Clone)]
pub struct ExportModeDynamicReexport {
pub ignored: HashSet<Atom>,
pub hidden: Option<HashSet<Atom>>,
}

#[derive(Debug, Default)]
Expand Down
6 changes: 3 additions & 3 deletions crates/rspack_core/src/dependency/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ pub use runtime_requirements_dependency::{
RuntimeRequirementsDependency, RuntimeRequirementsDependencyTemplate,
};
pub use runtime_template::*;
use rustc_hash::FxHashMap;
use rustc_hash::{FxHashMap, FxHashSet};
use serde::Serialize;
pub use span::SpanExt;
pub use static_exports_dependency::{StaticExportsDependency, StaticExportsSpec};
Expand Down Expand Up @@ -106,8 +106,8 @@ pub struct ExportsSpec {
pub terminal_binding: Option<bool>,
pub from: Option<ModuleGraphConnection>,
pub dependencies: Option<Vec<ModuleIdentifier>>,
pub hide_export: Option<Vec<Atom>>,
pub exclude_exports: Option<Vec<Atom>>,
pub hide_export: Option<FxHashSet<Atom>>,
pub exclude_exports: Option<FxHashSet<Atom>>,
}

pub trait DependencyConditionFn: Sync + Send {
Expand Down
5 changes: 3 additions & 2 deletions crates/rspack_core/src/exports/exports_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use either::Either;
use rspack_cacheable::cacheable;
use rspack_collections::{impl_item_ukey, Ukey, UkeySet};
use rspack_util::atom::Atom;
use rustc_hash::FxHashSet;
use serde::Serialize;

use super::{
Expand Down Expand Up @@ -129,15 +130,15 @@ impl ExportsInfo {
&self,
mg: &mut ModuleGraph,
can_mangle: bool,
exclude_exports: Option<Vec<Atom>>,
exclude_exports: Option<&FxHashSet<Atom>>,
target_key: Option<DependencyId>,
target_module: Option<DependencyId>,
priority: Option<u8>,
) -> bool {
let mut changed = false;

if let Some(exclude_exports) = &exclude_exports {
for name in exclude_exports {
for name in exclude_exports.iter() {
self.get_export_info(mg, name);
}
}
Expand Down
Loading
Loading