sprockets_uglifier_with_source_maps
sprockets_uglifier_with_source_maps copied to clipboard
Support input source maps
Context
We write ES6 and import
npm modules using webpack and https://github.com/shakacode/react_on_rails
This means that we
- write code in es6, and import from
node_modules/
- bundle the code using webpack, creating ES5 files (w/ sourcemaps) in
app/assets/javascripts
- 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
And have this gem add the input source map if it detects the presence of a file with [name].js.map ?
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.