Skip to content

Commit f66f024

Browse files
authored
Merge pull request webpack#3926 from eu81273/webpack-1
Pass mangle options to ast.figure_out_scope in uglify
2 parents b4ab944 + ecad7ff commit f66f024

File tree

4 files changed

+24
-3
lines changed

4 files changed

+24
-3
lines changed

lib/optimize/UglifyJsPlugin.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ UglifyJsPlugin.prototype.apply = function(compiler) {
8888
ast = ast.transform(compress);
8989
}
9090
if(options.mangle !== false) {
91-
ast.figure_out_scope();
91+
ast.figure_out_scope(options.mangle || {});
9292
ast.compute_char_frequency(options.mangle || {});
9393
ast.mangle_names(options.mangle || {});
9494
if(options.mangle && options.mangle.props) {
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
function t(a,b) {
2+
try {
3+
throw a+a;
4+
} catch(x) {
5+
b(x);
6+
}
7+
}
8+
9+
module.exports = t;

test/configCases/plugins/uglifyjs-plugin/index.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,13 @@ it("should contain comments in vendors chunk", function() {
1515
source.should.containEql(" * comment should not be stripped vendors.3");
1616
});
1717

18+
// this test is based off https://github.com/mishoo/UglifyJS2/blob/master/test/compress/screw-ie8.js
19+
it("should pass mangle options", function() {
20+
var fs = require("fs"),
21+
path = require("path");
22+
var source = fs.readFileSync(path.join(__dirname, "ie8.js"), "utf-8");
23+
source.should.containEql("function o(t,r){try{throw t+t}catch(o){r(o)}}");
24+
});
25+
1826

1927
require.include("./test.js");

test/configCases/plugins/uglifyjs-plugin/webpack.config.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,19 @@ module.exports = {
66
},
77
entry: {
88
bundle0: ["./index.js"],
9-
vendors: ["./vendors.js"]
9+
vendors: ["./vendors.js"],
10+
ie8: ["./ie8.js"]
1011
},
1112
output: {
1213
filename: "[name].js"
1314
},
1415
plugins: [
1516
new webpack.optimize.UglifyJsPlugin({
1617
comments: false,
17-
exclude: ["vendors.js"]
18+
exclude: ["vendors.js"],
19+
mangle: {
20+
screw_ie8: false
21+
}
1822
})
1923
]
2024
};

0 commit comments

Comments
 (0)