uglifyjs

SyntaxError: Unexpected token: punc ())

北慕城南 提交于 2019-12-01 22:11:05
I'm recieving: SyntaxError: Unexpected token: punc ()) from UglifyJS and it points to the first letter of global variable API_URL . I have it implemented in this way: export default reduxApi({ campaigns: { url: `${API_URL}/api/v1/whatever`, transformer (response) { if (!response) return {} return response.data } } }).use('fetch', adapterFetch(fetch)).use('options', { headers: getRequestHeaders() }) If I remove global variable under key url : export default reduxApi({ campaigns: { url: `/api/v1/whatever`, transformer (response) { if (!response) return {} return response.data } } }).use('fetch',

Rails 3.1 Possible Bug in Asset Pipeline and Uglifier

跟風遠走 提交于 2019-12-01 19:48:59
I ran into a problem deploying on Heroku do to a failure in the rake task rake assets:precompile At the bottom is the error I get if I integrate Rails 3.1 Jquery calendar: https://github.com/themouette/jquery-week-calendar Twitter bootstrap The error happens from uglifier. I suspect that problem could be related to the inclusion of many localizations for the calendar. I worked around the error by setting: # Compress JavaScripts and CSS config.assets.compress = false I was not able to examine the files as the temporary files are cleaned up. I also could not get the debugger in RubyMine to stop

uglify js error unexpected token eof “undefined”

喜欢而已 提交于 2019-12-01 17:46:14
So I installed npm using npm install uglify-js I run a command which is: cat file1.js file2.js .. fileN.js | uglifyjs -o files.min.js and I get this error: WARN: ERROR: Unexpected token eof «undefined», expected punc «,» [-:630,15] /usr/local/lib/node_modules/uglify-js/lib/parse.js:199 throw new JS_Parse_Error(message, line, col, pos); ^ Error at new JS_Parse_Error (/usr/local/lib/node_modules/uglify-js/lib/parse.js:185:18) at js_error (/usr/local/lib/node_modules/uglify-js/lib/parse.js:199:11) at croak (/usr/local/lib/node_modules/uglify-js/lib/parse.js:630:9) at token_error (/usr/local/lib

How to minify css files with RequireJS

烂漫一生 提交于 2019-12-01 02:58:22
问题 I have a backbone project with several js files and a couple of css files I'd like to have them minified to a single js and a single css So far, I managed to concatenate and minify all my js file to a single main.min.js Now I'm trying to do the same with the css files this is my layout: css bootstrap.css docs.css ... js optimize-node (script to run the optimizer) app main.js (entry point of my app) require-main.js index.html this is my script to minify it # optimize-node node ../../r.js -o

Rails 5 Heroku deploy error: ExecJS::ProgramError: SyntaxError: Unexpected token: name (autoRegisterNamespace)

☆樱花仙子☆ 提交于 2019-12-01 02:32:52
When trying to deploy a rails 5 app to heroku, I get the following error, when it reaches Running: rake assets:precompile : remote: ExecJS::ProgramError: SyntaxError: Unexpected token: name (autoRegisterNamespace) (line: 14767, col: 7, pos: 457487) remote: Error remote: at new JS_Parse_Error (<eval>:3623:11948) remote: at js_error (<eval>:3623:12167) remote: at croak (<eval>:3623:21858) remote: at token_error (<eval>:3623:21995) remote: at unexpected (<eval>:3623:22083) remote: at semicolon (<eval>:3623:22601) remote: at simple_statement (<eval>:3623:25779) remote: at <eval>:3623:23567 remote:

Enumerate regular expressions via UglifyJS

房东的猫 提交于 2019-11-30 20:05:19
I have some JavaScript code, from which I need to find start+end indexes of every literal regular expression. How can such information be extracted from UglifyJS? var uglify = require('uglify-js'); var code = "func(1/2, /hello/);"; var parsed = uglify.parse(code); The structure I'm getting into variable parsed is very complex. And all I need is an array of [{startIdx, endIdx}, {startIdx, endIdx}] of every literal regular expression. P.S. If somebody thinks that the same task can be accomplished in a way that's better than via UglifyJS, you are welcome to suggest! UPDATE I know if I dig deeper

关于js混淆与反混淆还原操作

此生再无相见时 提交于 2019-11-30 05:56:16
使用js的混淆加密,其目的是为了保护我们的前端代码逻辑,对应一些搞技术吃饭的公司来说,为了防止被竞争对手抓取或使用自己的代码,就会考虑如何加密,或者混淆js来达到代码保护。 1、为什么需要js混淆 在web系统发展早期,js在web系统中承担的职责并不多,只是简单的提交表单,js文件非常简单,也不需要任何的保护。 随着js文件体积的增大,为了缩小js体积,加快http传输速度,开始出现了很多对js的压缩工具,比如 uglify、compressor、clouser。。。它们的工作主要是 · 合并多个js文件 · 去除js代码里面的空格和换行 · 压缩js里面的变量名 · 剔除掉注释 压缩后的代码 虽然压缩工具出发点都是为了减少js文件的体积,但是人们发现压缩替换后的代码已经比源代码可读性差了很多,间接起到了代码保护的作用,于是压缩js文件成为了前端发布的标配之一。但是后来市面上主流浏览器chrome、Firefox等都提供了js格式化的功能,能够很快的把压缩后的js美化,再加上现代浏览器强大的debug功能,单纯压缩过的js代码对于真正怀有恶意的人,已经不能起到很好的防御工作,出现了"防君子不防小人"的尴尬局面。 chrome开发者工具格式化之后的代码 而在web应用越来越丰富的今天,伴随着浏览器性能和网速的提高,js承载了更多的工作,不少后端逻辑都在向前端转移

Mangle nested classes and variables with uglifyjs

ε祈祈猫儿з 提交于 2019-11-30 04:56:33
问题 I use uglifyjs to minify a concatenated set of files, which works fine but not good enough. The built lib uses namespaces, so classes, functions and constants are stored in a root namespace variable: (function() { var root = { api:{}, core:{}, names:{} }; /* util.js file */ root.names.SOME_LONG_NAMED_CONST='Angel'; /* Person.js file */ root.core.Person = function(name) { this.name = name }; /* API.js with the functions we want to expose */ root.api.perform = function(param_for_api) { /* do

Enumerate regular expressions via UglifyJS

纵然是瞬间 提交于 2019-11-30 03:58:18
问题 I have some JavaScript code, from which I need to find start+end indexes of every literal regular expression. How can such information be extracted from UglifyJS? var uglify = require('uglify-js'); var code = "func(1/2, /hello/);"; var parsed = uglify.parse(code); The structure I'm getting into variable parsed is very complex. And all I need is an array of [{startIdx, endIdx}, {startIdx, endIdx}] of every literal regular expression. P.S. If somebody thinks that the same task can be

Reverse Uglified Javascript Code

人盡茶涼 提交于 2019-11-30 02:54:41
问题 I am looking for way (preferably and online site) to a reverse Uglify of some javascript. The Website: http://jsbeautifier.org/ is great for minifed code, but it is does not do a great job for ugly stuff. 回答1: There is this awesome online tool, JSNice, that makes a great job of finding names to obfuscated variables. We make even obfuscated JavaScript code readable. We will rename variables and parameters to names that we learn from thousands of open source projects. Furthermore, often we are