hughsk / uglifyify

A browserify transform which minifies your code using UglifyJS2
Other
375 stars 61 forks source link

uglifyify is dropping a file #40

Open tolmasky opened 9 years ago

tolmasky commented 9 years ago

index.js:

require("babel-core/lib/generation")

browserify.js:

var gulp = require("gulp");

var browserify = require("browserify");
var source = require('vinyl-source-stream');
var gulp = require("gulp");

    var bundle = browserify({
        entries: ["./index.js"],
        debug: true,
        cache: {},
        packageCache: {},
        fullPaths: true
    })

   // If I comment out uglifyif then it works again.
    bundle = bundle.transform('uglifyify', { global: true });

    return bundle.bundle()
                 .pipe(source("main.bundle.js"))
                 .pipe(gulp.dest("./assets"));

Running node browserify.js breaks because node_modules/babel-core/node_modules/source-map/lib/base64-vlq.js disappears.

tolmasky commented 9 years ago

Heres the project if you're interested: http://tolmasky.com/letmeshowyou/uglifyify-bug.zip

tolmasky commented 9 years ago

Further inspection shows that it is mangle:true that is causing it (mangle:false leaves the file alone).

tolmasky commented 9 years ago

I figured this out. The file in question does this:

(function (require)
{
})(require)

Thus, the require is mangled in the function, and then not gotten. By blacklisting "Require" to never be mangled it solves this. However, given that this was something that took place in a dependency's dependency (and of a popular package), I think blacklisting "require" should maybe be the default behavior. OR, its possible that this is broken in that it should first grab dependencies then mangle.