Environment
sentry-cli version 2.28.6; Mac OS X and Ubuntu
Steps to Reproduce
Say you have a JavaScript file like the following that has a multi-line template literal:
input.js
var MyElement = class extends LitElement {
constructor() {
super(...arguments);
this.isInitialized = true;
}
render() {
return x`
<div>
<h1>My Element</h1>
</div>
`;
}
};
export {
MyElement
};
Then suppose you compress this using something like uglifyjs input.js -c -m --source-map "filename='bundle.js.map'" -o bundle.js, producing a minified script file and a source map. Importantly, you don't want to include a sourceMappingURL in the resulting JavaScript file because you do not plan to publish the map publicly and will only be uploading it to Sentry:
bundle.js
var MyElement=class extends LitElement{constructor(){super(...arguments),this.isInitialized=!0}render(){return x`
<div>
<h1>My Element</h1>
</div>
`}};export{MyElement};
bundle.js.map
{"version":3,"file":"bundle.js.map","sources":["input.js"],"names":["MyElement","LitElement","constructor","super","arguments","this","isInitialized","render","x"],"mappings":"AAAA,IAAIA,wBAA0BC,WAC1BC,cACEC,MAAM,GAAGC,SAAS,EAClBC,KAAKC,cAAgB,CAAA,CACvB,CACAC,SACE,OAAOC;;;;OAKT,CACF,SAGCR,SACF"}
Assuming this is your minified code, you then want to run sentry-cli sourcemaps inject . to inject Debug Ids into both files to prepare them for upload to Sentry.
Expected Result
The sentry-cli tool would identify bundle.js as minified code and bundle.js.map as the corresponding source map and add debug IDs to them.
Actual Result
Neither of the files is identified as a target for adding IDs. This is most likely because the is_likely_minified_js function cannot rely on the existence of a sourceMappingURL comment and the might_be_minified library being used as a backup cannot handle a resulting minified file like this.
Logs
sentry-cli sourcemaps inject ./dist --log-level=debug
DEBUG 2024-02-21 20:21:09.563336 -08:00 sentry-cli version: 2.28.6, platform: "darwin", architecture: "arm64"
INFO 2024-02-21 20:21:09.564783 -08:00 sentry-cli was invoked with the following command line: "sentry-cli" "sourcemaps" "inject" "./dist" "--log-level=debug"
> Searching ./dist
DEBUG 2024-02-21 20:21:09.567314 -08:00 built glob set; 0 literals, 0 basenames, 0 extensions, 0 prefixes, 0 suffixes, 4 required extensions, 0 regexes (from globset)
DEBUG 2024-02-21 20:21:09.568366 -08:00 glob converted to regex: Glob { glob: "**/*~", re: "(?-u)^(?:/?|.*/)[^/]*\\~$", opts: GlobOptions { case_insensitive: false, literal_separator: true, backslash_escape: true }, tokens: Tokens([RecursivePrefix, ZeroOrMore, Literal('~')]) } (from globset)
DEBUG 2024-02-21 20:21:09.568405 -08:00 built glob set; 0 literals, 1 basenames, 0 extensions, 0 prefixes, 0 suffixes, 0 required extensions, 1 regexes (from globset)
DEBUG 2024-02-21 20:21:09.568586 -08:00 whitelisting ./dist/bundle.js.map: Whitelist(IgnoreMatch(Types(Glob(Matched { def: FileTypeDef { name: "map", globs: ["*.map"] } })))) (from ignore)
INFO 2024-02-21 20:21:09.568615 -08:00 found: ./dist/bundle.js.map (296 bytes)
DEBUG 2024-02-21 20:21:09.568826 -08:00 whitelisting ./dist/bundle.js: Whitelist(IgnoreMatch(Types(Glob(Matched { def: FileTypeDef { name: "js", globs: ["*.js"] } })))) (from ignore)
INFO 2024-02-21 20:21:09.568851 -08:00 found: ./dist/bundle.js (203 bytes)
> Found 2 files
> Analyzing 2 sources
> Analyzing completed in 0.012s
> Injecting debug ids
> Nothing to inject
INFO 2024-02-21 20:21:09.582876 -08:00 Skipping update nagger update check
Environment
sentry-cliversion2.28.6; Mac OS X and UbuntuSteps to Reproduce
Say you have a JavaScript file like the following that has a multi-line template literal:
input.js
Then suppose you compress this using something like
uglifyjs input.js -c -m --source-map "filename='bundle.js.map'" -o bundle.js, producing a minified script file and a source map. Importantly, you don't want to include asourceMappingURLin the resulting JavaScript file because you do not plan to publish the map publicly and will only be uploading it to Sentry:bundle.js
bundle.js.map
Assuming this is your minified code, you then want to run
sentry-cli sourcemaps inject .to inject Debug Ids into both files to prepare them for upload to Sentry.Expected Result
The
sentry-clitool would identifybundle.jsas minified code andbundle.js.mapas the corresponding source map and add debug IDs to them.Actual Result
Neither of the files is identified as a target for adding IDs. This is most likely because the
is_likely_minified_jsfunction cannot rely on the existence of asourceMappingURLcomment and themight_be_minifiedlibrary being used as a backup cannot handle a resulting minified file like this.Logs