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

Improving the SourceMapBuilder API #85

Open
loewenheim opened this issue Mar 18, 2024 · 0 comments
Open

Improving the SourceMapBuilder API #85

loewenheim opened this issue Mar 18, 2024 · 0 comments

Comments

@loewenheim
Copy link
Contributor

This is part of #71.

In general I think the "nice" style of builder API is along the lines of

Builder::new()
    .add_something()
    .add_more()
    []
    .build()

By contrast, SourceMapBuilder has a bunch of of get and set methods. Unfortunately the "flow" style won't work for e.g. add_source because it needs to return the source ID.

I would advocate for getting rid at least of the following methods:

  • get_file
  • get_source_root
  • get_source, set_source
  • get_source_contents
  • strip_prefixes (just do that before adding the sources)

I'm not entirely sure about set_source_contents and load_local_source_contents. Being able to set source contents after the fact might come in handy. But there's also something to be said for only setting everything once.

add/add_with_id/add_raw/add_token should probably condensed and/or cleaned up—it's not easy to understand the difference between them and why e.g. add takes both a source and a source_id parameter.

@loewenheim loewenheim self-assigned this Mar 18, 2024
@olksdr olksdr changed the title Improving the SourceMapBuilder API [EPIC] Improving the SourceMapBuilder API Sep 23, 2024
@olksdr olksdr changed the title [EPIC] Improving the SourceMapBuilder API Improving the SourceMapBuilder API Sep 23, 2024
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

No branches or pull requests

1 participant