Skip to content

feat: support index source map#214

Draft
SyMind wants to merge 12 commits intomainfrom
support-index-source-map
Draft

feat: support index source map#214
SyMind wants to merge 12 commits intomainfrom
support-index-source-map

Conversation

@SyMind
Copy link
Collaborator

@SyMind SyMind commented Feb 13, 2026

No description provided.

@gemini-code-assist
Copy link

Summary of Changes

Hello @SyMind, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces support for IndexSourceMap, a more efficient representation for source maps, particularly beneficial when dealing with concatenated sources. By allowing source maps to be composed of multiple sections with offsets, it avoids the costly process of merging individual mappings, leading to improved performance and reduced memory usage for complex bundles. The changes include new data structures, a new trait method, and optimized implementations for ConcatSource and CachedSource.

Highlights

  • New IndexSourceMap Structure: Introduced IndexSourceMap to represent source maps as a collection of sections, improving performance for concatenated sources by avoiding expensive mapping merges.
  • Enhanced Source Trait: Added an index_map method to the Source trait, providing a more efficient way to generate source maps for complex source structures, with a default implementation that wraps a regular SourceMap.
  • Optimized ConcatSource: Implemented index_map for ConcatSource to intelligently combine source map sections from its children, correctly handling line and column offsets, including UTF-16 code unit counting.
  • Cached IndexSourceMap Results: Enhanced CachedSource to cache IndexSourceMap results, preventing redundant computations and improving performance for cached sources.
  • Comprehensive Testing and Benchmarking: Included a new benchmark to measure the performance of index_map and added extensive unit tests for IndexSourceMap serialization, flattening, and various concatenation scenarios.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • benches/benchmark_repetitive_react_components.rs
    • Added benchmark_repetitive_react_components_index_map to benchmark the new index_map functionality.
  • src/cached_source.rs
    • Imported IndexSourceMap.
    • Added columns_index_map and line_only_index_map fields to CachedData for caching IndexSourceMap results.
    • Implemented the index_map method for CachedSource to utilize the new caching mechanism.
    • Added new tests to verify index_map caching behavior and correctness.
  • src/concat_source.rs
    • Imported IndexSourceMap, Section, and SectionOffset.
    • Implemented the index_map method for ConcatSource, which iterates through child sources, offsets their index maps, and combines them into a single IndexSourceMap.
    • Added logic to correctly calculate line and column offsets, including handling UTF-16 code units for column counting.
    • Added numerous unit tests to cover various ConcatSource scenarios with IndexSourceMap, including raw sources, single/multiple original sources, raw prefixes/suffixes, same-line concatenation, mixed sources, nested sources, and empty children.
  • src/lib.rs
    • Exported IndexSourceMap, Section, and SectionOffset from the source module.
  • src/source.rs
    • Imported encode_mappings helper.
    • Added index_map method to the Source trait with a default implementation that converts a regular SourceMap into a single-section IndexSourceMap.
    • Implemented index_map for BoxSource to delegate to the inner source.
    • Defined new structs: SectionOffset, Section, and IndexSourceMap.
    • Implemented IndexSourceMap with methods for creation, file management, accessing sections, and to_source_map for flattening into a regular SourceMap.
    • Added to_json and to_writer methods for IndexSourceMap serialization.
    • Added unit tests for IndexSourceMap serialization, flattening with various offsets, and the default index_map implementation.
Activity
  • No specific activity (comments, reviews, progress updates) was provided in the context.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@codspeed-hq
Copy link

codspeed-hq bot commented Feb 13, 2026

Merging this PR will not alter performance

✅ 11 untouched benchmarks
🆕 1 new benchmark
⏩ 6 skipped benchmarks1

Performance Changes

Benchmark BASE HEAD Efficiency
🆕 repetitive_react_components_index_map N/A 2.1 ms N/A

Comparing support-index-source-map (ba214a1) with main (74beb79)

Open in CodSpeed

Footnotes

  1. 6 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces support for Index Source Maps, which is a great feature for improving performance with concatenated sources. The implementation is thorough, covering Source, ConcatSource, and CachedSource, and includes a comprehensive set of tests that cover many edge cases. The logic for generating index maps in ConcatSource and flattening them back into regular source maps in IndexSourceMap seems solid. I've found a couple of minor areas for improvement in src/source.rs for idiomatic code and robustness, but overall this is an excellent contribution.

src/source.rs Outdated
Comment on lines 742 to 744
while global_sources_content.len() < global_sources.len() {
global_sources_content.push("".into());
}

Choose a reason for hiding this comment

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

medium

This while loop can be simplified to a single call to resize_with, which is more idiomatic and potentially more efficient for growing the vector.

            global_sources_content.resize_with(global_sources.len(), || "".into());

@SyMind SyMind force-pushed the support-index-source-map branch from a0d63f1 to f0c5e32 Compare February 13, 2026 03:02
@SyMind SyMind force-pushed the support-index-source-map branch 2 times, most recently from 0e15849 to 7d9c7bb Compare February 13, 2026 06:56
@SyMind SyMind force-pushed the support-index-source-map branch from 7d9c7bb to 5ab3b74 Compare February 13, 2026 07:19
@SyMind SyMind force-pushed the support-index-source-map branch 2 times, most recently from 0a07242 to a11f1f1 Compare February 13, 2026 08:16
@SyMind SyMind force-pushed the support-index-source-map branch from a11f1f1 to ed51f33 Compare February 13, 2026 08:32
@SyMind SyMind force-pushed the support-index-source-map branch from c49eb99 to 55b7568 Compare February 13, 2026 09:18
@SyMind SyMind force-pushed the support-index-source-map branch from 7a70605 to 4eae42c Compare February 13, 2026 09:47
@SyMind SyMind force-pushed the support-index-source-map branch from 279a852 to ff51f68 Compare February 13, 2026 10:44
@SyMind SyMind force-pushed the support-index-source-map branch 4 times, most recently from 916bf6e to 5c60467 Compare February 15, 2026 09:53
@SyMind SyMind force-pushed the support-index-source-map branch from 5c60467 to ba214a1 Compare February 15, 2026 09:54
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.

1 participant

Comments