Skip to content

feat:add INEFFECTIVE_DYNAMIC_IMPORT warning in core#7971

Closed
AliceLanniste wants to merge 3 commits intorolldown:mainfrom
AliceLanniste:ineffective_dynamic_import
Closed

feat:add INEFFECTIVE_DYNAMIC_IMPORT warning in core#7971
AliceLanniste wants to merge 3 commits intorolldown:mainfrom
AliceLanniste:ineffective_dynamic_import

Conversation

@AliceLanniste
Copy link
Contributor

closed #7541

Comment on lines +210 to +217
if !self.options.code_splitting.is_disabled() {
Self::check_ineffective_dynamic_import_for_module(
target_chunk_idx,
chunk_graph,
module_table,
ineffective_warnings,
);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

@shulaoda shulaoda self-assigned this Feb 12, 2026
graphite-app bot pushed a commit that referenced this pull request Feb 12, 2026
closes #7541, #7971

---

Thanks to @AliceLanniste for the effort in PR #7971.

Co-authored-by: AliceLanniste <1399789151@qq.com>
graphite-app bot pushed a commit that referenced this pull request Feb 12, 2026
closes #7541, #7600, #7971

---

Thanks to @luke358 for the effort in PR #7600.
Thanks to @AliceLanniste for the effort in PR #7971.

Co-authored-by: luke358 <qq1494135711@gmail.com>
Co-authored-by: AliceLanniste <1399789151@qq.com>
@shulaoda
Copy link
Member

Closed by #8284

@shulaoda shulaoda closed this Feb 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request]: add INEFFECTIVE_DYNAMIC_IMPORT warning in core

2 participants