Skip to content
This repository has been archived by the owner on Dec 5, 2019. It is now read-only.

Commit

Permalink
fix: disable inline optimization by default
Browse files Browse the repository at this point in the history
  • Loading branch information
evilebottnawi committed Jun 9, 2018
1 parent 3ca5eaf commit 99b1291
Show file tree
Hide file tree
Showing 8 changed files with 466 additions and 410 deletions.
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -164,8 +164,8 @@ Number of concurrent runs.
|**`warnings`**|`{Boolean}`|`false`|Display Warnings|
|**[`parse`](https://github.com/mishoo/UglifyJS2/tree/harmony#parse-options)**|`{Object}`|`{}`|Additional Parse Options|
|**[`compress`](https://github.com/mishoo/UglifyJS2/tree/harmony#compress-options)**|`{Boolean\|Object}`|`true`|Additional Compress Options|
|**[`mangle`](https://github.com/mishoo/UglifyJS2/tree/harmony#mangle-options)**|`{Boolean\|Object}`|`true`|Enable Name Mangling (See [Mangle Properties](https://github.com/mishoo/UglifyJS2/tree/harmony#mangle-properties-options) for advanced setups, use with ⚠️)|
|**[`output`](https://github.com/mishoo/UglifyJS2/tree/harmony#output-options)**|`{Object}`|`{}`|Additional Output Options (The defaults are optimized for best compression)|
|**[`mangle`](https://github.com/mishoo/UglifyJS2/tree/harmony#mangle-options)**|`{Boolean\|Object}`|`{inline: false}`|Enable Name Mangling (See [Mangle Properties](https://github.com/mishoo/UglifyJS2/tree/harmony#mangle-properties-options) for advanced setups, use with ⚠️)|
|**[`output`](https://github.com/mishoo/UglifyJS2/tree/harmony#output-options)**|`{Object}`|`{comments: extractComments ? false : /^\**!|@preserve|@license|@cc_on/,}`|Additional Output Options (The defaults are optimized for best compression)|
|**`toplevel`**|`{Boolean}`|`false`|Enable top level variable and function name mangling and to drop unused variables and functions|
|**`nameCache`**|`{Object}`|`null`|Enable cache of mangled variable and property names across multiple invocations|
|**`ie8`**|`{Boolean}`|`false`|Enable IE8 Support|
Expand Down
3 changes: 3 additions & 0 deletions src/index.js
Expand Up @@ -42,6 +42,9 @@ class UglifyJsPlugin {
include,
exclude,
uglifyOptions: {
compress: {
inline: false,
},
output: {
comments: extractComments ? false : /^\**!|@preserve|@license|@cc_on/,
},
Expand Down
14 changes: 10 additions & 4 deletions src/uglify/minify.js
Expand Up @@ -21,17 +21,23 @@ const buildUglifyOptions = ({
} = {}) => ({
ecma,
warnings,
parse,
compress,
mangle: mangle == null ? true : mangle,
parse: {
...parse,
},
compress: {
...compress,
},
mangle: mangle == null ? true : {
...mangle,
},
output: {
shebang: true,
comments: false,
beautify: false,
semicolons: true,
...output,
},
// Ignoring sourcemap from options
// Ignoring sourceMap from options
sourceMap: null,
toplevel,
nameCache,
Expand Down
59 changes: 29 additions & 30 deletions test/__snapshots__/all-options.test.js.snap
Expand Up @@ -3,54 +3,53 @@
exports[`when applied with all options matches snapshot: errors 1`] = `Array []`;

exports[`when applied with all options matches snapshot: main.0c220ec66316af2c1b24.js 1`] = `
"webpackJsonp([ 0 ], [ function(module, exports) {
module.exports = function() {
"webpackJsonp([ 0 ], [ function(o, n) {
o.exports = function() {
console.log(7);
};
} ], [ 0 ]);"
`;

exports[`when applied with all options matches snapshot: manifest.d6857f782c13a99b5917.js 1`] = `
"!function(modules) {
var parentJsonpFunction = window.webpackJsonp;
window.webpackJsonp = function(chunkIds, moreModules, executeModules) {
for (var moduleId, chunkId, result, i = 0, resolves = []; i < chunkIds.length; i++) chunkId = chunkIds[i],
installedChunks[chunkId] && resolves.push(installedChunks[chunkId][0]), installedChunks[chunkId] = 0;
for (moduleId in moreModules) Object.prototype.hasOwnProperty.call(moreModules, moduleId) && (modules[moduleId] = moreModules[moduleId]);
for (parentJsonpFunction && parentJsonpFunction(chunkIds, moreModules, executeModules); resolves.length; ) resolves.shift()();
if (executeModules) for (i = 0; i < executeModules.length; i++) result = __webpack_require__(__webpack_require__.s = executeModules[i]);
return result;
"!function(r) {
var n = window.webpackJsonp;
window.webpackJsonp = function(e, u, c) {
for (var f, i, p, a = 0, l = []; a < e.length; a++) i = e[a], o[i] && l.push(o[i][0]),
o[i] = 0;
for (f in u) Object.prototype.hasOwnProperty.call(u, f) && (r[f] = u[f]);
for (n && n(e, u, c); l.length; ) l.shift()();
if (c) for (a = 0; a < c.length; a++) p = t(t.s = c[a]);
return p;
};
var installedModules = {}, installedChunks = {
var e = {}, o = {
1: 0
};
function __webpack_require__(moduleId) {
if (installedModules[moduleId]) return installedModules[moduleId].exports;
var module = installedModules[moduleId] = {
i: moduleId,
function t(n) {
if (e[n]) return e[n].exports;
var o = e[n] = {
i: n,
l: !1,
exports: {}
};
return modules[moduleId].call(module.exports, module, module.exports, __webpack_require__),
module.l = !0, module.exports;
return r[n].call(o.exports, o, o.exports, t), o.l = !0, o.exports;
}
__webpack_require__.m = modules, __webpack_require__.c = installedModules, __webpack_require__.d = function(exports, name, getter) {
__webpack_require__.o(exports, name) || Object.defineProperty(exports, name, {
t.m = r, t.c = e, t.d = function(r, n, e) {
t.o(r, n) || Object.defineProperty(r, n, {
configurable: !1,
enumerable: !0,
get: getter
get: e
});
}, __webpack_require__.n = function(module) {
var getter = module && module.__esModule ? function() {
return module.default;
}, t.n = function(r) {
var n = r && r.__esModule ? function() {
return r.default;
} : function() {
return module;
return r;
};
return __webpack_require__.d(getter, \\"a\\", getter), getter;
}, __webpack_require__.o = function(object, property) {
return Object.prototype.hasOwnProperty.call(object, property);
}, __webpack_require__.p = \\"\\", __webpack_require__.oe = function(err) {
throw console.error(err), err;
return t.d(n, \\"a\\", n), n;
}, t.o = function(r, n) {
return Object.prototype.hasOwnProperty.call(r, n);
}, t.p = \\"\\", t.oe = function(r) {
throw console.error(r), r;
};
}([]);"
`;
Expand Down

0 comments on commit 99b1291

Please sign in to comment.