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

[cli] Avoid SourceMapGenerator for simple map concatenation #14479

Merged
merged 2 commits into from Apr 21, 2022

Commits on Apr 20, 2022

  1. babel-cli: avoid SourceMapGenerator for simple map concatenation

    This removes the last use of `source-map` package from babel-cli. Instead, we use a [SectionedSourceMap](https://github.com/jridgewell/trace-mapping/blob/8db5df070b15e2a669277b710a9d69ad0676524d/src/types.ts#L28-L32), which is purpose built for simple file concatenation like this.
    
    This should be considerably faster to generate sourcemaps now. And, if a sourcemaps are not needed, it's essentially free. As an added benefit, this gives us proper `names` support:
    
    ```diff
    --- a	2022-04-20 11:01:49.000000000 -0400
    +++ b	2022-04-20 11:01:55.000000000 -0400
    @@ -1,12 +1,17 @@
     {
       "version": 3,
       "file": "script2.js",
    -  "names": [],
    +  "names": [ "arr", "map", "x", "MULTIPLIER" ],
       "sources": [
         "script.js"
       ],
       "sourcesContent": [
         "arr.map(x => x * MULTIPLIER);"
       ],
    -  "mappings": ";;AAAA,GAAG,CAAC,GAAJ,CAAQ,UAAA,CAAC;AAAA,SAAI,CAAC,GAAG,UAAR;AAAA,CAAT"
    +  "mappings": ";;AAAAA,GAAG,CAACC,GAAJ,CAAQ,UAAAC,CAAC;AAAA,SAAIA,CAAC,GAAGC,UAAR;AAAA,CAAT"
     }
    ```
    jridgewell committed Apr 20, 2022
    Copy the full SHA
    5bf4bf4 View commit details
    Browse the repository at this point in the history
  2. Dedupe

    jridgewell committed Apr 20, 2022
    Copy the full SHA
    724b527 View commit details
    Browse the repository at this point in the history