@@ -828,127 +828,9 @@ impl CodeSplitter {
828828
829829 fn create_chunks ( & mut self , compilation : & mut Compilation ) -> Result < ( ) > {
830830 let mut errors = vec ! [ ] ;
831- // let mut roots: Vec<CreateChunkRoot> = vec![];
832- // for (idx, (name, data)) in entries.iter().enumerate() {
833- // name_to_idx.insert(name, idx);
834- // let runtime = if let Some(depend_on) = &data.options.depend_on {
835- // deps.push((name, depend_on.clone()));
836- // None
837- // } else {
838- // Some(RuntimeSpec::from_entry_options(&data.options).expect("should have runtime"))
839- // };
840-
841- // // set runtime later
842- // roots.push(CreateChunkRoot::Entry(name.clone(), data.clone(), runtime));
843- // }
844-
845- // let mut entry_to_deps = HashMap::default();
846- // for (entry, deps) in deps {
847- // entry_to_deps.insert(
848- // entry.as_str(),
849- // deps
850- // .into_iter()
851- // .map(|dep| *name_to_idx.get(&dep).expect("should have idx"))
852- // .collect::<Vec<_>>(),
853- // );
854- // }
855-
856- // for (entry, _) in entries.iter() {
857- // let curr = *name_to_idx.get(entry).expect("unreachable");
858- // if roots[curr].get_runtime().is_some() {
859- // // already set
860- // continue;
861- // }
862- // let mut visited = Default::default();
863- // if let Err(dep) =
864- // set_entry_runtime_and_depend_on(curr, &mut roots, &entry_to_deps, &mut visited, &mut vec![])
865- // {
866- // let dep_name = roots[dep].entry_name();
867- // let dep_rt = RuntimeSpec::from_entry(dep_name, None);
868- // error_roots.push((curr, Diagnostic::from(error!("Entrypoints '{entry}' and '{dep_name}' use 'dependOn' to depend on each other in a circular way."))));
869- // roots[dep].set_runtime(dep_rt);
870- // roots[curr].set_runtime(RuntimeSpec::from_entry(entry, None));
871- // }
872- // }
873-
874- // let mut entry_module_runtime = IdentifierMap::<RuntimeSpec>::default();
875- // let module_graph: ModuleGraph = compilation.get_module_graph();
876- // for root in &roots {
877- // if let CreateChunkRoot::Entry(_name, data, runtime) = root {
878- // let runtime = runtime
879- // .as_ref()
880- // .expect("should have runtime after calculated depend on");
881- // for dep_id in compilation
882- // .global_entry
883- // .all_dependencies()
884- // .chain(data.all_dependencies())
885- // {
886- // let Some(module) = module_graph.module_identifier_by_dependency_id(dep_id) else {
887- // continue;
888- // };
889- // match entry_module_runtime.entry(*module) {
890- // std::collections::hash_map::Entry::Occupied(mut existing) => {
891- // let new_runtime = merge_runtime(existing.get(), &runtime);
892- // existing.insert(new_runtime);
893- // }
894- // std::collections::hash_map::Entry::Vacant(vacant) => {
895- // vacant.insert(runtime.clone());
896- // }
897- // }
898- // }
899- // }
900- // }
901-
902- // let module_graph = compilation.get_module_graph();
903- // let module_cache = DashMap::default();
904-
905- // roots.extend(
906- // self
907- // .blocks
908- // .par_iter()
909- // .map(|(block_id, origin)| {
910- // let visited = IdentifierDashSet::default();
911- // let block = module_graph
912- // .block_by_id(block_id)
913- // .expect("should have block");
914- // let runtime = if let Some(group_options) = block.get_group_options()
915- // && let Some(entry_options) = group_options.entry_options()
916- // {
917- // RuntimeSpec::from_entry_options(entry_options).or_else(|| {
918- // determine_runtime(
919- // *origin,
920- // &module_graph,
921- // &entry_module_runtime,
922- // &module_cache,
923- // &visited,
924- // )
925- // })
926- // } else {
927- // determine_runtime(
928- // *origin,
929- // &module_graph,
930- // &entry_module_runtime,
931- // &module_cache,
932- // &visited,
933- // )
934- // };
935-
936- // if runtime.is_none() {
937- // dbg!(block.identifier());
938- // panic!()
939- // }
940- // CreateChunkRoot::Block(*origin, *block_id, runtime)
941- // })
942- // .collect::<Vec<_>>(),
943- // );
944-
945- // for root in &roots {
946- // if let Some(runtime) = root.get_runtime() {
947- // self.module_deps.insert(runtime.clone(), Default::default());
948- // }
949- // }
950831
951832 let roots = self . analyze_module_graph ( compilation) ?;
833+
952834 // fill chunk with modules in parallel
953835 let chunks = roots
954836 . into_par_iter ( )
0 commit comments