sprockets

https://github.com/rails/sprockets

Ruby

Rack-based asset packaging system

Sprockets::SourceMapUtils#combine_source_maps

Public: Combine two seperate source map transformations into a single
mapping.

Source transformations may happen in discrete steps producing separate
source maps. These steps can be combined into a single mapping back to
the source.

For an example, CoffeeScript may transform a file producing a map. Then
Uglifier processes the result and produces another map. The CoffeeScript
map can be combined with the Uglifier map so the source lines of the
minified output can be traced back to the original CoffeeScript file.

  original_map = [{ :source => "index.coffee", :generated => [2, 0], :original => [1, 0] }]
  second_map   = [{ :source => "index.js",     :generated => [1, 1], :original => [2, 0] }]
  combine_source_maps(original_map, second_map)
    # => [{:source=>"index.coffee", :generated => [1, 1], :original => [1, 0]}]

Returns a new Array of source mapping Hashes.

Source | Google | Stack overflow

Edit

git clone [email protected]:rails/sprockets.git

cd sprockets

open lib/sprockets/source_map_utils.rb

Contribute

# Make a new branch

git checkout -b -your-name--update-docs-Sprockets--SourceMapUtils-combine_source_maps-for-pr


# Commit to git

git add lib/sprockets/source_map_utils.rbgit commit -m "better docs for Sprockets::SourceMapUtils#combine_source_maps"


# Open pull request

gem install hub # on a mac you can `brew install hub`

hub fork

git push <your name> -your-name--update-docs-Sprockets--SourceMapUtils-combine_source_maps-for-pr

hub pull-request


# Celebrate!