-
Notifications
You must be signed in to change notification settings - Fork 710
Description
What problem does this feature solve?
It is implemented in rolldown_plugin_vite_reporter. But this is not specific to Vite, so it would be nice to be implemented in core.
rolldown/crates/rolldown_plugin_vite_reporter/src/lib.rs
Lines 122 to 153 in e966919
| // TODO(shulaoda): Consider moving the following logic into core | |
| if !args.options.inline_dynamic_imports { | |
| for id in &args.chunk.module_ids { | |
| let Some(module) = ctx.get_module_info(id) else { | |
| continue; | |
| }; | |
| // When a dynamic importer shares a chunk with the imported module, | |
| // warn that the dynamic imported module will not be moved to another chunk (#12850). | |
| if !module.importers.is_empty() && !module.dynamic_importers.is_empty() { | |
| // Filter out the intersection of dynamic importers and sibling modules in | |
| // the same chunk. The intersecting dynamic importers' dynamic import is not | |
| // expected to work. Note we're only detecting the direct ineffective dynamic import here. | |
| let detected_ineffective_dynamic_import = module | |
| .dynamic_importers | |
| .iter() | |
| .any(|id| !is_in_node_modules(id.as_path()) && args.chunk.module_ids.contains(id)); | |
| if detected_ineffective_dynamic_import { | |
| let dynamic_importers_list: Vec<_> = | |
| module.dynamic_importers.iter().map(std::convert::AsRef::as_ref).collect(); | |
| let importers_list: Vec<_> = | |
| module.importers.iter().map(std::convert::AsRef::as_ref).collect(); | |
| let message = format!( | |
| "\n(!) {} is dynamically imported by {} but also statically imported by {}, dynamic import will not move module into another chunk.\n", | |
| module.id.as_ref(), | |
| utils::join_with_limit(&dynamic_importers_list, ", ", 5), | |
| utils::join_with_limit(&importers_list, ", ", 5), | |
| ); | |
| ctx.warn(rolldown_common::LogWithoutPlugin { message, ..Default::default() }); | |
| } | |
| } | |
| } | |
| } |
Tried copilot in #7530 but didn't have time to verify the code.
What does the proposed API look like?
Not an API change
Reactions are currently unavailable