getsentry / rust-sourcemap

A library for rust that implements basic sourcemap handling
Other
224 stars 28 forks source link

Add support for ignoreList property #93

Closed wbinnssmith closed 3 weeks ago

wbinnssmith commented 1 month ago

Sourcemaps can now specify an ignoreList[0], a list of indexes into sources for which those sources should be shown as ignored in dev tools, for example as collapsed stack frames in program stacks.

This adds the list to the SourceMap structure but only includes it in serialized output when it’s non-zero. Open to feedback.

Added a test to exercise this through flattening indexed source maps into a regular map with updated source positions.

[0] https://tc39.es/source-map/#source-map-format

wbinnssmith commented 1 month ago

cc @bgw @sokra

loewenheim commented 1 month ago

Hi, thank you for the contribution! I'm wondering if it might not be better to use a BTreeSet for the ignored indices to make serialization order deterministic.

wbinnssmith commented 1 month ago

Yeah, I think this is a good call. We use https://github.com/indexmap-rs/indexmap in Turbopack for this, but I was hesitant to add another dependency and the sourcemap spec doesn't seem to prefer any specific order, but implementations may.

A BTree wouldn't have constant time insertion, and we can end up doing a lot of redundant insertions during a sectioned map flatten with the code as it stands, but this may be negligible.

I'll make the change 😄