UNPKG

8.67 kBJavaScriptView Raw
1module.exports =
2/******/ (function() { // webpackBootstrap
3/******/ "use strict";
4/******/ var __webpack_modules__ = ({
5
6/***/ 787:
7/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
8
9
10
11Object.defineProperty(exports, "__esModule", ({
12 value: true
13}));
14exports.default = void 0;
15
16var _terser = __nccwpck_require__(775);
17
18function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
19
20function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
21
22function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
23
24const buildTerserOptions = ({
25 ecma,
26 warnings,
27 parse = {},
28 compress = {},
29 mangle,
30 module,
31 output,
32 toplevel,
33 nameCache,
34 ie8,
35
36 /* eslint-disable camelcase */
37 keep_classnames,
38 keep_fnames,
39
40 /* eslint-enable camelcase */
41 safari10
42} = {}) => ({
43 ecma,
44 warnings,
45 parse: _objectSpread({}, parse),
46 compress: typeof compress === 'boolean' ? compress : _objectSpread({}, compress),
47 // eslint-disable-next-line no-nested-ternary
48 mangle: mangle == null ? true : typeof mangle === 'boolean' ? mangle : _objectSpread({}, mangle),
49 output: _objectSpread({
50 shebang: true,
51 comments: false,
52 beautify: false,
53 semicolons: true
54 }, output),
55 module,
56 // Ignoring sourceMap from options
57 sourceMap: null,
58 toplevel,
59 nameCache,
60 ie8,
61 keep_classnames,
62 keep_fnames,
63 safari10
64});
65
66const buildComments = (options, terserOptions, extractedComments) => {
67 const condition = {};
68 const commentsOpts = terserOptions.output.comments; // Use /^\**!|@preserve|@license|@cc_on/i RegExp
69
70 if (typeof options.extractComments === 'boolean') {
71 condition.preserve = commentsOpts;
72 condition.extract = /^\**!|@preserve|@license|@cc_on/i;
73 } else if (typeof options.extractComments === 'string' || options.extractComments instanceof RegExp) {
74 // extractComments specifies the extract condition and commentsOpts specifies the preserve condition
75 condition.preserve = commentsOpts;
76 condition.extract = options.extractComments;
77 } else if (typeof options.extractComments === 'function') {
78 condition.preserve = commentsOpts;
79 condition.extract = options.extractComments;
80 } else if (Object.prototype.hasOwnProperty.call(options.extractComments, 'condition')) {
81 // Extract condition is given in extractComments.condition
82 condition.preserve = commentsOpts;
83 condition.extract = options.extractComments.condition;
84 } else {
85 // No extract condition is given. Extract comments that match commentsOpts instead of preserving them
86 condition.preserve = false;
87 condition.extract = commentsOpts;
88 } // Ensure that both conditions are functions
89
90
91 ['preserve', 'extract'].forEach(key => {
92 let regexStr;
93 let regex;
94
95 switch (typeof condition[key]) {
96 case 'boolean':
97 condition[key] = condition[key] ? () => true : () => false;
98 break;
99
100 case 'function':
101 break;
102
103 case 'string':
104 if (condition[key] === 'all') {
105 condition[key] = () => true;
106
107 break;
108 }
109
110 if (condition[key] === 'some') {
111 condition[key] = (astNode, comment) => {
112 return comment.type === 'comment2' && /^\**!|@preserve|@license|@cc_on/i.test(comment.value);
113 };
114
115 break;
116 }
117
118 regexStr = condition[key];
119
120 condition[key] = (astNode, comment) => {
121 return new RegExp(regexStr).test(comment.value);
122 };
123
124 break;
125
126 default:
127 regex = condition[key];
128
129 condition[key] = (astNode, comment) => regex.test(comment.value);
130
131 }
132 }); // Redefine the comments function to extract and preserve
133 // comments according to the two conditions
134
135 return (astNode, comment) => {
136 if (condition.extract(astNode, comment)) {
137 const commentText = comment.type === 'comment2' ? `/*${comment.value}*/` : `//${comment.value}`; // Don't include duplicate comments
138
139 if (!extractedComments.includes(commentText)) {
140 extractedComments.push(commentText);
141 }
142 }
143
144 return condition.preserve(astNode, comment);
145 };
146};
147
148const minify = options => {
149 const {
150 file,
151 input,
152 inputSourceMap,
153 extractComments,
154 minify: minifyFn
155 } = options;
156
157 if (minifyFn) {
158 return minifyFn({
159 [file]: input
160 }, inputSourceMap);
161 } // Copy terser options
162
163
164 const terserOptions = buildTerserOptions(options.terserOptions); // Let terser generate a SourceMap
165
166 if (inputSourceMap) {
167 terserOptions.sourceMap = true;
168 }
169
170 const extractedComments = [];
171
172 if (extractComments) {
173 terserOptions.output.comments = buildComments(options, terserOptions, extractedComments);
174 }
175
176 const {
177 error,
178 map,
179 code,
180 warnings
181 } = (0, _terser.minify)({
182 [file]: input
183 }, terserOptions);
184 return {
185 error,
186 map,
187 code,
188 warnings,
189 extractedComments
190 };
191};
192
193var _default = minify;
194exports.default = _default;
195
196/***/ }),
197
198/***/ 359:
199/***/ (function(module, exports, __nccwpck_require__) {
200
201/* module decorator */ module = __nccwpck_require__.nmd(module);
202
203
204var _minify = _interopRequireDefault(__nccwpck_require__(787));
205
206function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
207
208module.exports = (options, callback) => {
209 try {
210 // 'use strict' => this === undefined (Clean Scope)
211 // Safer for possible security issues, albeit not critical at all here
212 // eslint-disable-next-line no-new-func, no-param-reassign
213 options = new Function('exports', 'require', 'module', '__filename', '__dirname', `'use strict'\nreturn ${options}`)(exports, require, module, __filename, __dirname);
214 callback(null, (0, _minify.default)(options));
215 } catch (errors) {
216 callback(errors);
217 }
218};
219
220/***/ }),
221
222/***/ 775:
223/***/ (function(module) {
224
225module.exports = require("next/dist/compiled/terser");;
226
227/***/ })
228
229/******/ });
230/************************************************************************/
231/******/ // The module cache
232/******/ var __webpack_module_cache__ = {};
233/******/
234/******/ // The require function
235/******/ function __nccwpck_require__(moduleId) {
236/******/ // Check if module is in cache
237/******/ if(__webpack_module_cache__[moduleId]) {
238/******/ return __webpack_module_cache__[moduleId].exports;
239/******/ }
240/******/ // Create a new module (and put it into the cache)
241/******/ var module = __webpack_module_cache__[moduleId] = {
242/******/ id: moduleId,
243/******/ loaded: false,
244/******/ exports: {}
245/******/ };
246/******/
247/******/ // Execute the module function
248/******/ var threw = true;
249/******/ try {
250/******/ __webpack_modules__[moduleId](module, module.exports, __nccwpck_require__);
251/******/ threw = false;
252/******/ } finally {
253/******/ if(threw) delete __webpack_module_cache__[moduleId];
254/******/ }
255/******/
256/******/ // Flag the module as loaded
257/******/ module.loaded = true;
258/******/
259/******/ // Return the exports of the module
260/******/ return module.exports;
261/******/ }
262/******/
263/************************************************************************/
264/******/ /* webpack/runtime/node module decorator */
265/******/ !function() {
266/******/ __nccwpck_require__.nmd = function(module) {
267/******/ module.paths = [];
268/******/ if (!module.children) module.children = [];
269/******/ return module;
270/******/ };
271/******/ }();
272/******/
273/******/ /* webpack/runtime/compat */
274/******/
275/******/ __nccwpck_require__.ab = __dirname + "/";/************************************************************************/
276/******/ // module exports must be returned from runtime so entry inlining is disabled
277/******/ // startup
278/******/ // Load entry module and return exports
279/******/ return __nccwpck_require__(359);
280/******/ })()
281;
\No newline at end of file