-
-
Notifications
You must be signed in to change notification settings - Fork 776
feat(mf): layer-aware sharing and runtime scope-array support #12977
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
base: main
Are you sure you want to change the base?
Changes from 34 commits
f7afc46
34067b4
d0c5134
973d606
73579ad
695dcec
d4d6c2b
1030e0e
6059add
f762b6d
f56cb0e
12fdb20
75af9c2
a0bb7f3
6ae03fc
c2bdb34
65a0e4c
b651744
eb8cc84
8d765e9
77308ef
5fc25b9
3569738
6376498
c6980a9
a74d3f7
40df8b6
649d953
42b9549
ac74d78
8a2385f
d875250
3fd5af6
365c874
0cf57a5
646a072
a6f893b
c4882a2
ec97815
1e7b8f8
e62ddd8
81f9f62
e9116c2
bd5426a
6a20443
57f380b
6ab4004
9480e6b
96e7c01
2fbaad3
100611e
6bf7052
f15c27b
226452c
1eb2a18
492d8a4
b555530
a77dd3d
5853d77
6e12116
95cb638
dbf821c
ca2cac9
e4e588e
0a5dfad
01b7015
211d598
13875e3
7b80d28
feab32c
f7ff936
b90f83b
eef09ad
04e1c3b
0fe891e
61bd287
b241619
91abbcd
8d0c4a9
8e82836
1540f0e
dbf3131
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -215,6 +215,7 @@ impl Module for ContainerEntryModule { | |
| Box::new(ContainerExposedDependency::new( | ||
| name.clone(), | ||
| request.clone(), | ||
| options.layer.clone(), | ||
| )) as Box<dyn Dependency> | ||
| }) | ||
| .collect(), | ||
|
|
@@ -397,12 +398,13 @@ var init = function(shareScope, initScope) {{ | |
| has_own_property = | ||
| runtime_template.render_runtime_globals(&RuntimeGlobals::HAS_OWN_PROPERTY), | ||
| share_scope_map = runtime_template.render_runtime_globals(&RuntimeGlobals::SHARE_SCOPE_MAP), | ||
| share_scope = json_stringify_str(match &self.share_scope { | ||
| ShareScope::Single(s) => s.as_str(), | ||
| ShareScope::Multiple(_) => { | ||
| panic!("ContainerEntryModule: enhanced=false only supports string share scope") | ||
| } | ||
| }), | ||
| share_scope = json_stringify_str( | ||
| self | ||
| .share_scope | ||
| .scopes() | ||
| .first() | ||
|
||
| .map_or("default", |s| s.as_str()) | ||
| ), | ||
| initialize_sharing = | ||
| runtime_template.render_runtime_globals(&RuntimeGlobals::INITIALIZE_SHARING), | ||
| define_property_getters = | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -211,12 +211,21 @@ impl Module for RemoteModule { | |
| ) | ||
| }); | ||
| codegen.add(SourceType::Remote, RawStringSource::from_static("").boxed()); | ||
| codegen.data.insert(CodeGenerationDataShareInit { | ||
| items: vec![ShareInitData { | ||
| share_scope: self.share_scope.clone(), | ||
| let scopes: Vec<String> = if self.share_scope.is_empty() { | ||
| vec!["default".to_string()] | ||
| } else { | ||
| self.share_scope.scopes().to_vec() | ||
| }; | ||
| let share_init_items = scopes | ||
| .iter() | ||
| .map(|scope| ShareInitData { | ||
| share_scope: ShareScope::Single(scope.clone()), | ||
|
||
| init_stage: 20, | ||
| init: DataInitInfo::ExternalModuleId(id.cloned()), | ||
| }], | ||
| }) | ||
| .collect(); | ||
| codegen.data.insert(CodeGenerationDataShareInit { | ||
| items: share_init_items, | ||
| }); | ||
| Ok(codegen) | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,10 +32,13 @@ use rspack_util::fx_hash::{FxHashMap as HashMap, FxHashSet as HashSet}; | |
| use utils::{ | ||
| collect_entry_files, collect_expose_requirements, compose_id_with_separator, | ||
| ensure_configured_remotes, ensure_shared_entry, filter_assets, is_hot_file, | ||
| parse_consume_shared_identifier, parse_provide_shared_identifier, record_shared_usage, strip_ext, | ||
| parse_provide_shared_identifier, record_shared_usage, strip_ext, | ||
| }; | ||
|
|
||
| use crate::container::{container_entry_module::ContainerEntryModule, remote_module::RemoteModule}; | ||
| use crate::{ | ||
| container::{container_entry_module::ContainerEntryModule, remote_module::RemoteModule}, | ||
| sharing::consume_shared_module::ConsumeSharedModule, | ||
| }; | ||
|
|
||
| #[plugin] | ||
| #[derive(Debug)] | ||
|
|
@@ -358,9 +361,21 @@ async fn process_assets(&self, compilation: &mut Compilation) -> Result<()> { | |
| continue; | ||
| } | ||
|
|
||
| if matches!(module_type, ModuleType::ConsumeShared) | ||
| && let Some((pkg, required)) = parse_consume_shared_identifier(&identifier) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Need @2heal1 to review the manifest related changes |
||
| { | ||
| if matches!(module_type, ModuleType::ConsumeShared) { | ||
| let Some(consume_shared_module) = module | ||
| .as_ref() | ||
| .as_any() | ||
| .downcast_ref::<ConsumeSharedModule>() | ||
| else { | ||
| continue; | ||
| }; | ||
| let pkg = consume_shared_module.share_key().to_string(); | ||
| if pkg.is_empty() { | ||
| continue; | ||
| } | ||
| let required = consume_shared_module | ||
| .required_version() | ||
| .map(ToString::to_string); | ||
| let mut target_ids: IdentifierSet = IdentifierSet::default(); | ||
| for connection in module_graph.get_outgoing_connections(&module_identifier) { | ||
| let module_id = *connection.module_identifier(); | ||
|
|
||
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.
The unwrap should keep