Name remapping support for lambda functions
I'm trying to find a way to get original function names for lambda functions, which currently looks like it's not supported, or I'm not finding the right way to make it work. In order to explain this, I created this simple test that is based on this simple source code:
const SOME_CONST = 3;
function outer() {
const aFunctionAsConst = function() {
console.log("A function as const");
aFunctionAsConst();
};
const aLambdaAsConst = () => {
console.log("A lambda as const");
aLambdaAsConst();
};
function aRegularFunction() {
console.log("A regular function");
aRegularFunction();
}
aFunctionAsConst();
aLambdaAsConst();
aRegularFunction();
}
outer();
And used uglifyjs to generate the minified version and sourcemap:
uglifyjs source.js --compress --mangle --output source.min.js --source-map includeSources
The problem is when trying to get the original function name for (0, 106, "n", "aLambdaAsConst"), .
The reason I think why this doesn't work is because here https://github.com/getsentry/rust-sourcemap/blob/3f32cae8af8594e011b73040762df3ea34c94e01/src/sourceview.rs#L300-L304
we just check for function preceding the token name.. I wonder if const should be included, but I think it's going to cause some false positives.. Any ideas? Am I doing something wrong here?
I found it interesting that I saw some cases in sentry where the actual function name gets correctly translated in these cases, so maybe I'm just missing something here. e.g. here renderPath is picked up from a lambda const: