deno_core icon indicating copy to clipboard operation
deno_core copied to clipboard

feat: enhance `ModuleMap`

Open CyanChanges opened this issue 5 months ago โ€ข 1 comments

Issue: #1143

CyanChanges avatar Jun 12 '25 10:06 CyanChanges

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Jun 12 '25 10:06 CLAassistant

@CyanChanges can you please rebase this PR to the latest main?

bartlomieju avatar Nov 21 '25 20:11 bartlomieju

Walkthrough

This pull request expands the public API of the module management system by promoting previously private types and methods to public visibility. ModuleMap transitions from pub(crate) to pub with new public accessor/mutator methods (get, set, delete, alias_id, with_map), along with name resolution methods (get_name_by_module, get_name_by_id). Similarly, ModuleReference, ModuleRequest, and SymbolicModule are made public. ModuleMapData receives updated method signatures supporting generic Borrow-based key comparisons and returns reference types instead of owned Strings. A new unsafe function module_map_from is added to JsRuntime to expose module map retrieval from a V8 scope. Test coverage is extended to validate aliasing and mapping behavior.

Estimated code review effort

๐ŸŽฏ 3 (Moderate) | โฑ๏ธ ~25 minutes

  • core/modules/module_map_data.rs: Review method signature changes carefully, especially trait bounds (Borrow<Q>, Hash), type changes to handles_inverted (usize โ†’ ModuleId), and return type adjustments (String โ†’ &ModuleName). Verify serialization/deserialization paths remain correct.
  • core/modules/map.rs: Examine new public method implementations for correct delegation to internal methods and trait bound correctness on generic methods.
  • core/runtime/jsruntime.rs: Verify unsafe function safety documentation and confirm JsRealm::module_map_from is being delegated correctly.

Pre-merge checks and finishing touches

โŒ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage โš ๏ธ Warning Docstring coverage is 65.85% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
โœ… Passed checks (2 passed)
Check name Status Explanation
Title check โœ… Passed The title accurately describes the main change: expanding ModuleMap's public API with new methods and visibility changes.
Description check โœ… Passed The description references Issue #1143, which is related to the changeset even though minimal detail is provided.
โœจ Finishing touches
  • [ ] ๐Ÿ“ Generate docstrings
๐Ÿงช Generate unit tests (beta)
  • [ ] Create PR with unit tests
  • [ ] Post copyable unit tests in a comment

[!TIP]

๐Ÿ“ Customizable high-level summaries are now available in beta!

You can now customize how CodeRabbit generates the high-level summary in your pull requests โ€” including its content, structure, tone, and formatting.

  • Provide your own instructions using the high_level_summary_instructions setting.
  • Format the summary however you like (bullet lists, tables, multi-section layouts, contributor stats, etc.).
  • Use high_level_summary_in_walkthrough to move the summary from the description to the walkthrough section.

Example instruction:

"Divide the high-level summary into five sections:

  1. ๐Ÿ“ Description โ€” Summarize the main change in 50โ€“60 words, explaining what was done.
  2. ๐Ÿ““ References โ€” List relevant issues, discussions, documentation, or related PRs.
  3. ๐Ÿ“ฆ Dependencies & Requirements โ€” Mention any new/updated dependencies, environment variable changes, or configuration updates.
  4. ๐Ÿ“Š Contributor Summary โ€” Include a Markdown table showing contributions: | Contributor | Lines Added | Lines Removed | Files Changed |
  5. โœ”๏ธ Additional Notes โ€” Add any extra reviewer context. Keep each section concise (under 200 words) and use bullet or numbered lists for clarity."

Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later.


Comment @coderabbitai help to get the list of available commands and usage tips.

coderabbitai[bot] avatar Nov 22 '25 04:11 coderabbitai[bot]

Codecov Report

:x: Patch coverage is 86.97318% with 34 lines in your changes missing coverage. Please review. :white_check_mark: Project coverage is 80.29%. Comparing base (0c7f83e) to head (9ccb765). :warning: Report is 382 commits behind head on main.

Files with missing lines Patch % Lines
core/modules/module_map_data.rs 85.58% 16 Missing :warning:
core/modules/map.rs 82.75% 15 Missing :warning:
core/runtime/jsruntime.rs 0.00% 3 Missing :warning:
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1146      +/-   ##
==========================================
- Coverage   81.43%   80.29%   -1.15%     
==========================================
  Files          97      105       +8     
  Lines       23877    27618    +3741     
==========================================
+ Hits        19445    22176    +2731     
- Misses       4432     5442    +1010     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

codecov-commenter avatar Nov 22 '25 04:11 codecov-commenter