feat:add INEFFECTIVE_DYNAMIC_IMPORT warning in core#7971
feat:add INEFFECTIVE_DYNAMIC_IMPORT warning in core#7971AliceLanniste wants to merge 3 commits intorolldown:mainfrom
Conversation
| if !self.options.code_splitting.is_disabled() { | ||
| Self::check_ineffective_dynamic_import_for_module( | ||
| target_chunk_idx, | ||
| chunk_graph, | ||
| module_table, | ||
| ineffective_warnings, | ||
| ); | ||
| } |
There was a problem hiding this comment.
This code will generate duplicate warnings when multiple module groups are merged into the same chunk. The function check_ineffective_dynamic_import_for_module iterates over ALL modules in target_chunk_idx each time it's called, but merge_modules_into_existing_chunk can be called multiple times for the same chunk during optimization. Each call will re-check all previously added modules, creating duplicate warnings.
Evidence: The test snapshot at crates/rolldown/tests/rolldown/code_splitting/issue_2786/artifacts.snap shows the exact same warning for share.js appearing twice.
// Instead of checking all modules in the chunk repeatedly,
// only check the newly added modules:
for module_idx in &modules {
Self::check_ineffective_dynamic_import_for_module(
*module_idx,
target_chunk_idx,
chunk_graph,
module_table,
ineffective_warnings,
);
}The function signature should also change to check a single module instead of iterating over all modules in a chunk.
| if !self.options.code_splitting.is_disabled() { | |
| Self::check_ineffective_dynamic_import_for_module( | |
| target_chunk_idx, | |
| chunk_graph, | |
| module_table, | |
| ineffective_warnings, | |
| ); | |
| } | |
| if !self.options.code_splitting.is_disabled() { | |
| for module_idx in &modules { | |
| Self::check_ineffective_dynamic_import_for_single_module( | |
| *module_idx, | |
| target_chunk_idx, | |
| chunk_graph, | |
| module_table, | |
| ineffective_warnings, | |
| ); | |
| } | |
| } |
Spotted by Graphite Agent
Is this helpful? React 👍 or 👎 to let us know.
closes #7541, #7971 --- Thanks to @AliceLanniste for the effort in PR #7971. Co-authored-by: AliceLanniste <1399789151@qq.com>
|
Closed by #8284 |
closed #7541