lautis / uglifier

Ruby wrapper for UglifyJS JavaScript compressor.
http://www.rubydoc.info/gems/uglifier
MIT License
613 stars 82 forks source link

Can't uglify dhtmlxgrid_pro.js #32

Closed crawlik closed 12 years ago

crawlik commented 12 years ago

Guys, Please take a look at this post http://forum.dhtmlx.com/viewtopic.php?f=2&t=24298 and let me know if there is a way to work around the problem. Thanks a lot.

lautis commented 12 years ago

It looks like UglifyJS can't parse the file for some reason. Could be a bug in UglifyJS or the JS is somehow slightly broken. I don't have the source code so I don't have any idea how to solve this. The free version works fine.

It'd help if you could extract a minimal offending example.

crawlik commented 12 years ago

Looks like that is the one. It reproduces exactly the same error. Removing debugger; line eliminates the error. Don't know exactly what this line is for. Looks like debugging leftover to me.

dhtmlXGridObject.prototype.splitAt = function (a) {
    this._fake.doColResize = function (b, c, d, e, f) {
        debugger;
        var k = -1,
            g = 0;
        if (arguments[1]._cellIndex == a - 1) {
            k = this._initalSplR + (b.clientX - e);
            if (!this._initalSplF) this._initalSplF = arguments[3] + this.objBox.scrollWidth - this.objBox.offsetWidth;
            if (this.objBox.scrollWidth == this.objBox.offsetWidth && (this._fake.alter_split_resize || b.clientX - e > 0)) arguments[3] = this._initalSplF || arguments[3]
        } else if (this.obj.offsetWidth < this.entBox.offsetWidth) k = this.obj.offsetWidth;
        g = this.doColResizeA.apply(this, arguments);
        this._correctSplit(k);
        this.resized = this._fake.resized = 1;
        return g
    };
};
lautis commented 12 years ago

Ah yes, debugger. It's fixed in UglifyJS master, but the released version doesn't seem to have it. It'll be fixed in uglifier when UglifyJS does a release.

crawlik commented 12 years ago

Yeah... just pulled UglifyJS master and tried to uglify code with debugger. It worked. @lautis, I am kind of confused. Why we need UglifyJS release? As far as I understand uglifier build just pulls latest from UglifyJS master and packages in into gem. So I am wondering why uglifier build won't solve this problem? Last uglifier release was done on March 27, 2012 basically two week before 'debugger' issue was merged into master.

lautis commented 12 years ago

Of course, I could create a new version of uglifier based on trunk. I just feel more comfortable when using released version instead of whatever happened to be in master when I made the release.

I could update the the uglifyjs code here at master branch and then the brave ones could use that version with git dependency in their Gemfiles.

crawlik commented 12 years ago

it will work :)

crawlik commented 12 years ago

@lautis, one more question just to feed my curiosity. What is the process to generate uglify.js?

lautis commented 12 years ago

Master is now updated. Uglifier has uglifyjs as git submodule. Javascript source can be packaged with node build.

crawlik commented 12 years ago

Thanks. Worked for me. JavaScript got compressed. Noticed that compression uses a lot of computing power. System Load Average was around ~20.