Skip to content

Remove unstable_compactSourceMaps; always store compact VLQ source maps (#1765)#1765

Open
robhogan wants to merge 3 commits into
mainfrom
export-D110762248
Open

Remove unstable_compactSourceMaps; always store compact VLQ source maps (#1765)#1765
robhogan wants to merge 3 commits into
mainfrom
export-D110762248

Conversation

@robhogan

@robhogan robhogan commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Summary:

unstable_compactSourceMaps gated whether the transform worker stored each module's source map as a compact VLQ VlqMap ({mappings, names}) or as decoded MetroSourceMapSegmentTuple[]. Its default was flipped to true earlier in this stack; this removes the option entirely and makes compact VLQ storage unconditional.

  • Deletes the transformer.unstable_compactSourceMaps option (Flow type, metro-config default, and generated TS type).
  • Simplifies transformJS/transformJSON to always encode a VlqMap: the Babel decoded-map fast path when not minifying, re-encoding the minifier's tuples otherwise.
  • Narrows JsOutput.data.map from Array<MetroSourceMapSegmentTuple> | VlqMap to VlqMap and regenerates the TS defs.

unstable_compactSourceMaps was recently introduced and has never appears in an OSS release.

Changelog:

 - **[Breaking]** Transformer output (`JsOutput['data']['map']`) is now always a `VlqMap`

Reviewed By: GijsWeterings

Differential Revision: D110762248

robhogan and others added 2 commits July 6, 2026 06:04
…ults to `true`

Differential Revision: D110759649
Summary:
The whole-bundle source map served by Metro (the `.map` endpoint, inline source maps, and RAM bundle info) can be emitted either as a flat map or as an indexed/sectioned map. The indexed form passes each module's stored VLQ `mappings` through verbatim instead of decoding and re-encoding them into one flat map, so it is much cheaper to serialize; the flat form was only kept for consumers that predate index-map support. This was gated behind `serializer.unstable_allowIndexMap` (default off) and additionally only took effect when at least one module actually stored a compact VLQ map (`shouldEmitIndexedMap` checked `some(isVlqMap)`).

Index maps are now safe to emit unconditionally, so this removes the choice:

- Deletes the `serializer.unstable_allowIndexMap` option (default, Flow type, and generated TS type).
- Removes `shouldEmitIndexedMap` and the `some(isVlqMap)` guard from `sourceMapGenerator`; both `sourceMapGenerator` and `sourceMapGeneratorNonBlocking` now always call `fromRawMappingsIndexed`. `fromRawMappingsIndexed`/`toIndexMapSection` already handle every input shape (VLQ maps pass through verbatim; tuple maps are re-encoded per section), so no change is needed there.
- Drops the now-dead `allowIndexMap` plumbing from `Server.js` and the `unstable_allowIndexMap` wiring in the fb-metro CLI (the `--experimental-compact-source-maps` flag still controls `transformer.unstable_compactSourceMaps`, which is what determines VLQ storage).

Behavioral change: the bundle `.map` (and inline/RAM-bundle maps) is now always a sectioned index map, whereas previously it defaulted to a flat map. This is the intended graduation of the index-map path; consumers on this toolchain already understand index maps.

Scope note — this does NOT make the flat serialization functions dead: `fromRawMappings` is still called directly by `metro-transform-worker` and `metro-buck-transform-worker` for single-module maps, and `fromRawMappings`/`fromRawMappingsNonBlocking`/`isVlqMap`/`toBabelSegments` remain public exports of `metro-source-map`. Only the serializer's flat-vs-indexed *choice* is removed. `fromRawMappingsNonBlocking` is now internally unused but retained as public API; removing it would be a separate, deliberate API break.

Differential Revision: D110757150
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jul 6, 2026
@meta-codesync meta-codesync Bot force-pushed the export-D110762248 branch 2 times, most recently from 802c496 to c3c5977 Compare July 6, 2026 15:19
robhogan added a commit that referenced this pull request Jul 6, 2026
…maps (#1765)

Summary:
Pull Request resolved: #1765

`unstable_compactSourceMaps` gated whether the transform worker stored each module's source map as a compact VLQ `VlqMap` (`{mappings, names}`) or as decoded `MetroSourceMapSegmentTuple[]`. Its default was flipped to `true` earlier in this stack; this removes the option entirely and makes compact VLQ storage unconditional.

- Deletes the `transformer.unstable_compactSourceMaps` option (Flow type, metro-config default, and generated TS type).
- Simplifies `transformJS`/`transformJSON` to always encode a `VlqMap`: the Babel decoded-map fast path when not minifying, re-encoding the minifier's tuples otherwise.
- Narrows `JsOutput.data.map` from `Array<MetroSourceMapSegmentTuple> | VlqMap` to `VlqMap` and regenerates the TS defs.

`unstable_compactSourceMaps` was recently introduced and has never appears in an OSS release.

Changelog:
```
 - **[Breaking]** Transformer output (`JsOutput['data']['map']`) is now always a `VlqMap`
````

Reviewed By: GijsWeterings

Differential Revision: D110762248
@robhogan robhogan force-pushed the export-D110762248 branch from c3c5977 to c4ddfa9 Compare July 6, 2026 15:22
@meta-codesync meta-codesync Bot changed the title Remove unstable_compactSourceMaps; always store compact VLQ source maps Remove unstable_compactSourceMaps; always store compact VLQ source maps (#1765) Jul 6, 2026
@meta-codesync

meta-codesync Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

@robhogan has exported this pull request. If you are a Meta employee, you can view the originating Diff in D110762248.

…maps (#1765)

Summary:
Pull Request resolved: #1765

`unstable_compactSourceMaps` gated whether the transform worker stored each module's source map as a compact VLQ `VlqMap` (`{mappings, names}`) or as decoded `MetroSourceMapSegmentTuple[]`. Its default was flipped to `true` earlier in this stack; this removes the option entirely and makes compact VLQ storage unconditional.

- Deletes the `transformer.unstable_compactSourceMaps` option (Flow type, metro-config default, and generated TS type).
- Simplifies `transformJS`/`transformJSON` to always encode a `VlqMap`: the Babel decoded-map fast path when not minifying, re-encoding the minifier's tuples otherwise.
- Narrows `JsOutput.data.map` from `Array<MetroSourceMapSegmentTuple> | VlqMap` to `VlqMap` and regenerates the TS defs.

`unstable_compactSourceMaps` was recently introduced and has never appears in an OSS release.

Changelog:
```
 - **[Breaking]** Transformer output (`JsOutput['data']['map']`) is now always a `VlqMap`
````

Reviewed By: GijsWeterings

Differential Revision: D110762248
@robhogan robhogan force-pushed the export-D110762248 branch from c4ddfa9 to 8725281 Compare July 6, 2026 15:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. meta-exported

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant