When I generate a source map from minified js back to source files, does the map include the text of the source files, or do I need to host them separately?
The HTML5 Rocks description mentions the sources
key that lists the names of source files, and explains how mappings
maps minified line and column numbers to original line and column numbers, but suggests "You'll also need to upload your original files so the dev tools can reference and display them when necessary".
Browserify's debug
option generates inline source maps that show original files in dev tools without hosting the source files separately.
Does the current source map spec support both?
Most JavaScript and CSS sources are usually minified and source maps serve as a memory map to the compressed files. It's generally a good practice to minify and combine your assets (Javascript & CSS) when deploying to production.
A source map is a file that maps from the transformed source to the original source, enabling the browser to reconstruct the original source and present the reconstructed original in the debugger.
It allows developers to debug transpiled code in developer tools such as Chrome Developer Tools or Firefox Developer Tools by looking at the original source code including the original line numbers, column numbers, function names, and identifiers that may have been changed during minification or transpiling.
Source maps create a map from these compressed asset files back to the source files. This source map allows you to debug and view the source code of your compressed assets, as if you were actually working with the original CSS and Javascript source code.
Source maps can optionally include the original source.
From the spec, sourcesContent
is "An optional list of source content, useful when the “source” can’t be hosted.
source-map (the node module powering browserify source maps) supports sourcesContent
. Coffeeify populates sourcesContent
by default, inlining source text.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With