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

Merge multi-source output sourcemaps #14246

Merged
merged 1 commit into from Feb 6, 2022

Commits on Feb 6, 2022

  1. Merge multi-source output sourcemaps

    Surprisingly, Babel allows a transformer to mark the source file of
    a node to allow it to be sourced from any file. When this happens, the
    output sourcemap will contain multiple `sources`. I didn't realize this
    when I created babel#14209, and this `remapping` will throw an error if the
    output map has multiple sources.
    
    This can be fixed by using `remapping`'s graph building API (don't pass
    an array). This allows us to return an input map for _any_ source file,
    and we just need some special handling to figure out which source is our
    transformed file.
    
    This actually adds a new feature, allowing us to remap these
    multi-source outputs. Previously, the merging would silently fail and
    generate a blank (no `mappings`) sourcemap. That's not great. The new
    behavior will properly merge the maps, provided we can figure out which
    source is the transformed file (which should always work, I can't think
    of a case it wouldn't).
    
    Fixes ampproject/remapping#159.
    jridgewell committed Feb 6, 2022
    Copy the full SHA
    205983a View commit details
    Browse the repository at this point in the history