I have a few small Javascript files for a website. At this moment, I use script to put them in a file and then run terser to minimize it. With the minimized version, the website runs without any problem.
Now I would like to obfuscate it with JavaScript-Obfuscator (https://obfuscator.io/). I created a gulp task to generate the obfuscated version
gulp.task('obfus', function() {
gulp.src('src/main/webapp/js/mysite.min.js')
.pipe(javascriptObfuscator({
compact: true
})).pipe(gulp.dest('src/main/webapp/js/dist'));
});
However, I got this error when running the website:
Uncaught ReferenceError: loc is not defined
at eval (eval at exampledomain.<computed> (mysite.min.js?:1:71178), <anonymous>:1:39)
Here is the line of code where the error happens:
eval('exampledomain.build' + type + '(loc)');
I need to use "eval" to call different functions based on "type".
How to fix this problem?