Coder Social home page Coder Social logo

Comments (11)

abagshaw avatar abagshaw commented on August 28, 2024 1

@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):

  1. Open Brackets and update brackets-minifier to the latest version (v3.0.0). Then go to Help -> Show Extensions Folder.

  2. Go to ./user/brackets-minify/node.

  3. Open minifyjs.js and modify line 7 to use "uglify-es" instead of the original "uglify-js".

  4. 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.

from brackets-minifier.

abagshaw avatar abagshaw commented on August 28, 2024

A few things:

  1. Have you set any directories to exclude?
  2. Can you give me an example of a filename of one of the .js files that isn't being minified?
  3. Can you go to 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).

from brackets-minifier.

onclave avatar onclave commented on August 28, 2024

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.

screen shot 2017-05-28 at 2 21 32 pm

from brackets-minifier.

abagshaw avatar abagshaw commented on August 28, 2024

@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.

from brackets-minifier.

onclave avatar onclave commented on August 28, 2024

@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. :)

from brackets-minifier.

abagshaw avatar abagshaw commented on August 28, 2024

Ok sounds good - I'll try to add ES6 support when I have a chance.

from brackets-minifier.

mblais avatar mblais commented on August 28, 2024

@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 :-\

from brackets-minifier.

abagshaw avatar abagshaw commented on August 28, 2024

@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.

from brackets-minifier.

mblais avatar mblais commented on August 28, 2024

My bad - I had not actually exited Brackets, only reloaded it.

Seems to work now, thanks! :-)

from brackets-minifier.

abagshaw avatar abagshaw commented on August 28, 2024

Great - glad it worked.

from brackets-minifier.

LePreto avatar LePreto commented on August 28, 2024

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<user>\AppData\Roaming\Brackets\extensions\user\brackets-minify\node\

and run:
npm install babel-minify

on your code press: ctrl+alt+M

best regards!

from brackets-minifier.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.