sprockets_uglifier_with_source_maps icon indicating copy to clipboard operation
sprockets_uglifier_with_source_maps copied to clipboard

Support input source maps

Open yinghaochan opened this issue 7 years ago • 1 comments

Context

We write ES6 and import npm modules using webpack and https://github.com/shakacode/react_on_rails

This means that we

  1. write code in es6, and import from node_modules/
  2. bundle the code using webpack, creating ES5 files (w/ sourcemaps) in app/assets/javascripts
  3. sprockets then fingerprints and uglifies these ES5 files during the compile step.

However, the initial source maps generated by webpack for the ES5 code don't get parsed and therefore the uglified version contains source maps only to the bundled ES5 code, not to the original ES6 code.

Suggestion

https://github.com/lautis/uglifier/blob/master/spec/source_map_spec.rb#L97 allows for an input source map file (but doesn't seem to support inlined source maps).

So would it be possible to create these ES5 and map files in app/assets/javascripts

image

And have this gem add the input source map if it detects the presence of a file with [name].js.map ?

yinghaochan avatar Mar 01 '17 08:03 yinghaochan

https://github.com/AlexanderPavlenko/sprockets_uglifier_with_source_maps/blob/master/lib/sprockets_uglifier_with_source_maps/compressor.rb#L20 Currently input source maps are not handled. Pull Request welcome.

AlexanderPavlenko avatar Mar 01 '17 09:03 AlexanderPavlenko