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

Commit bbe0ef5

Browse files
evilebottnawijoshwiens
authored andcommittedNov 19, 2017
feat: include option (#167)
1 parent 2c06f46 commit bbe0ef5

File tree

7 files changed

+462
-7
lines changed

7 files changed

+462
-7
lines changed
 

‎src/index.js

+2
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class UglifyJsPlugin {
3131
sourceMap = false,
3232
cache = false,
3333
parallel = false,
34+
include,
3435
exclude,
3536
} = options;
3637

@@ -41,6 +42,7 @@ class UglifyJsPlugin {
4142
sourceMap,
4243
cache,
4344
parallel,
45+
include,
4446
exclude,
4547
uglifyOptions: {
4648
output: {

‎test/__snapshots__/exclude-option.test.js.snap

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3+
exports[`entry.a3533847fa24ef98733c.js 1`] = `"webpackJsonp([2],{2:function(o,n){o.exports=function(){console.log(7)}}},[2]);"`;
4+
5+
exports[`entry.a3533847fa24ef98733c.js 2`] = `"webpackJsonp([2],{2:function(o,n){o.exports=function(){console.log(7)}}},[2]);"`;
6+
37
exports[`errors 1`] = `Array []`;
48

59
exports[`errors 2`] = `Array []`;
@@ -49,13 +53,9 @@ module.exports = function Bar2() {
4953
],[1]);"
5054
`;
5155

52-
exports[`included.97bcf4abdd9efecc94b3.js 1`] = `"webpackJsonp([2],{2:function(o,n){o.exports=function(){console.log(7)}}},[2]);"`;
53-
54-
exports[`included.97bcf4abdd9efecc94b3.js 2`] = `"webpackJsonp([2],{2:function(o,n){o.exports=function(){console.log(7)}}},[2]);"`;
55-
56-
exports[`manifest.2264c6ca1c158d5cd90e.js 1`] = `"!function(e){function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}var r=window.webpackJsonp;window.webpackJsonp=function(t,c,a){for(var u,i,f,l=0,d=[];l<t.length;l++)i=t[l],o[i]&&d.push(o[i][0]),o[i]=0;for(u in c)Object.prototype.hasOwnProperty.call(c,u)&&(e[u]=c[u]);for(r&&r(t,c,a);d.length;)d.shift()();if(a)for(l=0;l<a.length;l++)f=n(n.s=a[l]);return f};var t={},o={3:0};n.e=function(e){function r(){u.onerror=u.onload=null,clearTimeout(i);var n=o[e];0!==n&&(n&&n[1](new Error(\\"Loading chunk \\"+e+\\" failed.\\")),o[e]=void 0)}var t=o[e];if(0===t)return new Promise(function(e){e()});if(t)return t[2];var c=new Promise(function(n,r){t=o[e]=[n,r]});t[2]=c;var a=document.getElementsByTagName(\\"head\\")[0],u=document.createElement(\\"script\\");u.type=\\"text/javascript\\",u.charset=\\"utf-8\\",u.async=!0,u.timeout=12e4,n.nc&&u.setAttribute(\\"nonce\\",n.nc),u.src=n.p+\\"\\"+e+\\".\\"+({0:\\"excluded2\\",1:\\"excluded1\\",2:\\"included\\"}[e]||e)+\\".\\"+{0:\\"a96f544a34079b25c7b4\\",1:\\"4d3a1b43eccbc2acc9d6\\",2:\\"97bcf4abdd9efecc94b3\\"}[e]+\\".js\\";var i=setTimeout(r,12e4);return u.onerror=u.onload=r,a.appendChild(u),c},n.m=e,n.c=t,n.d=function(e,r,t){n.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:t})},n.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(r,\\"a\\",r),r},n.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},n.p=\\"\\",n.oe=function(e){throw console.error(e),e}}([]);"`;
56+
exports[`manifest.70d0d238a960e43f4454.js 1`] = `"!function(e){function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}var r=window.webpackJsonp;window.webpackJsonp=function(t,c,a){for(var u,i,f,l=0,s=[];l<t.length;l++)i=t[l],o[i]&&s.push(o[i][0]),o[i]=0;for(u in c)Object.prototype.hasOwnProperty.call(c,u)&&(e[u]=c[u]);for(r&&r(t,c,a);s.length;)s.shift()();if(a)for(l=0;l<a.length;l++)f=n(n.s=a[l]);return f};var t={},o={3:0};n.e=function(e){function r(){u.onerror=u.onload=null,clearTimeout(i);var n=o[e];0!==n&&(n&&n[1](new Error(\\"Loading chunk \\"+e+\\" failed.\\")),o[e]=void 0)}var t=o[e];if(0===t)return new Promise(function(e){e()});if(t)return t[2];var c=new Promise(function(n,r){t=o[e]=[n,r]});t[2]=c;var a=document.getElementsByTagName(\\"head\\")[0],u=document.createElement(\\"script\\");u.type=\\"text/javascript\\",u.charset=\\"utf-8\\",u.async=!0,u.timeout=12e4,n.nc&&u.setAttribute(\\"nonce\\",n.nc),u.src=n.p+\\"\\"+e+\\".\\"+({0:\\"excluded2\\",1:\\"excluded1\\",2:\\"entry\\"}[e]||e)+\\".\\"+{0:\\"a96f544a34079b25c7b4\\",1:\\"4d3a1b43eccbc2acc9d6\\",2:\\"a3533847fa24ef98733c\\"}[e]+\\".js\\";var i=setTimeout(r,12e4);return u.onerror=u.onload=r,a.appendChild(u),c},n.m=e,n.c=t,n.d=function(e,r,t){n.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:t})},n.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(r,\\"a\\",r),r},n.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},n.p=\\"\\",n.oe=function(e){throw console.error(e),e}}([]);"`;
5757

58-
exports[`manifest.2264c6ca1c158d5cd90e.js 2`] = `"!function(e){function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}var r=window.webpackJsonp;window.webpackJsonp=function(t,c,a){for(var u,i,f,l=0,d=[];l<t.length;l++)i=t[l],o[i]&&d.push(o[i][0]),o[i]=0;for(u in c)Object.prototype.hasOwnProperty.call(c,u)&&(e[u]=c[u]);for(r&&r(t,c,a);d.length;)d.shift()();if(a)for(l=0;l<a.length;l++)f=n(n.s=a[l]);return f};var t={},o={3:0};n.e=function(e){function r(){u.onerror=u.onload=null,clearTimeout(i);var n=o[e];0!==n&&(n&&n[1](new Error(\\"Loading chunk \\"+e+\\" failed.\\")),o[e]=void 0)}var t=o[e];if(0===t)return new Promise(function(e){e()});if(t)return t[2];var c=new Promise(function(n,r){t=o[e]=[n,r]});t[2]=c;var a=document.getElementsByTagName(\\"head\\")[0],u=document.createElement(\\"script\\");u.type=\\"text/javascript\\",u.charset=\\"utf-8\\",u.async=!0,u.timeout=12e4,n.nc&&u.setAttribute(\\"nonce\\",n.nc),u.src=n.p+\\"\\"+e+\\".\\"+({0:\\"excluded2\\",1:\\"excluded1\\",2:\\"included\\"}[e]||e)+\\".\\"+{0:\\"a96f544a34079b25c7b4\\",1:\\"4d3a1b43eccbc2acc9d6\\",2:\\"97bcf4abdd9efecc94b3\\"}[e]+\\".js\\";var i=setTimeout(r,12e4);return u.onerror=u.onload=r,a.appendChild(u),c},n.m=e,n.c=t,n.d=function(e,r,t){n.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:t})},n.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(r,\\"a\\",r),r},n.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},n.p=\\"\\",n.oe=function(e){throw console.error(e),e}}([]);"`;
58+
exports[`manifest.70d0d238a960e43f4454.js 2`] = `"!function(e){function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}var r=window.webpackJsonp;window.webpackJsonp=function(t,c,a){for(var u,i,f,l=0,s=[];l<t.length;l++)i=t[l],o[i]&&s.push(o[i][0]),o[i]=0;for(u in c)Object.prototype.hasOwnProperty.call(c,u)&&(e[u]=c[u]);for(r&&r(t,c,a);s.length;)s.shift()();if(a)for(l=0;l<a.length;l++)f=n(n.s=a[l]);return f};var t={},o={3:0};n.e=function(e){function r(){u.onerror=u.onload=null,clearTimeout(i);var n=o[e];0!==n&&(n&&n[1](new Error(\\"Loading chunk \\"+e+\\" failed.\\")),o[e]=void 0)}var t=o[e];if(0===t)return new Promise(function(e){e()});if(t)return t[2];var c=new Promise(function(n,r){t=o[e]=[n,r]});t[2]=c;var a=document.getElementsByTagName(\\"head\\")[0],u=document.createElement(\\"script\\");u.type=\\"text/javascript\\",u.charset=\\"utf-8\\",u.async=!0,u.timeout=12e4,n.nc&&u.setAttribute(\\"nonce\\",n.nc),u.src=n.p+\\"\\"+e+\\".\\"+({0:\\"excluded2\\",1:\\"excluded1\\",2:\\"entry\\"}[e]||e)+\\".\\"+{0:\\"a96f544a34079b25c7b4\\",1:\\"4d3a1b43eccbc2acc9d6\\",2:\\"a3533847fa24ef98733c\\"}[e]+\\".js\\";var i=setTimeout(r,12e4);return u.onerror=u.onload=r,a.appendChild(u),c},n.m=e,n.c=t,n.d=function(e,r,t){n.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:t})},n.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(r,\\"a\\",r),r},n.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},n.p=\\"\\",n.oe=function(e){throw console.error(e),e}}([]);"`;
5959

6060
exports[`warnings 1`] = `Array []`;
6161

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,381 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`entry.a3533847fa24ef98733c.js 1`] = `
4+
"webpackJsonp([2],{
5+
6+
/***/ 2:
7+
/***/ (function(module, exports) {
8+
9+
// foo
10+
/* @preserve*/
11+
// bar
12+
const a = 2 + 2;
13+
14+
module.exports = function Foo() {
15+
const b = 2 + 2;
16+
console.log(b + 1 + 2);
17+
};
18+
19+
20+
/***/ })
21+
22+
},[2]);"
23+
`;
24+
25+
exports[`entry.a3533847fa24ef98733c.js 2`] = `
26+
"webpackJsonp([2],{
27+
28+
/***/ 2:
29+
/***/ (function(module, exports) {
30+
31+
// foo
32+
/* @preserve*/
33+
// bar
34+
const a = 2 + 2;
35+
36+
module.exports = function Foo() {
37+
const b = 2 + 2;
38+
console.log(b + 1 + 2);
39+
};
40+
41+
42+
/***/ })
43+
44+
},[2]);"
45+
`;
46+
47+
exports[`errors 1`] = `Array []`;
48+
49+
exports[`errors 2`] = `Array []`;
50+
51+
exports[`included1.3c000166b4174c9cb9a0.js 1`] = `"webpackJsonp([1],[function(o,n){o.exports=function(){console.log(7)}}],[0]);"`;
52+
53+
exports[`included1.3c000166b4174c9cb9a0.js 2`] = `"webpackJsonp([1],[function(o,n){o.exports=function(){console.log(7)}}],[0]);"`;
54+
55+
exports[`included2.110cfb201ee67fa7a412.js 1`] = `
56+
"webpackJsonp([0],[
57+
/* 0 */,
58+
/* 1 */
59+
/***/ (function(module, exports) {
60+
61+
module.exports = function Bar2() {
62+
const b = 2 + 2;
63+
console.log(b + 1 + 2);
64+
};
65+
66+
67+
/***/ })
68+
],[1]);"
69+
`;
70+
71+
exports[`included2.110cfb201ee67fa7a412.js 2`] = `"webpackJsonp([0],[,function(o,n){o.exports=function(){console.log(7)}}],[1]);"`;
72+
73+
exports[`manifest.fb0c1ba6a18ef6f513dc.js 1`] = `
74+
"/******/ (function(modules) { // webpackBootstrap
75+
/******/ // install a JSONP callback for chunk loading
76+
/******/ var parentJsonpFunction = window[\\"webpackJsonp\\"];
77+
/******/ window[\\"webpackJsonp\\"] = function webpackJsonpCallback(chunkIds, moreModules, executeModules) {
78+
/******/ // add \\"moreModules\\" to the modules object,
79+
/******/ // then flag all \\"chunkIds\\" as loaded and fire callback
80+
/******/ var moduleId, chunkId, i = 0, resolves = [], result;
81+
/******/ for(;i < chunkIds.length; i++) {
82+
/******/ chunkId = chunkIds[i];
83+
/******/ if(installedChunks[chunkId]) {
84+
/******/ resolves.push(installedChunks[chunkId][0]);
85+
/******/ }
86+
/******/ installedChunks[chunkId] = 0;
87+
/******/ }
88+
/******/ for(moduleId in moreModules) {
89+
/******/ if(Object.prototype.hasOwnProperty.call(moreModules, moduleId)) {
90+
/******/ modules[moduleId] = moreModules[moduleId];
91+
/******/ }
92+
/******/ }
93+
/******/ if(parentJsonpFunction) parentJsonpFunction(chunkIds, moreModules, executeModules);
94+
/******/ while(resolves.length) {
95+
/******/ resolves.shift()();
96+
/******/ }
97+
/******/ if(executeModules) {
98+
/******/ for(i=0; i < executeModules.length; i++) {
99+
/******/ result = __webpack_require__(__webpack_require__.s = executeModules[i]);
100+
/******/ }
101+
/******/ }
102+
/******/ return result;
103+
/******/ };
104+
/******/
105+
/******/ // The module cache
106+
/******/ var installedModules = {};
107+
/******/
108+
/******/ // objects to store loaded and loading chunks
109+
/******/ var installedChunks = {
110+
/******/ 3: 0
111+
/******/ };
112+
/******/
113+
/******/ // The require function
114+
/******/ function __webpack_require__(moduleId) {
115+
/******/
116+
/******/ // Check if module is in cache
117+
/******/ if(installedModules[moduleId]) {
118+
/******/ return installedModules[moduleId].exports;
119+
/******/ }
120+
/******/ // Create a new module (and put it into the cache)
121+
/******/ var module = installedModules[moduleId] = {
122+
/******/ i: moduleId,
123+
/******/ l: false,
124+
/******/ exports: {}
125+
/******/ };
126+
/******/
127+
/******/ // Execute the module function
128+
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
129+
/******/
130+
/******/ // Flag the module as loaded
131+
/******/ module.l = true;
132+
/******/
133+
/******/ // Return the exports of the module
134+
/******/ return module.exports;
135+
/******/ }
136+
/******/
137+
/******/ // This file contains only the entry chunk.
138+
/******/ // The chunk loading function for additional chunks
139+
/******/ __webpack_require__.e = function requireEnsure(chunkId) {
140+
/******/ var installedChunkData = installedChunks[chunkId];
141+
/******/ if(installedChunkData === 0) {
142+
/******/ return new Promise(function(resolve) { resolve(); });
143+
/******/ }
144+
/******/
145+
/******/ // a Promise means \\"currently loading\\".
146+
/******/ if(installedChunkData) {
147+
/******/ return installedChunkData[2];
148+
/******/ }
149+
/******/
150+
/******/ // setup Promise in chunk cache
151+
/******/ var promise = new Promise(function(resolve, reject) {
152+
/******/ installedChunkData = installedChunks[chunkId] = [resolve, reject];
153+
/******/ });
154+
/******/ installedChunkData[2] = promise;
155+
/******/
156+
/******/ // start chunk loading
157+
/******/ var head = document.getElementsByTagName('head')[0];
158+
/******/ var script = document.createElement('script');
159+
/******/ script.type = 'text/javascript';
160+
/******/ script.charset = 'utf-8';
161+
/******/ script.async = true;
162+
/******/ script.timeout = 120000;
163+
/******/
164+
/******/ if (__webpack_require__.nc) {
165+
/******/ script.setAttribute(\\"nonce\\", __webpack_require__.nc);
166+
/******/ }
167+
/******/ script.src = __webpack_require__.p + \\"\\" + chunkId + \\".\\" + ({\\"0\\":\\"included2\\",\\"1\\":\\"included1\\",\\"2\\":\\"entry\\"}[chunkId]||chunkId) + \\".\\" + {\\"0\\":\\"110cfb201ee67fa7a412\\",\\"1\\":\\"3c000166b4174c9cb9a0\\",\\"2\\":\\"a3533847fa24ef98733c\\"}[chunkId] + \\".js\\";
168+
/******/ var timeout = setTimeout(onScriptComplete, 120000);
169+
/******/ script.onerror = script.onload = onScriptComplete;
170+
/******/ function onScriptComplete() {
171+
/******/ // avoid mem leaks in IE.
172+
/******/ script.onerror = script.onload = null;
173+
/******/ clearTimeout(timeout);
174+
/******/ var chunk = installedChunks[chunkId];
175+
/******/ if(chunk !== 0) {
176+
/******/ if(chunk) {
177+
/******/ chunk[1](new Error('Loading chunk ' + chunkId + ' failed.'));
178+
/******/ }
179+
/******/ installedChunks[chunkId] = undefined;
180+
/******/ }
181+
/******/ };
182+
/******/ head.appendChild(script);
183+
/******/
184+
/******/ return promise;
185+
/******/ };
186+
/******/
187+
/******/ // expose the modules object (__webpack_modules__)
188+
/******/ __webpack_require__.m = modules;
189+
/******/
190+
/******/ // expose the module cache
191+
/******/ __webpack_require__.c = installedModules;
192+
/******/
193+
/******/ // define getter function for harmony exports
194+
/******/ __webpack_require__.d = function(exports, name, getter) {
195+
/******/ if(!__webpack_require__.o(exports, name)) {
196+
/******/ Object.defineProperty(exports, name, {
197+
/******/ configurable: false,
198+
/******/ enumerable: true,
199+
/******/ get: getter
200+
/******/ });
201+
/******/ }
202+
/******/ };
203+
/******/
204+
/******/ // getDefaultExport function for compatibility with non-harmony modules
205+
/******/ __webpack_require__.n = function(module) {
206+
/******/ var getter = module && module.__esModule ?
207+
/******/ function getDefault() { return module['default']; } :
208+
/******/ function getModuleExports() { return module; };
209+
/******/ __webpack_require__.d(getter, 'a', getter);
210+
/******/ return getter;
211+
/******/ };
212+
/******/
213+
/******/ // Object.prototype.hasOwnProperty.call
214+
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
215+
/******/
216+
/******/ // __webpack_public_path__
217+
/******/ __webpack_require__.p = \\"\\";
218+
/******/
219+
/******/ // on error function for async loading
220+
/******/ __webpack_require__.oe = function(err) { console.error(err); throw err; };
221+
/******/ })
222+
/************************************************************************/
223+
/******/ ([]);"
224+
`;
225+
226+
exports[`manifest.fb0c1ba6a18ef6f513dc.js 2`] = `
227+
"/******/ (function(modules) { // webpackBootstrap
228+
/******/ // install a JSONP callback for chunk loading
229+
/******/ var parentJsonpFunction = window[\\"webpackJsonp\\"];
230+
/******/ window[\\"webpackJsonp\\"] = function webpackJsonpCallback(chunkIds, moreModules, executeModules) {
231+
/******/ // add \\"moreModules\\" to the modules object,
232+
/******/ // then flag all \\"chunkIds\\" as loaded and fire callback
233+
/******/ var moduleId, chunkId, i = 0, resolves = [], result;
234+
/******/ for(;i < chunkIds.length; i++) {
235+
/******/ chunkId = chunkIds[i];
236+
/******/ if(installedChunks[chunkId]) {
237+
/******/ resolves.push(installedChunks[chunkId][0]);
238+
/******/ }
239+
/******/ installedChunks[chunkId] = 0;
240+
/******/ }
241+
/******/ for(moduleId in moreModules) {
242+
/******/ if(Object.prototype.hasOwnProperty.call(moreModules, moduleId)) {
243+
/******/ modules[moduleId] = moreModules[moduleId];
244+
/******/ }
245+
/******/ }
246+
/******/ if(parentJsonpFunction) parentJsonpFunction(chunkIds, moreModules, executeModules);
247+
/******/ while(resolves.length) {
248+
/******/ resolves.shift()();
249+
/******/ }
250+
/******/ if(executeModules) {
251+
/******/ for(i=0; i < executeModules.length; i++) {
252+
/******/ result = __webpack_require__(__webpack_require__.s = executeModules[i]);
253+
/******/ }
254+
/******/ }
255+
/******/ return result;
256+
/******/ };
257+
/******/
258+
/******/ // The module cache
259+
/******/ var installedModules = {};
260+
/******/
261+
/******/ // objects to store loaded and loading chunks
262+
/******/ var installedChunks = {
263+
/******/ 3: 0
264+
/******/ };
265+
/******/
266+
/******/ // The require function
267+
/******/ function __webpack_require__(moduleId) {
268+
/******/
269+
/******/ // Check if module is in cache
270+
/******/ if(installedModules[moduleId]) {
271+
/******/ return installedModules[moduleId].exports;
272+
/******/ }
273+
/******/ // Create a new module (and put it into the cache)
274+
/******/ var module = installedModules[moduleId] = {
275+
/******/ i: moduleId,
276+
/******/ l: false,
277+
/******/ exports: {}
278+
/******/ };
279+
/******/
280+
/******/ // Execute the module function
281+
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
282+
/******/
283+
/******/ // Flag the module as loaded
284+
/******/ module.l = true;
285+
/******/
286+
/******/ // Return the exports of the module
287+
/******/ return module.exports;
288+
/******/ }
289+
/******/
290+
/******/ // This file contains only the entry chunk.
291+
/******/ // The chunk loading function for additional chunks
292+
/******/ __webpack_require__.e = function requireEnsure(chunkId) {
293+
/******/ var installedChunkData = installedChunks[chunkId];
294+
/******/ if(installedChunkData === 0) {
295+
/******/ return new Promise(function(resolve) { resolve(); });
296+
/******/ }
297+
/******/
298+
/******/ // a Promise means \\"currently loading\\".
299+
/******/ if(installedChunkData) {
300+
/******/ return installedChunkData[2];
301+
/******/ }
302+
/******/
303+
/******/ // setup Promise in chunk cache
304+
/******/ var promise = new Promise(function(resolve, reject) {
305+
/******/ installedChunkData = installedChunks[chunkId] = [resolve, reject];
306+
/******/ });
307+
/******/ installedChunkData[2] = promise;
308+
/******/
309+
/******/ // start chunk loading
310+
/******/ var head = document.getElementsByTagName('head')[0];
311+
/******/ var script = document.createElement('script');
312+
/******/ script.type = 'text/javascript';
313+
/******/ script.charset = 'utf-8';
314+
/******/ script.async = true;
315+
/******/ script.timeout = 120000;
316+
/******/
317+
/******/ if (__webpack_require__.nc) {
318+
/******/ script.setAttribute(\\"nonce\\", __webpack_require__.nc);
319+
/******/ }
320+
/******/ script.src = __webpack_require__.p + \\"\\" + chunkId + \\".\\" + ({\\"0\\":\\"included2\\",\\"1\\":\\"included1\\",\\"2\\":\\"entry\\"}[chunkId]||chunkId) + \\".\\" + {\\"0\\":\\"110cfb201ee67fa7a412\\",\\"1\\":\\"3c000166b4174c9cb9a0\\",\\"2\\":\\"a3533847fa24ef98733c\\"}[chunkId] + \\".js\\";
321+
/******/ var timeout = setTimeout(onScriptComplete, 120000);
322+
/******/ script.onerror = script.onload = onScriptComplete;
323+
/******/ function onScriptComplete() {
324+
/******/ // avoid mem leaks in IE.
325+
/******/ script.onerror = script.onload = null;
326+
/******/ clearTimeout(timeout);
327+
/******/ var chunk = installedChunks[chunkId];
328+
/******/ if(chunk !== 0) {
329+
/******/ if(chunk) {
330+
/******/ chunk[1](new Error('Loading chunk ' + chunkId + ' failed.'));
331+
/******/ }
332+
/******/ installedChunks[chunkId] = undefined;
333+
/******/ }
334+
/******/ };
335+
/******/ head.appendChild(script);
336+
/******/
337+
/******/ return promise;
338+
/******/ };
339+
/******/
340+
/******/ // expose the modules object (__webpack_modules__)
341+
/******/ __webpack_require__.m = modules;
342+
/******/
343+
/******/ // expose the module cache
344+
/******/ __webpack_require__.c = installedModules;
345+
/******/
346+
/******/ // define getter function for harmony exports
347+
/******/ __webpack_require__.d = function(exports, name, getter) {
348+
/******/ if(!__webpack_require__.o(exports, name)) {
349+
/******/ Object.defineProperty(exports, name, {
350+
/******/ configurable: false,
351+
/******/ enumerable: true,
352+
/******/ get: getter
353+
/******/ });
354+
/******/ }
355+
/******/ };
356+
/******/
357+
/******/ // getDefaultExport function for compatibility with non-harmony modules
358+
/******/ __webpack_require__.n = function(module) {
359+
/******/ var getter = module && module.__esModule ?
360+
/******/ function getDefault() { return module['default']; } :
361+
/******/ function getModuleExports() { return module; };
362+
/******/ __webpack_require__.d(getter, 'a', getter);
363+
/******/ return getter;
364+
/******/ };
365+
/******/
366+
/******/ // Object.prototype.hasOwnProperty.call
367+
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
368+
/******/
369+
/******/ // __webpack_public_path__
370+
/******/ __webpack_require__.p = \\"\\";
371+
/******/
372+
/******/ // on error function for async loading
373+
/******/ __webpack_require__.oe = function(err) { console.error(err); throw err; };
374+
/******/ })
375+
/************************************************************************/
376+
/******/ ([]);"
377+
`;
378+
379+
exports[`warnings 1`] = `Array []`;
380+
381+
exports[`warnings 2`] = `Array []`;

‎test/exclude-option.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ describe('when applied with exclude option', () => {
1212
entry: {
1313
excluded1: `${__dirname}/fixtures/excluded1.js`,
1414
excluded2: `${__dirname}/fixtures/excluded2.js`,
15-
included: `${__dirname}/fixtures/entry.js`,
15+
entry: `${__dirname}/fixtures/entry.js`,
1616
},
1717
});
1818
});

‎test/fixtures/included1.js

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module.exports = function Bar1() {
2+
const b = 2 + 2;
3+
console.log(b + 1 + 2);
4+
};

‎test/fixtures/included2.js

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module.exports = function Bar2() {
2+
const b = 2 + 2;
3+
console.log(b + 1 + 2);
4+
};

‎test/include-options.test.js

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import UglifyJsPlugin from '../src/index';
2+
import {
3+
cleanErrorStack,
4+
createCompiler,
5+
compile,
6+
} from './helpers';
7+
8+
describe('when applied with include option', () => {
9+
let compiler;
10+
beforeEach(() => {
11+
compiler = createCompiler({
12+
entry: {
13+
included1: `${__dirname}/fixtures/included1.js`,
14+
included2: `${__dirname}/fixtures/included2.js`,
15+
entry: `${__dirname}/fixtures/entry.js`,
16+
},
17+
});
18+
});
19+
20+
it('matches snapshot for a single include', () => {
21+
new UglifyJsPlugin({
22+
include: /included1/,
23+
}).apply(compiler);
24+
25+
26+
return compile(compiler).then((stats) => {
27+
const errors = stats.compilation.errors.map(cleanErrorStack);
28+
const warnings = stats.compilation.warnings.map(cleanErrorStack);
29+
30+
expect(errors).toMatchSnapshot('errors');
31+
expect(warnings).toMatchSnapshot('warnings');
32+
33+
for (const file in stats.compilation.assets) {
34+
if (Object.prototype.hasOwnProperty.call(stats.compilation.assets, file)) {
35+
expect(stats.compilation.assets[file].source()).toMatchSnapshot(file);
36+
}
37+
}
38+
});
39+
});
40+
41+
it('matches snapshot for multiple includes', () => {
42+
new UglifyJsPlugin({
43+
include: [
44+
/included1/,
45+
/included2/,
46+
],
47+
}).apply(compiler);
48+
49+
50+
return compile(compiler).then((stats) => {
51+
const errors = stats.compilation.errors.map(cleanErrorStack);
52+
const warnings = stats.compilation.warnings.map(cleanErrorStack);
53+
54+
expect(errors).toMatchSnapshot('errors');
55+
expect(warnings).toMatchSnapshot('warnings');
56+
57+
for (const file in stats.compilation.assets) {
58+
if (Object.prototype.hasOwnProperty.call(stats.compilation.assets, file)) {
59+
expect(stats.compilation.assets[file].source()).toMatchSnapshot(file);
60+
}
61+
}
62+
});
63+
});
64+
});

0 commit comments

Comments
 (0)
This repository has been archived.