Closed onclave closed 6 years ago
A few things:
.js
files that isn't being minified?Debug (Top menu bar) -> Show Developer Tools -> Console (Tab at the top)
and see if any errors show up (if so please include them here).Hi,
1: I did exclude 2 directories, namely, /bower_components/
and /node_modules/
.
2: pms.controller.profile.js
, pms.controller.userdetails.js
, pms.controller.administrationdetails.js
are few among the many files that are not being minified. I tried to find a pattern among the file names that are not being minified, but there are none such. For example, pms.controller.administration.js
is getting minified to pms.controller.administration.min.js
, but pms.controller.administrationdetails.js
is not getting minified.
3: I cleared the console. Then I deleted all the minified files and did a minify project
. Upon doing so, this was the output on the console. I am attaching a screenshot of the console output.
Do let me know if you need more information. Thanks.
@onclave I believe the issue is that the files that aren't being minified have some syntax problem. I think the error Unexpected token operator =, expected punc ,
is being emitted because of an error in the syntax of the .js
files in question. The problem is that there is very little debug information (i.e. what line the problem is at in the .js
file being minified). In the future, I may upgrade this plugin to UglifyJS 3
and see if I can build in better debugging features.
For now, can you try to paste the code in pms.controller.administrationdetails.js
to https://jscompress.com/ and see if it is able to compress it properly without any errors? With any luck it'll find an error in the syntax that can be fixed.
It is possible this is a bug with the plugin - but doubtful. If https://jscompress.com/ doesn't find any issues I'll look into the plugin itself further.
@abagshaw so I checked as you asked, and yes the problem is with my js code (kind of). I am using some ES6 specific features in my code, especially default values for parameters in javascript methods. So, I would have to now re-write certain part of my code to use your minifier tool. Anyway, you could close this issue as resolved or mark it as a feature request so that your minifier can be ES6 compatible. Would really love to see the feature. And, thank you, once again, for your awesome minifier. :)
Ok sounds good - I'll try to add ES6 support when I have a chance.
@onclave I've just updated the dependencies for brackets-minifier. Unfortunately it appears that UglifyJS3 does not support ES6 by default.
There's a bit of a roundabout method, however, to get ES6 minification that worked for me (and hopefully works for you):
Open Brackets and update brackets-minifier to the latest version (v3.0.0). Then go to Help -> Show Extensions Folder.
Go to ./user/brackets-minify/node
.
Open minifyjs.js
and modify line 7 to use "uglify-es"
instead of the original "uglify-js"
.
Then open up a command prompt/terminal and navigate to the same folder. Run npm install uglify-es
(you'll need to install npm first if you don't already have it).
Then, after reloading brackets, you should be able to minify your ES6 code. Keep in mind if you do update/re-install brackets-minifier in the future it will overwrite those changes you made.
If UglifyJS brings ES6 support to its main package I'll update it again. Until then I'm going to close this issue.
@abagshaw I tried your method suggested above (and reloaded Brackets), but I still see
Unexpected token name «of», expected punc «;»
on my for ( var v of ... )
statements
So I guess it's manual minification for me :-\
@mblais Odd, when I switch brackets-minifier to use uglify-es I can minify for (var v of ...)
statements just fine.
Are you sure that your minifyjs.js
has require("uglify-es")
and not require("uglify-js")
on this line? And when you say "reloaded Brackets" have you shut it down and re-opened it, or just hit F5/Cmd+R
?
Might not be worth your trouble trying to fix this - but it's odd that it doesn't work.
My bad - I had not actually exited Brackets, only reloaded it.
Seems to work now, thanks! :-)
Great - glad it worked.
To minify ES6 i use Babel minify:
I did the following:
on minifyjs.js: (/brackets-minify/node/minifyjs.js) Add var BabelMinJS = require("babel-minify");
on function minifyJS: minified = BabelMinJS(text, {mangle: {keepClassName: true}}).code;
on CMD navigate to:
C:\Users\
and run: npm install babel-minify
on your code press: ctrl+alt+M
best regards!
Brackets version 1.9 Minifier version 2.0.0
I have a custom path set for my minified JS files at /build. I have close to 60 JS files in my project in the /scripts directory. When I try to
minify project
or simplyminify
, only some of these JS files are minified. The rest of the files are never minified. If I delete the minified JS files and try to re-minify them again, exactly those files are minified again, and some files are ignored every time. If you could help me with the problem, that'd be great.P.S. the minifier extension is awesome, thanks for all the hard work.