Skip to content

Commit 472fcf8

Browse files
committed
Update to Uglify Harmony 2.8.22 and add support Babili fallback.
This is the same behavior of the official `minifier-js` package, except with the Harmony branch.
1 parent de2dbda commit 472fcf8

File tree

4 files changed

+39
-69
lines changed

4 files changed

+39
-69
lines changed

.npm/package/npm-shrinkwrap.json

+6-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

minifier.js

+25-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,25 @@
1-
UglifyJS = Npm.require('uglify-js');
2-
UglifyJSMinify = UglifyJS.minify;
1+
var uglify;
2+
3+
meteorJsMinify = function (source) {
4+
var result = {};
5+
uglify = uglify || Npm.require("uglify-js");
6+
7+
try {
8+
result.code = uglify.minify(source, {
9+
fromString: true,
10+
compress: {
11+
drop_debugger: false,
12+
unused: false,
13+
dead_code: false
14+
}
15+
}).code;
16+
17+
} catch (e) {
18+
// Although Babel.minify can handle a wider variety of ECMAScript
19+
// 2015+ syntax, it is substantially slower than UglifyJS, so we use
20+
// it only as a fallback.
21+
result.code = Babel.minify(source).code;
22+
}
23+
24+
return result;
25+
};

package.js

+4-16
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,16 @@
11
Package.describe({
22
name: 'abernix:minifier-js',
33
summary: "JavaScript minifier",
4-
version: "1.3.19"
4+
version: "2.0.0"
55
});
66

77
Npm.depends({
88
"source-map": "0.5.6",
9-
"uglify-js": "git+https://github.com/mishoo/UglifyJS2#harmony-v2.8.15",
10-
});
11-
12-
Npm.strip({
13-
"uglify-js": ["test/"]
9+
"uglify-js": "git+https://github.com/mishoo/UglifyJS2#harmony-v2.8.22",
1410
});
1511

1612
Package.onUse(function (api) {
17-
api.export(['UglifyJSMinify', 'UglifyJS']);
13+
api.use('[email protected]');
14+
api.export(['meteorJsMinify']);
1815
api.addFiles(['minifier.js'], 'server');
1916
});
20-
21-
Package.onTest(function (api) {
22-
api.use('abernix:minifier-js', 'server');
23-
api.use('tinytest');
24-
25-
api.addFiles([
26-
'beautify-tests.js',
27-
], 'server');
28-
});

0 commit comments

Comments
 (0)