deno_core
deno_core copied to clipboard
feat: enhance `ModuleMap`
Issue: #1143
@CyanChanges can you please rebase this PR to the latest main?
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_instructionssetting.- Format the summary however you like (bullet lists, tables, multi-section layouts, contributor stats, etc.).
- Use
high_level_summary_in_walkthroughto move the summary from the description to the walkthrough section.Example instruction:
"Divide the high-level summary into five sections:
- ๐ Description โ Summarize the main change in 50โ60 words, explaining what was done.
- ๐ References โ List relevant issues, discussions, documentation, or related PRs.
- ๐ฆ Dependencies & Requirements โ Mention any new/updated dependencies, environment variable changes, or configuration updates.
- ๐ Contributor Summary โ Include a Markdown table showing contributions:
| Contributor | Lines Added | Lines Removed | Files Changed |- โ๏ธ 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.
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.