Improve detection of minified source files
The code that determines if a source file that has been added to a SourceMapProcessor is minified is here. It checks
- if the file name contains the substring ".min."
- if the file contains a debug id or source mapping URL
- a bunch of heuristics based on code shape and whatnot.
Another reason to consider a file minified might be if it has a sourcemap in the "obvious" location (i.e. a sibling file with same file name, but the extension .map). We already have logic for finding such a sourcemap in the form of the guess_sourcemap_reference function, but that function refers to the SourceMapProcessor's internal list of sourcemaps—something we can't rely on until we're finished with adding files.
I think we might want to talk to the web folks to see what common filename patterns they see too. For instance chunk is a pretty common indicator now that something is transpiled.
IMO flagging everything that has a corresponding source map as "minified" is a good idea. The name "minified" is a bit misleading, as it does not need to be "minified" at all, it just has to be a file that has a sourcemap because it was created from a different source file.
We also have files like this: https://github.com/getsentry/sentry-cli/blob/master/tests/integration/_fixtures/inject/server/chunks/flight-server-css-manifest.js, which looks minified at a glance, having only a single long line. Is this a false negative in our detection?
It is a single line, but it's too close looking to a legit code.
module.exports = { MAX_RETRIES: 5, BASE_URL: 'http://sentry.io' }
Heuristics look at things like line length, short variable names etc., end this file simply has none of those - https://docs.rs/might-be-minified/0.3.0/src/might_be_minified/lib.rs.html#221-232
This issue has gone three weeks without activity. In another week, I will close it.
But! If you comment or otherwise update it, I will reset the clock, and if you label it Status: Backlog or Status: In Progress, I will leave it alone ... forever!
"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀
#1958 eliminates the distinction between minified and non-minified files at the location linked in the original comment (which we use for sourcemaps inject and sourcemaps upload).
So, I am going to close this issue for now.