Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for ignoreList property #93

Merged
merged 3 commits into from
Nov 7, 2024

Conversation

wbinnssmith
Copy link
Contributor

@wbinnssmith wbinnssmith commented Oct 16, 2024

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
Copy link
Contributor Author

cc @bgw @sokra

@wbinnssmith wbinnssmith force-pushed the wbinnssmith/ignore-list branch 2 times, most recently from c8fb7d4 to 9db4ff4 Compare October 17, 2024 01:08
@loewenheim
Copy link
Contributor

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
Copy link
Contributor Author

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 😄

@wbinnssmith wbinnssmith force-pushed the wbinnssmith/ignore-list branch 2 times, most recently from 8c60825 to 4e914e7 Compare October 17, 2024 18:43
@loewenheim loewenheim self-assigned this Oct 18, 2024
Copy link
Member

@Swatinem Swatinem left a comment

Choose a reason for hiding this comment

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

You are converting to/from Vec<u32> as it is defined in the JSON types, and the public API.
Which Set implementation you use should not really matter in those cases.

src/types.rs Outdated Show resolved Hide resolved
src/types.rs Outdated
pub fn new(
file: Option<Arc<str>>,
mut tokens: Vec<RawToken>,
names: Vec<Arc<str>>,
sources: Vec<Arc<str>>,
sources_content: Option<Vec<Option<Arc<str>>>>,
ignore_list: Option<Vec<u32>>,
Copy link
Member

Choose a reason for hiding this comment

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

this is a breaking change

Copy link
Contributor

Choose a reason for hiding this comment

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

That's a good point. This could be avoided by removing this parameter and using add_to_ignore_list in SourceMapBuilder::into_sourcemap.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Could we add a corresponding add_to_ignore_list (or set_ignore_list) in the builder?

@wbinnssmith wbinnssmith force-pushed the wbinnssmith/ignore-list branch from 4e914e7 to 93d524e Compare October 21, 2024 15:40
Sourcemaps can now specify an `ignoreList`, 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.
@wbinnssmith wbinnssmith force-pushed the wbinnssmith/ignore-list branch from 93d524e to d3c1b28 Compare October 21, 2024 23:42
src/builder.rs Outdated Show resolved Hide resolved
src/types.rs Outdated
pub fn new(
file: Option<Arc<str>>,
mut tokens: Vec<RawToken>,
names: Vec<Arc<str>>,
sources: Vec<Arc<str>>,
sources_content: Option<Vec<Option<Arc<str>>>>,
ignore_list: Option<Vec<u32>>,
Copy link
Contributor

Choose a reason for hiding this comment

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

That's a good point. This could be avoided by removing this parameter and using add_to_ignore_list in SourceMapBuilder::into_sourcemap.

Co-authored-by: Sebastian Zivota <[email protected]>
@wbinnssmith wbinnssmith force-pushed the wbinnssmith/ignore-list branch from bcb7141 to 5ddd8f1 Compare October 23, 2024 23:49
@wbinnssmith wbinnssmith force-pushed the wbinnssmith/ignore-list branch from 5ddd8f1 to fb686c7 Compare November 7, 2024 00:28
@loewenheim loewenheim merged commit 9130f31 into getsentry:master Nov 7, 2024
6 checks passed
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.

3 participants