1 | #!/usr/bin/env node
|
2 | 'use strict';
|
3 |
|
4 | function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
5 |
|
6 | var fs = require('fs');
|
7 | var fs__default = _interopDefault(fs);
|
8 | var path = require('path');
|
9 | var path__default = _interopDefault(path);
|
10 | var module$1 = _interopDefault(require('module'));
|
11 | var rollup = require('../dist/rollup.js');
|
12 | var rollup__default = _interopDefault(rollup);
|
13 | var assert = _interopDefault(require('assert'));
|
14 | var events = _interopDefault(require('events'));
|
15 |
|
16 | var help = "rollup version __VERSION__\n=====================================\n\nUsage: rollup [options] <entry file>\n\nBasic options:\n\n-c, --config <filename> Use this config file (if argument is used but value\n is unspecified, defaults to rollup.config.js)\n-d, --dir <dirname> Directory for chunks (if absent, prints to stdout)\n-e, --external <ids> Comma-separate list of module IDs to exclude\n-f, --format <format> Type of output (amd, cjs, esm, iife, umd)\n-g, --globals <pairs> Comma-separate list of `moduleID:Global` pairs\n-h, --help Show this help message\n-i, --input <filename> Input (alternative to <entry file>)\n-m, --sourcemap Generate sourcemap (`-m inline` for inline map)\n-n, --name <name> Name for UMD export\n-o, --file <output> Single output file (if absent, prints to stdout)\n-v, --version Show version number\n-w, --watch Watch files in bundle and rebuild on changes\n--amd.id <id> ID for AMD module (default is anonymous)\n--amd.define <name> Function to use in place of `define`\n--assetFileNames <pattern> Name pattern for emitted assets\n--banner <text> Code to insert at top of bundle (outside wrapper)\n--chunkFileNames <pattern> Name pattern for emitted secondary chunks\n--compact Minify wrapper code\n--context <variable> Specify top-level `this` value\n--dynamicImportFunction <name> Rename the dynamic `import()` function\n--entryFileNames <pattern> Name pattern for emitted entry chunks\n--environment <values> Settings passed to config file (see example)\n--no-esModule Do not add __esModule property\n--exports <mode> Specify export mode (auto, default, named, none)\n--extend Extend global variable defined by --name\n--footer <text> Code to insert at end of bundle (outside wrapper)\n--no-freeze Do not freeze namespace objects\n--no-indent Don't indent result\n--no-interop Do not include interop block\n--inlineDynamicImports Create single bundle when using dynamic imports\n--intro <text> Code to insert at top of bundle (inside wrapper)\n--namespaceToStringTag Create proper `.toString` methods for namespaces\n--noConflict Generate a noConflict method for UMD globals\n--no-strict Don't emit `\"use strict\";` in the generated modules\n--outro <text> Code to insert at end of bundle (inside wrapper)\n--preferConst Use `const` instead of `var` for exports\n--preserveModules Preserve module structure\n--preserveSymlinks Do not follow symlinks when resolving files\n--shimMissingExports Create shim variables for missing exports\n--silent Don't print warnings\n--sourcemapExcludeSources Do not include source code in source maps\n--sourcemapFile <file> Specify bundle position for source maps\n--no-treeshake Disable tree-shaking optimisations\n--no-treeshake.annotations Ignore pure call annotations\n--no-treeshake.propertyReadSideEffects Ignore property access side-effects\n--treeshake.pureExternalModules Assume side-effect free externals\n\nExamples:\n\n# use settings in config file\nrollup -c\n\n# in config file, process.env.INCLUDE_DEPS === 'true'\n# and process.env.BUILD === 'production'\nrollup -c --environment INCLUDE_DEPS,BUILD:production\n\n# create CommonJS bundle.js from src/main.js\nrollup --format=cjs --file=bundle.js -- src/main.js\n\n# create self-executing IIFE using `window.jQuery`\n# and `window._` as external globals\nrollup -f iife --globals jquery:jQuery,lodash:_ \\\n -i src/app.js -o build/app.js -m build/app.js.map\n\nNotes:\n\n* When piping to stdout, only inline sourcemaps are permitted\n\nFor more information visit https://rollupjs.org\n";
|
17 |
|
18 | var minimist = function (args, opts) {
|
19 | if (!opts) opts = {};
|
20 |
|
21 | var flags = { bools : {}, strings : {}, unknownFn: null };
|
22 |
|
23 | if (typeof opts['unknown'] === 'function') {
|
24 | flags.unknownFn = opts['unknown'];
|
25 | }
|
26 |
|
27 | if (typeof opts['boolean'] === 'boolean' && opts['boolean']) {
|
28 | flags.allBools = true;
|
29 | } else {
|
30 | [].concat(opts['boolean']).filter(Boolean).forEach(function (key) {
|
31 | flags.bools[key] = true;
|
32 | });
|
33 | }
|
34 |
|
35 | var aliases = {};
|
36 | Object.keys(opts.alias || {}).forEach(function (key) {
|
37 | aliases[key] = [].concat(opts.alias[key]);
|
38 | aliases[key].forEach(function (x) {
|
39 | aliases[x] = [key].concat(aliases[key].filter(function (y) {
|
40 | return x !== y;
|
41 | }));
|
42 | });
|
43 | });
|
44 |
|
45 | [].concat(opts.string).filter(Boolean).forEach(function (key) {
|
46 | flags.strings[key] = true;
|
47 | if (aliases[key]) {
|
48 | flags.strings[aliases[key]] = true;
|
49 | }
|
50 | });
|
51 |
|
52 | var defaults = opts['default'] || {};
|
53 |
|
54 | var argv = { _ : [] };
|
55 | Object.keys(flags.bools).forEach(function (key) {
|
56 | setArg(key, defaults[key] === undefined ? false : defaults[key]);
|
57 | });
|
58 |
|
59 | var notFlags = [];
|
60 |
|
61 | if (args.indexOf('--') !== -1) {
|
62 | notFlags = args.slice(args.indexOf('--')+1);
|
63 | args = args.slice(0, args.indexOf('--'));
|
64 | }
|
65 |
|
66 | function argDefined(key, arg) {
|
67 | return (flags.allBools && /^--[^=]+$/.test(arg)) ||
|
68 | flags.strings[key] || flags.bools[key] || aliases[key];
|
69 | }
|
70 |
|
71 | function setArg (key, val, arg) {
|
72 | if (arg && flags.unknownFn && !argDefined(key, arg)) {
|
73 | if (flags.unknownFn(arg) === false) return;
|
74 | }
|
75 |
|
76 | var value = !flags.strings[key] && isNumber(val)
|
77 | ? Number(val) : val
|
78 | ;
|
79 | setKey(argv, key.split('.'), value);
|
80 |
|
81 | (aliases[key] || []).forEach(function (x) {
|
82 | setKey(argv, x.split('.'), value);
|
83 | });
|
84 | }
|
85 |
|
86 | function setKey (obj, keys, value) {
|
87 | var o = obj;
|
88 | keys.slice(0,-1).forEach(function (key) {
|
89 | if (o[key] === undefined) o[key] = {};
|
90 | o = o[key];
|
91 | });
|
92 |
|
93 | var key = keys[keys.length - 1];
|
94 | if (o[key] === undefined || flags.bools[key] || typeof o[key] === 'boolean') {
|
95 | o[key] = value;
|
96 | }
|
97 | else if (Array.isArray(o[key])) {
|
98 | o[key].push(value);
|
99 | }
|
100 | else {
|
101 | o[key] = [ o[key], value ];
|
102 | }
|
103 | }
|
104 |
|
105 | function aliasIsBoolean(key) {
|
106 | return aliases[key].some(function (x) {
|
107 | return flags.bools[x];
|
108 | });
|
109 | }
|
110 |
|
111 | for (var i = 0; i < args.length; i++) {
|
112 | var arg = args[i];
|
113 |
|
114 | if (/^--.+=/.test(arg)) {
|
115 | // Using [\s\S] instead of . because js doesn't support the
|
116 | // 'dotall' regex modifier. See:
|
117 | // http://stackoverflow.com/a/1068308/13216
|
118 | var m = arg.match(/^--([^=]+)=([\s\S]*)$/);
|
119 | var key = m[1];
|
120 | var value = m[2];
|
121 | if (flags.bools[key]) {
|
122 | value = value !== 'false';
|
123 | }
|
124 | setArg(key, value, arg);
|
125 | }
|
126 | else if (/^--no-.+/.test(arg)) {
|
127 | var key = arg.match(/^--no-(.+)/)[1];
|
128 | setArg(key, false, arg);
|
129 | }
|
130 | else if (/^--.+/.test(arg)) {
|
131 | var key = arg.match(/^--(.+)/)[1];
|
132 | var next = args[i + 1];
|
133 | if (next !== undefined && !/^-/.test(next)
|
134 | && !flags.bools[key]
|
135 | && !flags.allBools
|
136 | && (aliases[key] ? !aliasIsBoolean(key) : true)) {
|
137 | setArg(key, next, arg);
|
138 | i++;
|
139 | }
|
140 | else if (/^(true|false)$/.test(next)) {
|
141 | setArg(key, next === 'true', arg);
|
142 | i++;
|
143 | }
|
144 | else {
|
145 | setArg(key, flags.strings[key] ? '' : true, arg);
|
146 | }
|
147 | }
|
148 | else if (/^-[^-]+/.test(arg)) {
|
149 | var letters = arg.slice(1,-1).split('');
|
150 |
|
151 | var broken = false;
|
152 | for (var j = 0; j < letters.length; j++) {
|
153 | var next = arg.slice(j+2);
|
154 |
|
155 | if (next === '-') {
|
156 | setArg(letters[j], next, arg);
|
157 | continue;
|
158 | }
|
159 |
|
160 | if (/[A-Za-z]/.test(letters[j]) && /=/.test(next)) {
|
161 | setArg(letters[j], next.split('=')[1], arg);
|
162 | broken = true;
|
163 | break;
|
164 | }
|
165 |
|
166 | if (/[A-Za-z]/.test(letters[j])
|
167 | && /-?\d+(\.\d*)?(e-?\d+)?$/.test(next)) {
|
168 | setArg(letters[j], next, arg);
|
169 | broken = true;
|
170 | break;
|
171 | }
|
172 |
|
173 | if (letters[j+1] && letters[j+1].match(/\W/)) {
|
174 | setArg(letters[j], arg.slice(j+2), arg);
|
175 | broken = true;
|
176 | break;
|
177 | }
|
178 | else {
|
179 | setArg(letters[j], flags.strings[letters[j]] ? '' : true, arg);
|
180 | }
|
181 | }
|
182 |
|
183 | var key = arg.slice(-1)[0];
|
184 | if (!broken && key !== '-') {
|
185 | if (args[i+1] && !/^(-|--)[^-]/.test(args[i+1])
|
186 | && !flags.bools[key]
|
187 | && (aliases[key] ? !aliasIsBoolean(key) : true)) {
|
188 | setArg(key, args[i+1], arg);
|
189 | i++;
|
190 | }
|
191 | else if (args[i+1] && /true|false/.test(args[i+1])) {
|
192 | setArg(key, args[i+1] === 'true', arg);
|
193 | i++;
|
194 | }
|
195 | else {
|
196 | setArg(key, flags.strings[key] ? '' : true, arg);
|
197 | }
|
198 | }
|
199 | }
|
200 | else {
|
201 | if (!flags.unknownFn || flags.unknownFn(arg) !== false) {
|
202 | argv._.push(
|
203 | flags.strings['_'] || !isNumber(arg) ? arg : Number(arg)
|
204 | );
|
205 | }
|
206 | if (opts.stopEarly) {
|
207 | argv._.push.apply(argv._, args.slice(i + 1));
|
208 | break;
|
209 | }
|
210 | }
|
211 | }
|
212 |
|
213 | Object.keys(defaults).forEach(function (key) {
|
214 | if (!hasKey(argv, key.split('.'))) {
|
215 | setKey(argv, key.split('.'), defaults[key]);
|
216 |
|
217 | (aliases[key] || []).forEach(function (x) {
|
218 | setKey(argv, x.split('.'), defaults[key]);
|
219 | });
|
220 | }
|
221 | });
|
222 |
|
223 | if (opts['--']) {
|
224 | argv['--'] = new Array();
|
225 | notFlags.forEach(function(key) {
|
226 | argv['--'].push(key);
|
227 | });
|
228 | }
|
229 | else {
|
230 | notFlags.forEach(function(key) {
|
231 | argv._.push(key);
|
232 | });
|
233 | }
|
234 |
|
235 | return argv;
|
236 | };
|
237 |
|
238 | function hasKey (obj, keys) {
|
239 | var o = obj;
|
240 | keys.slice(0,-1).forEach(function (key) {
|
241 | o = (o[key] || {});
|
242 | });
|
243 |
|
244 | var key = keys[keys.length - 1];
|
245 | return key in o;
|
246 | }
|
247 |
|
248 | function isNumber (x) {
|
249 | if (typeof x === 'number') return true;
|
250 | if (/^0x[0-9a-f]+$/i.test(x)) return true;
|
251 | return /^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(x);
|
252 | }
|
253 |
|
254 | var version = "1.9.3";
|
255 |
|
256 | /*! *****************************************************************************
|
257 | Copyright (c) Microsoft Corporation. All rights reserved.
|
258 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
259 | this file except in compliance with the License. You may obtain a copy of the
|
260 | License at http://www.apache.org/licenses/LICENSE-2.0
|
261 |
|
262 | THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
263 | KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
264 | WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
265 | MERCHANTABLITY OR NON-INFRINGEMENT.
|
266 |
|
267 | See the Apache Version 2.0 License for specific language governing permissions
|
268 | and limitations under the License.
|
269 | ***************************************************************************** */
|
270 | /* global Reflect, Promise */
|
271 |
|
272 | var extendStatics = function(d, b) {
|
273 | extendStatics = Object.setPrototypeOf ||
|
274 | ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
275 | function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
276 | return extendStatics(d, b);
|
277 | };
|
278 |
|
279 | function __extends(d, b) {
|
280 | extendStatics(d, b);
|
281 | function __() { this.constructor = d; }
|
282 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
283 | }
|
284 |
|
285 | var __assign = function() {
|
286 | __assign = Object.assign || function __assign(t) {
|
287 | for (var s, i = 1, n = arguments.length; i < n; i++) {
|
288 | s = arguments[i];
|
289 | for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
290 | }
|
291 | return t;
|
292 | };
|
293 | return __assign.apply(this, arguments);
|
294 | };
|
295 |
|
296 | function __rest(s, e) {
|
297 | var t = {};
|
298 | for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
299 | t[p] = s[p];
|
300 | if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
301 | for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0)
|
302 | t[p[i]] = s[p[i]];
|
303 | return t;
|
304 | }
|
305 |
|
306 | function __decorate(decorators, target, key, desc) {
|
307 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
308 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
309 | else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
310 | return c > 3 && r && Object.defineProperty(target, key, r), r;
|
311 | }
|
312 |
|
313 | function __param(paramIndex, decorator) {
|
314 | return function (target, key) { decorator(target, key, paramIndex); }
|
315 | }
|
316 |
|
317 | function __metadata(metadataKey, metadataValue) {
|
318 | if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
|
319 | }
|
320 |
|
321 | function __awaiter(thisArg, _arguments, P, generator) {
|
322 | return new (P || (P = Promise))(function (resolve, reject) {
|
323 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
324 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
325 | function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
326 | step((generator = generator.apply(thisArg, _arguments || [])).next());
|
327 | });
|
328 | }
|
329 |
|
330 | function __generator(thisArg, body) {
|
331 | var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
332 | return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
333 | function verb(n) { return function (v) { return step([n, v]); }; }
|
334 | function step(op) {
|
335 | if (f) throw new TypeError("Generator is already executing.");
|
336 | while (_) try {
|
337 | if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
338 | if (y = 0, t) op = [op[0] & 2, t.value];
|
339 | switch (op[0]) {
|
340 | case 0: case 1: t = op; break;
|
341 | case 4: _.label++; return { value: op[1], done: false };
|
342 | case 5: _.label++; y = op[1]; op = [0]; continue;
|
343 | case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
344 | default:
|
345 | if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
346 | if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
347 | if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
348 | if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
349 | if (t[2]) _.ops.pop();
|
350 | _.trys.pop(); continue;
|
351 | }
|
352 | op = body.call(thisArg, _);
|
353 | } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
354 | if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
355 | }
|
356 | }
|
357 |
|
358 | function __exportStar(m, exports) {
|
359 | for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
360 | }
|
361 |
|
362 | function __values(o) {
|
363 | var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
|
364 | if (m) return m.call(o);
|
365 | return {
|
366 | next: function () {
|
367 | if (o && i >= o.length) o = void 0;
|
368 | return { value: o && o[i++], done: !o };
|
369 | }
|
370 | };
|
371 | }
|
372 |
|
373 | function __read(o, n) {
|
374 | var m = typeof Symbol === "function" && o[Symbol.iterator];
|
375 | if (!m) return o;
|
376 | var i = m.call(o), r, ar = [], e;
|
377 | try {
|
378 | while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
379 | }
|
380 | catch (error) { e = { error: error }; }
|
381 | finally {
|
382 | try {
|
383 | if (r && !r.done && (m = i["return"])) m.call(i);
|
384 | }
|
385 | finally { if (e) throw e.error; }
|
386 | }
|
387 | return ar;
|
388 | }
|
389 |
|
390 | function __spread() {
|
391 | for (var ar = [], i = 0; i < arguments.length; i++)
|
392 | ar = ar.concat(__read(arguments[i]));
|
393 | return ar;
|
394 | }
|
395 |
|
396 | function __await(v) {
|
397 | return this instanceof __await ? (this.v = v, this) : new __await(v);
|
398 | }
|
399 |
|
400 | function __asyncGenerator(thisArg, _arguments, generator) {
|
401 | if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
402 | var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
403 | return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
|
404 | function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
|
405 | function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
|
406 | function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
407 | function fulfill(value) { resume("next", value); }
|
408 | function reject(value) { resume("throw", value); }
|
409 | function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
|
410 | }
|
411 |
|
412 | function __asyncDelegator(o) {
|
413 | var i, p;
|
414 | return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
|
415 | function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
|
416 | }
|
417 |
|
418 | function __asyncValues(o) {
|
419 | if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
420 | var m = o[Symbol.asyncIterator], i;
|
421 | return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
422 | function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
423 | function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
424 | }
|
425 |
|
426 | function __makeTemplateObject(cooked, raw) {
|
427 | if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
428 | return cooked;
|
429 | }
|
430 | function __importStar(mod) {
|
431 | if (mod && mod.__esModule) return mod;
|
432 | var result = {};
|
433 | if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
434 | result.default = mod;
|
435 | return result;
|
436 | }
|
437 |
|
438 | function __importDefault(mod) {
|
439 | return (mod && mod.__esModule) ? mod : { default: mod };
|
440 | }
|
441 |
|
442 | var tslib_1 = /*#__PURE__*/Object.freeze({
|
443 | __extends: __extends,
|
444 | get __assign () { return __assign; },
|
445 | __rest: __rest,
|
446 | __decorate: __decorate,
|
447 | __param: __param,
|
448 | __metadata: __metadata,
|
449 | __awaiter: __awaiter,
|
450 | __generator: __generator,
|
451 | __exportStar: __exportStar,
|
452 | __values: __values,
|
453 | __read: __read,
|
454 | __spread: __spread,
|
455 | __await: __await,
|
456 | __asyncGenerator: __asyncGenerator,
|
457 | __asyncDelegator: __asyncDelegator,
|
458 | __asyncValues: __asyncValues,
|
459 | __makeTemplateObject: __makeTemplateObject,
|
460 | __importStar: __importStar,
|
461 | __importDefault: __importDefault
|
462 | });
|
463 |
|
464 | var createGetOption = function (config, command) { return function (name, defaultValue) {
|
465 | return command[name] !== undefined
|
466 | ? command[name]
|
467 | : config[name] !== undefined
|
468 | ? config[name]
|
469 | : defaultValue;
|
470 | }; };
|
471 | var normalizeObjectOptionValue = function (optionValue) {
|
472 | if (!optionValue) {
|
473 | return optionValue;
|
474 | }
|
475 | if (typeof optionValue !== 'object') {
|
476 | return {};
|
477 | }
|
478 | return optionValue;
|
479 | };
|
480 | var getObjectOption = function (config, command, name) {
|
481 | var commandOption = normalizeObjectOptionValue(command[name]);
|
482 | var configOption = normalizeObjectOptionValue(config[name]);
|
483 | if (commandOption !== undefined) {
|
484 | return commandOption && configOption ? __assign({}, configOption, commandOption) : commandOption;
|
485 | }
|
486 | return configOption;
|
487 | };
|
488 | var defaultOnWarn = function (warning) {
|
489 | if (typeof warning === 'string') {
|
490 | console.warn(warning); // eslint-disable-line no-console
|
491 | }
|
492 | else {
|
493 | console.warn(warning.message); // eslint-disable-line no-console
|
494 | }
|
495 | };
|
496 | var getOnWarn = function (config, command, defaultOnWarnHandler) {
|
497 | if (defaultOnWarnHandler === void 0) { defaultOnWarnHandler = defaultOnWarn; }
|
498 | return command.silent
|
499 | ? function () { }
|
500 | : config.onwarn
|
501 | ? function (warning) { return config.onwarn(warning, defaultOnWarnHandler); }
|
502 | : defaultOnWarnHandler;
|
503 | };
|
504 | var getExternal = function (config, command) {
|
505 | var configExternal = config.external;
|
506 | return typeof configExternal === 'function'
|
507 | ? function (id) {
|
508 | var rest = [];
|
509 | for (var _i = 1; _i < arguments.length; _i++) {
|
510 | rest[_i - 1] = arguments[_i];
|
511 | }
|
512 | return configExternal.apply(void 0, [id].concat(rest)) || command.external.indexOf(id) !== -1;
|
513 | }
|
514 | : (configExternal || []).concat(command.external);
|
515 | };
|
516 | var commandAliases = {
|
517 | c: 'config',
|
518 | d: 'dir',
|
519 | e: 'external',
|
520 | f: 'format',
|
521 | g: 'globals',
|
522 | h: 'help',
|
523 | i: 'input',
|
524 | m: 'sourcemap',
|
525 | n: 'name',
|
526 | o: 'file',
|
527 | v: 'version',
|
528 | w: 'watch'
|
529 | };
|
530 | function mergeOptions(_a) {
|
531 | var _b = _a.config, config = _b === void 0 ? {} : _b, _c = _a.command, rawCommandOptions = _c === void 0 ? {} : _c, defaultOnWarnHandler = _a.defaultOnWarnHandler;
|
532 | var command = getCommandOptions(rawCommandOptions);
|
533 | var inputOptions = getInputOptions(config, command, defaultOnWarnHandler);
|
534 | if (command.output) {
|
535 | Object.assign(command, command.output);
|
536 | }
|
537 | var output = config.output;
|
538 | var normalizedOutputOptions = Array.isArray(output) ? output : output ? [output] : [];
|
539 | if (normalizedOutputOptions.length === 0)
|
540 | normalizedOutputOptions.push({});
|
541 | var outputOptions = normalizedOutputOptions.map(function (singleOutputOptions) {
|
542 | return getOutputOptions(singleOutputOptions, command);
|
543 | });
|
544 | var unknownOptionErrors = [];
|
545 | var validInputOptions = Object.keys(inputOptions);
|
546 | addUnknownOptionErrors(unknownOptionErrors, Object.keys(config), validInputOptions, 'input option', /^output$/);
|
547 | var validOutputOptions = Object.keys(outputOptions[0]);
|
548 | addUnknownOptionErrors(unknownOptionErrors, outputOptions.reduce(function (allKeys, options) { return allKeys.concat(Object.keys(options)); }, []), validOutputOptions, 'output option');
|
549 | var validCliOutputOptions = validOutputOptions.filter(function (option) { return option !== 'sourcemapPathTransform'; });
|
550 | addUnknownOptionErrors(unknownOptionErrors, Object.keys(command), validInputOptions.concat(validCliOutputOptions, Object.keys(commandAliases), 'config', 'environment', 'silent'), 'CLI flag', /^_|output|(config.*)$/);
|
551 | return {
|
552 | inputOptions: inputOptions,
|
553 | optionError: unknownOptionErrors.length > 0 ? unknownOptionErrors.join('\n') : null,
|
554 | outputOptions: outputOptions
|
555 | };
|
556 | }
|
557 | function addUnknownOptionErrors(errors, options, validOptions, optionType, ignoredKeys) {
|
558 | if (ignoredKeys === void 0) { ignoredKeys = /$./; }
|
559 | var unknownOptions = options.filter(function (key) { return validOptions.indexOf(key) === -1 && !ignoredKeys.test(key); });
|
560 | if (unknownOptions.length > 0)
|
561 | errors.push("Unknown " + optionType + ": " + unknownOptions.join(', ') + ". Allowed options: " + validOptions.sort().join(', '));
|
562 | }
|
563 | function getCommandOptions(rawCommandOptions) {
|
564 | var command = __assign({}, rawCommandOptions);
|
565 | command.external = rawCommandOptions.external ? rawCommandOptions.external.split(',') : [];
|
566 | if (rawCommandOptions.globals) {
|
567 | command.globals = Object.create(null);
|
568 | rawCommandOptions.globals.split(',').forEach(function (str) {
|
569 | var names = str.split(':');
|
570 | command.globals[names[0]] = names[1];
|
571 | // Add missing Module IDs to external.
|
572 | if (command.external.indexOf(names[0]) === -1) {
|
573 | command.external.push(names[0]);
|
574 | }
|
575 | });
|
576 | }
|
577 | return command;
|
578 | }
|
579 | function getInputOptions(config, command, defaultOnWarnHandler) {
|
580 | if (command === void 0) { command = {}; }
|
581 | var getOption = createGetOption(config, command);
|
582 | var inputOptions = {
|
583 | acorn: config.acorn,
|
584 | acornInjectPlugins: config.acornInjectPlugins,
|
585 | cache: getOption('cache'),
|
586 | chunkGroupingSize: getOption('chunkGroupingSize', 5000),
|
587 | context: config.context,
|
588 | experimentalCacheExpiry: getOption('experimentalCacheExpiry', 10),
|
589 | experimentalOptimizeChunks: getOption('experimentalOptimizeChunks'),
|
590 | experimentalTopLevelAwait: getOption('experimentalTopLevelAwait'),
|
591 | external: getExternal(config, command),
|
592 | inlineDynamicImports: getOption('inlineDynamicImports', false),
|
593 | input: getOption('input'),
|
594 | manualChunks: getOption('manualChunks'),
|
595 | moduleContext: config.moduleContext,
|
596 | onwarn: getOnWarn(config, command, defaultOnWarnHandler),
|
597 | perf: getOption('perf', false),
|
598 | plugins: config.plugins,
|
599 | preserveModules: getOption('preserveModules'),
|
600 | preserveSymlinks: getOption('preserveSymlinks'),
|
601 | shimMissingExports: getOption('shimMissingExports'),
|
602 | treeshake: getObjectOption(config, command, 'treeshake'),
|
603 | watch: config.watch
|
604 | };
|
605 | // support rollup({ cache: prevBuildObject })
|
606 | if (inputOptions.cache && inputOptions.cache.cache)
|
607 | inputOptions.cache = inputOptions.cache.cache;
|
608 | return inputOptions;
|
609 | }
|
610 | function getOutputOptions(config, command) {
|
611 | if (command === void 0) { command = {}; }
|
612 | var getOption = createGetOption(config, command);
|
613 | var format = getOption('format');
|
614 | // Handle format aliases
|
615 | switch (format) {
|
616 | case 'esm':
|
617 | case 'module':
|
618 | format = 'es';
|
619 | break;
|
620 | case 'commonjs':
|
621 | format = 'cjs';
|
622 | }
|
623 | return {
|
624 | amd: __assign({}, config.amd, command.amd),
|
625 | assetFileNames: getOption('assetFileNames'),
|
626 | banner: getOption('banner'),
|
627 | chunkFileNames: getOption('chunkFileNames'),
|
628 | compact: getOption('compact', false),
|
629 | dir: getOption('dir'),
|
630 | dynamicImportFunction: getOption('dynamicImportFunction'),
|
631 | entryFileNames: getOption('entryFileNames'),
|
632 | esModule: getOption('esModule', true),
|
633 | exports: getOption('exports'),
|
634 | extend: getOption('extend'),
|
635 | file: getOption('file'),
|
636 | footer: getOption('footer'),
|
637 | format: format === 'esm' ? 'es' : format,
|
638 | freeze: getOption('freeze', true),
|
639 | globals: getOption('globals'),
|
640 | indent: getOption('indent', true),
|
641 | interop: getOption('interop', true),
|
642 | intro: getOption('intro'),
|
643 | name: getOption('name'),
|
644 | namespaceToStringTag: getOption('namespaceToStringTag', false),
|
645 | noConflict: getOption('noConflict'),
|
646 | outro: getOption('outro'),
|
647 | paths: getOption('paths'),
|
648 | preferConst: getOption('preferConst'),
|
649 | sourcemap: getOption('sourcemap'),
|
650 | sourcemapExcludeSources: getOption('sourcemapExcludeSources'),
|
651 | sourcemapFile: getOption('sourcemapFile'),
|
652 | sourcemapPathTransform: getOption('sourcemapPathTransform'),
|
653 | strict: getOption('strict', true)
|
654 | };
|
655 | }
|
656 |
|
657 | var modules = {};
|
658 |
|
659 | var getModule = function(dir) {
|
660 | var rootPath = dir ? path__default.resolve(dir) : process.cwd();
|
661 | var rootName = path__default.join(rootPath, '@root');
|
662 | var root = modules[rootName];
|
663 | if (!root) {
|
664 | root = new module$1(rootName);
|
665 | root.filename = rootName;
|
666 | root.paths = module$1._nodeModulePaths(rootPath);
|
667 | modules[rootName] = root;
|
668 | }
|
669 | return root;
|
670 | };
|
671 |
|
672 | var requireRelative = function(requested, relativeTo) {
|
673 | var root = getModule(relativeTo);
|
674 | return root.require(requested);
|
675 | };
|
676 |
|
677 | requireRelative.resolve = function(requested, relativeTo) {
|
678 | var root = getModule(relativeTo);
|
679 | return module$1._resolveFilename(requested, root);
|
680 | };
|
681 |
|
682 | var requireRelative_1 = requireRelative;
|
683 |
|
684 | var absolutePath = /^(?:\/|(?:[A-Za-z]:)?[\\|/])/;
|
685 | function isAbsolute(path) {
|
686 | return absolutePath.test(path);
|
687 | }
|
688 |
|
689 | function getAliasName(resolved, unresolved) {
|
690 | var alias = path.basename(unresolved || resolved);
|
691 | var ext = path.extname(resolved);
|
692 | if (alias.endsWith(ext))
|
693 | alias = alias.substr(0, alias.length - ext.length);
|
694 | return alias;
|
695 | }
|
696 | function relativeId(id) {
|
697 | if (typeof process === 'undefined' || !isAbsolute(id))
|
698 | return id;
|
699 | return path.relative(process.cwd(), id);
|
700 | }
|
701 |
|
702 | const tc = {
|
703 | enabled:
|
704 | process.env.FORCE_COLOR ||
|
705 | process.platform === "win32" ||
|
706 | (process.stdout.isTTY && process.env.TERM && process.env.TERM !== "dumb")
|
707 | };
|
708 | const Styles = (tc.Styles = {});
|
709 | const defineProp = Object.defineProperty;
|
710 |
|
711 | const init = (style, open, close, re) => {
|
712 | let i,
|
713 | len = 1,
|
714 | seq = [(Styles[style] = { open, close, re })];
|
715 |
|
716 | const fn = s => {
|
717 | if (tc.enabled) {
|
718 | for (i = 0, s += ""; i < len; i++) {
|
719 | style = seq[i];
|
720 | s =
|
721 | (open = style.open) +
|
722 | (~s.indexOf((close = style.close), 4) // skip first \x1b[
|
723 | ? s.replace(style.re, open)
|
724 | : s) +
|
725 | close;
|
726 | }
|
727 | len = 1;
|
728 | }
|
729 | return s
|
730 | };
|
731 |
|
732 | defineProp(tc, style, {
|
733 | get: () => {
|
734 | for (let k in Styles)
|
735 | defineProp(fn, k, {
|
736 | get: () => ((seq[len++] = Styles[k]), fn)
|
737 | });
|
738 | delete tc[style];
|
739 | return (tc[style] = fn)
|
740 | },
|
741 | configurable: true
|
742 | });
|
743 | };
|
744 |
|
745 | init("reset", "\x1b[0m", "\x1b[0m", /\x1b\[0m/g);
|
746 | init("bold", "\x1b[1m", "\x1b[22m", /\x1b\[22m/g);
|
747 | init("dim", "\x1b[2m", "\x1b[22m", /\x1b\[22m/g);
|
748 | init("italic", "\x1b[3m", "\x1b[23m", /\x1b\[23m/g);
|
749 | init("underline", "\x1b[4m", "\x1b[24m", /\x1b\[24m/g);
|
750 | init("inverse", "\x1b[7m", "\x1b[27m", /\x1b\[27m/g);
|
751 | init("hidden", "\x1b[8m", "\x1b[28m", /\x1b\[28m/g);
|
752 | init("strikethrough", "\x1b[9m", "\x1b[29m", /\x1b\[29m/g);
|
753 | init("black", "\x1b[30m", "\x1b[39m", /\x1b\[39m/g);
|
754 | init("red", "\x1b[31m", "\x1b[39m", /\x1b\[39m/g);
|
755 | init("green", "\x1b[32m", "\x1b[39m", /\x1b\[39m/g);
|
756 | init("yellow", "\x1b[33m", "\x1b[39m", /\x1b\[39m/g);
|
757 | init("blue", "\x1b[34m", "\x1b[39m", /\x1b\[39m/g);
|
758 | init("magenta", "\x1b[35m", "\x1b[39m", /\x1b\[39m/g);
|
759 | init("cyan", "\x1b[36m", "\x1b[39m", /\x1b\[39m/g);
|
760 | init("white", "\x1b[37m", "\x1b[39m", /\x1b\[39m/g);
|
761 | init("gray", "\x1b[90m", "\x1b[39m", /\x1b\[39m/g);
|
762 | init("bgBlack", "\x1b[40m", "\x1b[49m", /\x1b\[49m/g);
|
763 | init("bgRed", "\x1b[41m", "\x1b[49m", /\x1b\[49m/g);
|
764 | init("bgGreen", "\x1b[42m", "\x1b[49m", /\x1b\[49m/g);
|
765 | init("bgYellow", "\x1b[43m", "\x1b[49m", /\x1b\[49m/g);
|
766 | init("bgBlue", "\x1b[44m", "\x1b[49m", /\x1b\[49m/g);
|
767 | init("bgMagenta", "\x1b[45m", "\x1b[49m", /\x1b\[49m/g);
|
768 | init("bgCyan", "\x1b[46m", "\x1b[49m", /\x1b\[49m/g);
|
769 | init("bgWhite", "\x1b[47m", "\x1b[49m", /\x1b\[49m/g);
|
770 |
|
771 | var turbocolor = tc;
|
772 |
|
773 | // log to stderr to keep `rollup main.js > bundle.js` from breaking
|
774 | var stderr = console.error.bind(console); // eslint-disable-line no-console
|
775 | function handleError(err, recover) {
|
776 | if (recover === void 0) { recover = false; }
|
777 | var description = err.message || err;
|
778 | if (err.name)
|
779 | description = err.name + ": " + description;
|
780 | var message = (err.plugin
|
781 | ? "(" + err.plugin + " plugin) " + description
|
782 | : description) || err;
|
783 | stderr(turbocolor.bold.red("[!] " + turbocolor.bold(message.toString())));
|
784 | if (err.url) {
|
785 | stderr(turbocolor.cyan(err.url));
|
786 | }
|
787 | if (err.loc) {
|
788 | stderr(relativeId(err.loc.file || err.id) + " (" + err.loc.line + ":" + err.loc.column + ")");
|
789 | }
|
790 | else if (err.id) {
|
791 | stderr(relativeId(err.id));
|
792 | }
|
793 | if (err.frame) {
|
794 | stderr(turbocolor.dim(err.frame));
|
795 | }
|
796 | if (err.stack) {
|
797 | stderr(turbocolor.dim(err.stack));
|
798 | }
|
799 | stderr('');
|
800 | if (!recover)
|
801 | process.exit(1);
|
802 | }
|
803 |
|
804 | function batchWarnings() {
|
805 | var allWarnings = new Map();
|
806 | var count = 0;
|
807 | return {
|
808 | get count() {
|
809 | return count;
|
810 | },
|
811 | add: function (warning) {
|
812 | if (typeof warning === 'string') {
|
813 | warning = { code: 'UNKNOWN', message: warning };
|
814 | }
|
815 | if (warning.code in immediateHandlers) {
|
816 | immediateHandlers[warning.code](warning);
|
817 | return;
|
818 | }
|
819 | if (!allWarnings.has(warning.code))
|
820 | allWarnings.set(warning.code, []);
|
821 | allWarnings.get(warning.code).push(warning);
|
822 | count += 1;
|
823 | },
|
824 | flush: function () {
|
825 | if (count === 0)
|
826 | return;
|
827 | var codes = Array.from(allWarnings.keys()).sort(function (a, b) {
|
828 | if (deferredHandlers[a] && deferredHandlers[b]) {
|
829 | return deferredHandlers[a].priority - deferredHandlers[b].priority;
|
830 | }
|
831 | if (deferredHandlers[a])
|
832 | return -1;
|
833 | if (deferredHandlers[b])
|
834 | return 1;
|
835 | return allWarnings.get(b).length - allWarnings.get(a).length;
|
836 | });
|
837 | codes.forEach(function (code) {
|
838 | var handler = deferredHandlers[code];
|
839 | var warnings = allWarnings.get(code);
|
840 | if (handler) {
|
841 | handler.fn(warnings);
|
842 | }
|
843 | else {
|
844 | warnings.forEach(function (warning) {
|
845 | title(warning.message);
|
846 | if (warning.url)
|
847 | info(warning.url);
|
848 | var id = (warning.loc && warning.loc.file) || warning.id;
|
849 | if (id) {
|
850 | var loc = warning.loc
|
851 | ? relativeId(id) + ": (" + warning.loc.line + ":" + warning.loc.column + ")"
|
852 | : relativeId(id);
|
853 | stderr(turbocolor.bold(relativeId(loc)));
|
854 | }
|
855 | if (warning.frame)
|
856 | info(warning.frame);
|
857 | });
|
858 | }
|
859 | });
|
860 | allWarnings = new Map();
|
861 | count = 0;
|
862 | }
|
863 | };
|
864 | }
|
865 | var immediateHandlers = {
|
866 | UNKNOWN_OPTION: function (warning) {
|
867 | title("You have passed an unrecognized option");
|
868 | stderr(warning.message);
|
869 | },
|
870 | MISSING_NODE_BUILTINS: function (warning) {
|
871 | title("Missing shims for Node.js built-ins");
|
872 | var detail = warning.modules.length === 1
|
873 | ? "'" + warning.modules[0] + "'"
|
874 | : warning.modules
|
875 | .slice(0, -1)
|
876 | .map(function (name) { return "'" + name + "'"; })
|
877 | .join(', ') + " and '" + warning.modules.slice(-1) + "'";
|
878 | stderr("Creating a browser bundle that depends on " + detail + ". You might need to include https://www.npmjs.com/package/rollup-plugin-node-builtins");
|
879 | },
|
880 | MIXED_EXPORTS: function () {
|
881 | title('Mixing named and default exports');
|
882 | stderr("Consumers of your bundle will have to use bundle['default'] to access the default export, which may not be what you want. Use `output.exports: 'named'` to disable this warning");
|
883 | },
|
884 | EMPTY_BUNDLE: function () {
|
885 | title("Generated an empty bundle");
|
886 | }
|
887 | };
|
888 | // TODO select sensible priorities
|
889 | var deferredHandlers = {
|
890 | UNUSED_EXTERNAL_IMPORT: {
|
891 | fn: function (warnings) {
|
892 | title('Unused external imports');
|
893 | warnings.forEach(function (warning) {
|
894 | stderr(warning.names + " imported from external module '" + warning.source + "' but never used");
|
895 | });
|
896 | },
|
897 | priority: 1
|
898 | },
|
899 | UNRESOLVED_IMPORT: {
|
900 | fn: function (warnings) {
|
901 | title('Unresolved dependencies');
|
902 | info('https://rollupjs.org/guide/en#warning-treating-module-as-external-dependency');
|
903 | var dependencies = new Map();
|
904 | warnings.forEach(function (warning) {
|
905 | if (!dependencies.has(warning.source))
|
906 | dependencies.set(warning.source, []);
|
907 | dependencies.get(warning.source).push(warning.importer);
|
908 | });
|
909 | Array.from(dependencies.keys()).forEach(function (dependency) {
|
910 | var importers = dependencies.get(dependency);
|
911 | stderr(turbocolor.bold(dependency) + " (imported by " + importers.join(', ') + ")");
|
912 | });
|
913 | },
|
914 | priority: 1
|
915 | },
|
916 | MISSING_EXPORT: {
|
917 | fn: function (warnings) {
|
918 | title('Missing exports');
|
919 | info('https://rollupjs.org/guide/en#error-name-is-not-exported-by-module-');
|
920 | warnings.forEach(function (warning) {
|
921 | stderr(turbocolor.bold(warning.importer));
|
922 | stderr(warning.missing + " is not exported by " + warning.exporter);
|
923 | stderr(turbocolor.gray(warning.frame));
|
924 | });
|
925 | },
|
926 | priority: 1
|
927 | },
|
928 | THIS_IS_UNDEFINED: {
|
929 | fn: function (warnings) {
|
930 | title('`this` has been rewritten to `undefined`');
|
931 | info('https://rollupjs.org/guide/en#error-this-is-undefined');
|
932 | showTruncatedWarnings(warnings);
|
933 | },
|
934 | priority: 1
|
935 | },
|
936 | EVAL: {
|
937 | fn: function (warnings) {
|
938 | title('Use of eval is strongly discouraged');
|
939 | info('https://rollupjs.org/guide/en#avoiding-eval');
|
940 | showTruncatedWarnings(warnings);
|
941 | },
|
942 | priority: 1
|
943 | },
|
944 | NON_EXISTENT_EXPORT: {
|
945 | fn: function (warnings) {
|
946 | title("Import of non-existent " + (warnings.length > 1 ? 'exports' : 'export'));
|
947 | showTruncatedWarnings(warnings);
|
948 | },
|
949 | priority: 1
|
950 | },
|
951 | NAMESPACE_CONFLICT: {
|
952 | fn: function (warnings) {
|
953 | title("Conflicting re-exports");
|
954 | warnings.forEach(function (warning) {
|
955 | stderr(turbocolor.bold(relativeId(warning.reexporter)) + " re-exports '" + warning.name + "' from both " + relativeId(warning.sources[0]) + " and " + relativeId(warning.sources[1]) + " (will be ignored)");
|
956 | });
|
957 | },
|
958 | priority: 1
|
959 | },
|
960 | MISSING_GLOBAL_NAME: {
|
961 | fn: function (warnings) {
|
962 | title("Missing global variable " + (warnings.length > 1 ? 'names' : 'name'));
|
963 | stderr("Use output.globals to specify browser global variable names corresponding to external modules");
|
964 | warnings.forEach(function (warning) {
|
965 | stderr(turbocolor.bold(warning.source) + " (guessing '" + warning.guess + "')");
|
966 | });
|
967 | },
|
968 | priority: 1
|
969 | },
|
970 | SOURCEMAP_BROKEN: {
|
971 | fn: function (warnings) {
|
972 | title("Broken sourcemap");
|
973 | info('https://rollupjs.org/guide/en#warning-sourcemap-is-likely-to-be-incorrect');
|
974 | var plugins = Array.from(new Set(warnings.map(function (w) { return w.plugin; }).filter(Boolean)));
|
975 | var detail = plugins.length === 0
|
976 | ? ''
|
977 | : plugins.length > 1
|
978 | ? " (such as " + plugins
|
979 | .slice(0, -1)
|
980 | .map(function (p) { return "'" + p + "'"; })
|
981 | .join(', ') + " and '" + plugins.slice(-1) + "')"
|
982 | : " (such as '" + plugins[0] + "')";
|
983 | stderr("Plugins that transform code" + detail + " should generate accompanying sourcemaps");
|
984 | },
|
985 | priority: 1
|
986 | },
|
987 | PLUGIN_WARNING: {
|
988 | fn: function (warnings) {
|
989 | var nestedByPlugin = nest(warnings, 'plugin');
|
990 | nestedByPlugin.forEach(function (_a) {
|
991 | var plugin = _a.key, items = _a.items;
|
992 | var nestedByMessage = nest(items, 'message');
|
993 | var lastUrl;
|
994 | nestedByMessage.forEach(function (_a) {
|
995 | var message = _a.key, items = _a.items;
|
996 | title(plugin + " plugin: " + message);
|
997 | items.forEach(function (warning) {
|
998 | if (warning.url !== lastUrl)
|
999 | info((lastUrl = warning.url));
|
1000 | if (warning.id) {
|
1001 | var loc = relativeId(warning.id);
|
1002 | if (warning.loc) {
|
1003 | loc += ": (" + warning.loc.line + ":" + warning.loc.column + ")";
|
1004 | }
|
1005 | stderr(turbocolor.bold(loc));
|
1006 | }
|
1007 | if (warning.frame)
|
1008 | info(warning.frame);
|
1009 | });
|
1010 | });
|
1011 | });
|
1012 | },
|
1013 | priority: 1
|
1014 | }
|
1015 | };
|
1016 | function title(str) {
|
1017 | stderr(turbocolor.bold.yellow('(!)') + " " + turbocolor.bold.yellow(str));
|
1018 | }
|
1019 | function info(url) {
|
1020 | stderr(turbocolor.gray(url));
|
1021 | }
|
1022 | function nest(array, prop) {
|
1023 | var nested = [];
|
1024 | var lookup = new Map();
|
1025 | array.forEach(function (item) {
|
1026 | var key = item[prop];
|
1027 | if (!lookup.has(key)) {
|
1028 | lookup.set(key, {
|
1029 | items: [],
|
1030 | key: key
|
1031 | });
|
1032 | nested.push(lookup.get(key));
|
1033 | }
|
1034 | lookup.get(key).items.push(item);
|
1035 | });
|
1036 | return nested;
|
1037 | }
|
1038 | function showTruncatedWarnings(warnings) {
|
1039 | var nestedByModule = nest(warnings, 'id');
|
1040 | var sliced = nestedByModule.length > 5 ? nestedByModule.slice(0, 3) : nestedByModule;
|
1041 | sliced.forEach(function (_a) {
|
1042 | var id = _a.key, items = _a.items;
|
1043 | stderr(turbocolor.bold(relativeId(id)));
|
1044 | stderr(turbocolor.gray(items[0].frame));
|
1045 | if (items.length > 1) {
|
1046 | stderr("...and " + (items.length - 1) + " other " + (items.length > 2 ? 'occurrences' : 'occurrence'));
|
1047 | }
|
1048 | });
|
1049 | if (nestedByModule.length > sliced.length) {
|
1050 | stderr("\n...and " + (nestedByModule.length - sliced.length) + " other files");
|
1051 | }
|
1052 | }
|
1053 |
|
1054 | var parseMs = ms => {
|
1055 | if (typeof ms !== 'number') {
|
1056 | throw new TypeError('Expected a number');
|
1057 | }
|
1058 |
|
1059 | const roundTowardsZero = ms > 0 ? Math.floor : Math.ceil;
|
1060 |
|
1061 | return {
|
1062 | days: roundTowardsZero(ms / 86400000),
|
1063 | hours: roundTowardsZero(ms / 3600000) % 24,
|
1064 | minutes: roundTowardsZero(ms / 60000) % 60,
|
1065 | seconds: roundTowardsZero(ms / 1000) % 60,
|
1066 | milliseconds: roundTowardsZero(ms) % 1000,
|
1067 | microseconds: roundTowardsZero(ms * 1000) % 1000,
|
1068 | nanoseconds: roundTowardsZero(ms * 1e6) % 1000
|
1069 | };
|
1070 | };
|
1071 |
|
1072 | const pluralize = (word, count) => count === 1 ? word : word + 's';
|
1073 |
|
1074 | var prettyMs = (ms, options = {}) => {
|
1075 | if (!Number.isFinite(ms)) {
|
1076 | throw new TypeError('Expected a finite number');
|
1077 | }
|
1078 |
|
1079 | if (options.compact) {
|
1080 | options.secDecimalDigits = 0;
|
1081 | options.msDecimalDigits = 0;
|
1082 | }
|
1083 |
|
1084 | const ret = [];
|
1085 |
|
1086 | const add = (value, long, short, valueString) => {
|
1087 | if (value === 0) {
|
1088 | return;
|
1089 | }
|
1090 |
|
1091 | const postfix = options.verbose ? ' ' + pluralize(long, value) : short;
|
1092 |
|
1093 | ret.push((valueString || value) + postfix);
|
1094 | };
|
1095 |
|
1096 | const secDecimalDigits = typeof options.secDecimalDigits === 'number' ? options.secDecimalDigits : 1;
|
1097 |
|
1098 | if (secDecimalDigits < 1) {
|
1099 | const diff = 1000 - (ms % 1000);
|
1100 | if (diff < 500) {
|
1101 | ms += diff;
|
1102 | }
|
1103 | }
|
1104 |
|
1105 | const parsed = parseMs(ms);
|
1106 |
|
1107 | add(Math.trunc(parsed.days / 365), 'year', 'y');
|
1108 | add(parsed.days % 365, 'day', 'd');
|
1109 | add(parsed.hours, 'hour', 'h');
|
1110 | add(parsed.minutes, 'minute', 'm');
|
1111 |
|
1112 | if (options.separateMs || options.formatSubMs || ms < 1000) {
|
1113 | add(parsed.seconds, 'second', 's');
|
1114 | if (options.formatSubMs) {
|
1115 | add(parsed.milliseconds, 'millisecond', 'ms');
|
1116 | add(parsed.microseconds, 'microsecond', 'µs');
|
1117 | add(parsed.nanoseconds, 'nanosecond', 'ns');
|
1118 | } else {
|
1119 | const msAndBelow = parsed.milliseconds + (parsed.microseconds / 1000) + (parsed.nanoseconds / 1e6);
|
1120 | const msDecimalDigits = typeof options.msDecimalDigits === 'number' ? options.msDecimalDigits : 0;
|
1121 | const msStr = msDecimalDigits ? msAndBelow.toFixed(msDecimalDigits) : Math.ceil(msAndBelow);
|
1122 | add(parseFloat(msStr, 10), 'millisecond', 'ms', msStr);
|
1123 | }
|
1124 | } else {
|
1125 | const sec = ms / 1000 % 60;
|
1126 | const secDecimalDigits = typeof options.secDecimalDigits === 'number' ? options.secDecimalDigits : 1;
|
1127 | const secFixed = sec.toFixed(secDecimalDigits);
|
1128 | const secStr = options.keepDecimalsOnWholeSeconds ? secFixed : secFixed.replace(/\.0+$/, '');
|
1129 | add(parseFloat(secStr, 10), 'second', 's', secStr);
|
1130 | }
|
1131 |
|
1132 | if (ret.length === 0) {
|
1133 | return '0' + (options.verbose ? ' milliseconds' : 'ms');
|
1134 | }
|
1135 |
|
1136 | if (options.compact) {
|
1137 | return '~' + ret[0];
|
1138 | }
|
1139 |
|
1140 | if (typeof options.unitCount === 'number') {
|
1141 | return '~' + ret.slice(0, Math.max(options.unitCount, 1)).join(' ');
|
1142 | }
|
1143 |
|
1144 | return ret.join(' ');
|
1145 | };
|
1146 |
|
1147 | var SOURCEMAPPING_URL = 'sourceMa';
|
1148 | SOURCEMAPPING_URL += 'ppingURL';
|
1149 | var SOURCEMAPPING_URL$1 = SOURCEMAPPING_URL;
|
1150 |
|
1151 | const UNITS = [
|
1152 | 'B',
|
1153 | 'kB',
|
1154 | 'MB',
|
1155 | 'GB',
|
1156 | 'TB',
|
1157 | 'PB',
|
1158 | 'EB',
|
1159 | 'ZB',
|
1160 | 'YB'
|
1161 | ];
|
1162 |
|
1163 | /*
|
1164 | Formats the given number using `Number#toLocaleString`.
|
1165 | - If locale is a string, the value is expected to be a locale-key (for example: `de`).
|
1166 | - If locale is true, the system default locale is used for translation.
|
1167 | - If no value for locale is specified, the number is returned unmodified.
|
1168 | */
|
1169 | const toLocaleString = (number, locale) => {
|
1170 | let result = number;
|
1171 | if (typeof locale === 'string') {
|
1172 | result = number.toLocaleString(locale);
|
1173 | } else if (locale === true) {
|
1174 | result = number.toLocaleString();
|
1175 | }
|
1176 |
|
1177 | return result;
|
1178 | };
|
1179 |
|
1180 | var prettyBytes = (number, options) => {
|
1181 | if (!Number.isFinite(number)) {
|
1182 | throw new TypeError(`Expected a finite number, got ${typeof number}: ${number}`);
|
1183 | }
|
1184 |
|
1185 | options = Object.assign({}, options);
|
1186 |
|
1187 | if (options.signed && number === 0) {
|
1188 | return ' 0 B';
|
1189 | }
|
1190 |
|
1191 | const isNegative = number < 0;
|
1192 | const prefix = isNegative ? '-' : (options.signed ? '+' : '');
|
1193 |
|
1194 | if (isNegative) {
|
1195 | number = -number;
|
1196 | }
|
1197 |
|
1198 | if (number < 1) {
|
1199 | const numberString = toLocaleString(number, options.locale);
|
1200 | return prefix + numberString + ' B';
|
1201 | }
|
1202 |
|
1203 | const exponent = Math.min(Math.floor(Math.log10(number) / 3), UNITS.length - 1);
|
1204 | number = Number((number / Math.pow(1000, exponent)).toPrecision(3));
|
1205 | const numberString = toLocaleString(number, options.locale);
|
1206 |
|
1207 | const unit = UNITS[exponent];
|
1208 |
|
1209 | return prefix + numberString + ' ' + unit;
|
1210 | };
|
1211 |
|
1212 | function printTimings(timings) {
|
1213 | Object.keys(timings).forEach(function (label) {
|
1214 | var color = label[0] === '#' ? (label[1] !== '#' ? turbocolor.underline : turbocolor.bold) : function (text) { return text; };
|
1215 | var _a = timings[label], time = _a[0], memory = _a[1], total = _a[2];
|
1216 | var row = label + ": " + time.toFixed(0) + "ms, " + prettyBytes(memory) + " / " + prettyBytes(total);
|
1217 | console.info(color(row));
|
1218 | });
|
1219 | }
|
1220 |
|
1221 | function build(inputOptions, outputOptions, warnings, silent) {
|
1222 | if (silent === void 0) { silent = false; }
|
1223 | var useStdout = !outputOptions[0].file && !outputOptions[0].dir;
|
1224 | var start = Date.now();
|
1225 | var files = useStdout ? ['stdout'] : outputOptions.map(function (t) { return relativeId(t.file || t.dir); });
|
1226 | if (!silent) {
|
1227 | var inputFiles = void 0;
|
1228 | if (typeof inputOptions.input === 'string') {
|
1229 | inputFiles = inputOptions.input;
|
1230 | }
|
1231 | else if (inputOptions.input instanceof Array) {
|
1232 | inputFiles = inputOptions.input.join(', ');
|
1233 | }
|
1234 | else if (typeof inputOptions.input === 'object' && inputOptions.input !== null) {
|
1235 | inputFiles = Object.keys(inputOptions.input)
|
1236 | .map(function (name) { return inputOptions.input[name]; })
|
1237 | .join(', ');
|
1238 | }
|
1239 | stderr(turbocolor.cyan("\n" + turbocolor.bold(inputFiles) + " \u2192 " + turbocolor.bold(files.join(', ')) + "..."));
|
1240 | }
|
1241 | return rollup.rollup(inputOptions)
|
1242 | .then(function (bundle) {
|
1243 | if (useStdout) {
|
1244 | var output_1 = outputOptions[0];
|
1245 | if (output_1.sourcemap && output_1.sourcemap !== 'inline') {
|
1246 | handleError({
|
1247 | code: 'MISSING_OUTPUT_OPTION',
|
1248 | message: 'You must specify a --file (-o) option when creating a file with a sourcemap'
|
1249 | });
|
1250 | }
|
1251 | return bundle.generate(output_1).then(function (_a) {
|
1252 | var outputs = _a.output;
|
1253 | for (var _i = 0, outputs_1 = outputs; _i < outputs_1.length; _i++) {
|
1254 | var file = outputs_1[_i];
|
1255 | var source = void 0;
|
1256 | if (file.isAsset) {
|
1257 | source = file.source;
|
1258 | }
|
1259 | else {
|
1260 | source = file.code;
|
1261 | if (output_1.sourcemap === 'inline') {
|
1262 | source += "\n//# " + SOURCEMAPPING_URL$1 + "=" + file.map.toUrl() + "\n";
|
1263 | }
|
1264 | }
|
1265 | if (outputs.length > 1)
|
1266 | process.stdout.write('\n' + turbocolor.cyan(turbocolor.bold('//→ ' + file.fileName + ':')) + '\n');
|
1267 | process.stdout.write(source);
|
1268 | }
|
1269 | });
|
1270 | }
|
1271 | return Promise.all(outputOptions.map(function (output) { return bundle.write(output); })).then(function () { return bundle; });
|
1272 | })
|
1273 | .then(function (bundle) {
|
1274 | warnings.flush();
|
1275 | if (!silent)
|
1276 | stderr(turbocolor.green("created " + turbocolor.bold(files.join(', ')) + " in " + turbocolor.bold(prettyMs(Date.now() - start))));
|
1277 | if (bundle && bundle.getTimings) {
|
1278 | printTimings(bundle.getTimings());
|
1279 | }
|
1280 | })
|
1281 | .catch(function (err) {
|
1282 | if (warnings.count > 0)
|
1283 | warnings.flush();
|
1284 | handleError(err);
|
1285 | });
|
1286 | }
|
1287 |
|
1288 | function loadConfigFile(configFile, commandOptions) {
|
1289 | if (commandOptions === void 0) { commandOptions = {}; }
|
1290 | var silent = commandOptions.silent || false;
|
1291 | var warnings = batchWarnings();
|
1292 | return rollup__default
|
1293 | .rollup({
|
1294 | external: function (id) {
|
1295 | return (id[0] !== '.' && !path__default.isAbsolute(id)) || id.slice(-5, id.length) === '.json';
|
1296 | },
|
1297 | input: configFile,
|
1298 | onwarn: warnings.add,
|
1299 | treeshake: false
|
1300 | })
|
1301 | .then(function (bundle) {
|
1302 | if (!silent && warnings.count > 0) {
|
1303 | stderr(turbocolor.bold("loaded " + relativeId(configFile) + " with warnings"));
|
1304 | warnings.flush();
|
1305 | }
|
1306 | return bundle.generate({
|
1307 | exports: 'named',
|
1308 | format: 'cjs'
|
1309 | });
|
1310 | })
|
1311 | .then(function (_a) {
|
1312 | var code = _a.output[0].code;
|
1313 | // temporarily override require
|
1314 | var defaultLoader = require.extensions['.js'];
|
1315 | require.extensions['.js'] = function (module, filename) {
|
1316 | if (filename === configFile) {
|
1317 | module._compile(code, filename);
|
1318 | }
|
1319 | else {
|
1320 | defaultLoader(module, filename);
|
1321 | }
|
1322 | };
|
1323 | delete require.cache[configFile];
|
1324 | return Promise.resolve(require(configFile))
|
1325 | .then(function (configFileContent) {
|
1326 | if (configFileContent.default)
|
1327 | configFileContent = configFileContent.default;
|
1328 | if (typeof configFileContent === 'function') {
|
1329 | return configFileContent(commandOptions);
|
1330 | }
|
1331 | return configFileContent;
|
1332 | })
|
1333 | .then(function (configs) {
|
1334 | if (Object.keys(configs).length === 0) {
|
1335 | handleError({
|
1336 | code: 'MISSING_CONFIG',
|
1337 | message: 'Config file must export an options object, or an array of options objects',
|
1338 | url: 'https://rollupjs.org/guide/en#configuration-files'
|
1339 | });
|
1340 | }
|
1341 | require.extensions['.js'] = defaultLoader;
|
1342 | return Array.isArray(configs) ? configs : [configs];
|
1343 | });
|
1344 | });
|
1345 | }
|
1346 |
|
1347 | var timeZone = date => {
|
1348 | const offset = (date || new Date()).getTimezoneOffset();
|
1349 | const absOffset = Math.abs(offset);
|
1350 | const hours = Math.floor(absOffset / 60);
|
1351 | const minutes = absOffset % 60;
|
1352 | const minutesOut = minutes > 0 ? ':' + ('0' + minutes).slice(-2) : '';
|
1353 |
|
1354 | return (offset < 0 ? '+' : '-') + hours + minutesOut;
|
1355 | };
|
1356 |
|
1357 | const dateTime = options => {
|
1358 | options = Object.assign({
|
1359 | date: new Date(),
|
1360 | local: true,
|
1361 | showTimeZone: false,
|
1362 | showMilliseconds: false
|
1363 | }, options);
|
1364 |
|
1365 | let {date} = options;
|
1366 |
|
1367 | if (options.local) {
|
1368 | // Offset the date so it will return the correct value when getting the ISO string
|
1369 | date = new Date(date.getTime() - (date.getTimezoneOffset() * 60000));
|
1370 | }
|
1371 |
|
1372 | let end = '';
|
1373 |
|
1374 | if (options.showTimeZone) {
|
1375 | end = ' UTC' + (options.local ? timeZone(date) : '');
|
1376 | }
|
1377 |
|
1378 | if (options.showMilliseconds && date.getUTCMilliseconds() > 0) {
|
1379 | end = ` ${date.getUTCMilliseconds()}ms${end}`;
|
1380 | }
|
1381 |
|
1382 | return date
|
1383 | .toISOString()
|
1384 | .replace(/T/, ' ')
|
1385 | .replace(/\..+/, end);
|
1386 | };
|
1387 |
|
1388 | var dateTime_1 = dateTime;
|
1389 | // TODO: Remove this for the next major release
|
1390 | var default_1 = dateTime;
|
1391 | dateTime_1.default = default_1;
|
1392 |
|
1393 | function createCommonjsModule(fn, module) {
|
1394 | return module = { exports: {} }, fn(module, module.exports), module.exports;
|
1395 | }
|
1396 |
|
1397 | var signals = createCommonjsModule(function (module) {
|
1398 | // This is not the set of all possible signals.
|
1399 | //
|
1400 | // It IS, however, the set of all signals that trigger
|
1401 | // an exit on either Linux or BSD systems. Linux is a
|
1402 | // superset of the signal names supported on BSD, and
|
1403 | // the unknown signals just fail to register, so we can
|
1404 | // catch that easily enough.
|
1405 | //
|
1406 | // Don't bother with SIGKILL. It's uncatchable, which
|
1407 | // means that we can't fire any callbacks anyway.
|
1408 | //
|
1409 | // If a user does happen to register a handler on a non-
|
1410 | // fatal signal like SIGWINCH or something, and then
|
1411 | // exit, it'll end up firing `process.emit('exit')`, so
|
1412 | // the handler will be fired anyway.
|
1413 | //
|
1414 | // SIGBUS, SIGFPE, SIGSEGV and SIGILL, when not raised
|
1415 | // artificially, inherently leave the process in a
|
1416 | // state from which it is not safe to try and enter JS
|
1417 | // listeners.
|
1418 | module.exports = [
|
1419 | 'SIGABRT',
|
1420 | 'SIGALRM',
|
1421 | 'SIGHUP',
|
1422 | 'SIGINT',
|
1423 | 'SIGTERM'
|
1424 | ];
|
1425 |
|
1426 | if (process.platform !== 'win32') {
|
1427 | module.exports.push(
|
1428 | 'SIGVTALRM',
|
1429 | 'SIGXCPU',
|
1430 | 'SIGXFSZ',
|
1431 | 'SIGUSR2',
|
1432 | 'SIGTRAP',
|
1433 | 'SIGSYS',
|
1434 | 'SIGQUIT',
|
1435 | 'SIGIOT'
|
1436 | // should detect profiler and enable/disable accordingly.
|
1437 | // see #21
|
1438 | // 'SIGPROF'
|
1439 | );
|
1440 | }
|
1441 |
|
1442 | if (process.platform === 'linux') {
|
1443 | module.exports.push(
|
1444 | 'SIGIO',
|
1445 | 'SIGPOLL',
|
1446 | 'SIGPWR',
|
1447 | 'SIGSTKFLT',
|
1448 | 'SIGUNUSED'
|
1449 | );
|
1450 | }
|
1451 | });
|
1452 |
|
1453 | // Note: since nyc uses this module to output coverage, any lines
|
1454 | // that are in the direct sync flow of nyc's outputCoverage are
|
1455 | // ignored, since we can never get coverage for them.
|
1456 |
|
1457 | var signals$1 = signals;
|
1458 |
|
1459 | var EE = events;
|
1460 | /* istanbul ignore if */
|
1461 | if (typeof EE !== 'function') {
|
1462 | EE = EE.EventEmitter;
|
1463 | }
|
1464 |
|
1465 | var emitter;
|
1466 | if (process.__signal_exit_emitter__) {
|
1467 | emitter = process.__signal_exit_emitter__;
|
1468 | } else {
|
1469 | emitter = process.__signal_exit_emitter__ = new EE();
|
1470 | emitter.count = 0;
|
1471 | emitter.emitted = {};
|
1472 | }
|
1473 |
|
1474 | // Because this emitter is a global, we have to check to see if a
|
1475 | // previous version of this library failed to enable infinite listeners.
|
1476 | // I know what you're about to say. But literally everything about
|
1477 | // signal-exit is a compromise with evil. Get used to it.
|
1478 | if (!emitter.infinite) {
|
1479 | emitter.setMaxListeners(Infinity);
|
1480 | emitter.infinite = true;
|
1481 | }
|
1482 |
|
1483 | var signalExit = function (cb, opts) {
|
1484 | assert.equal(typeof cb, 'function', 'a callback must be provided for exit handler');
|
1485 |
|
1486 | if (loaded === false) {
|
1487 | load();
|
1488 | }
|
1489 |
|
1490 | var ev = 'exit';
|
1491 | if (opts && opts.alwaysLast) {
|
1492 | ev = 'afterexit';
|
1493 | }
|
1494 |
|
1495 | var remove = function () {
|
1496 | emitter.removeListener(ev, cb);
|
1497 | if (emitter.listeners('exit').length === 0 &&
|
1498 | emitter.listeners('afterexit').length === 0) {
|
1499 | unload();
|
1500 | }
|
1501 | };
|
1502 | emitter.on(ev, cb);
|
1503 |
|
1504 | return remove
|
1505 | };
|
1506 |
|
1507 | var unload_1 = unload;
|
1508 | function unload () {
|
1509 | if (!loaded) {
|
1510 | return
|
1511 | }
|
1512 | loaded = false;
|
1513 |
|
1514 | signals$1.forEach(function (sig) {
|
1515 | try {
|
1516 | process.removeListener(sig, sigListeners[sig]);
|
1517 | } catch (er) {}
|
1518 | });
|
1519 | process.emit = originalProcessEmit;
|
1520 | process.reallyExit = originalProcessReallyExit;
|
1521 | emitter.count -= 1;
|
1522 | }
|
1523 |
|
1524 | function emit (event, code, signal) {
|
1525 | if (emitter.emitted[event]) {
|
1526 | return
|
1527 | }
|
1528 | emitter.emitted[event] = true;
|
1529 | emitter.emit(event, code, signal);
|
1530 | }
|
1531 |
|
1532 | // { <signal>: <listener fn>, ... }
|
1533 | var sigListeners = {};
|
1534 | signals$1.forEach(function (sig) {
|
1535 | sigListeners[sig] = function listener () {
|
1536 | // If there are no other listeners, an exit is coming!
|
1537 | // Simplest way: remove us and then re-send the signal.
|
1538 | // We know that this will kill the process, so we can
|
1539 | // safely emit now.
|
1540 | var listeners = process.listeners(sig);
|
1541 | if (listeners.length === emitter.count) {
|
1542 | unload();
|
1543 | emit('exit', null, sig);
|
1544 | /* istanbul ignore next */
|
1545 | emit('afterexit', null, sig);
|
1546 | /* istanbul ignore next */
|
1547 | process.kill(process.pid, sig);
|
1548 | }
|
1549 | };
|
1550 | });
|
1551 |
|
1552 | var signals_1 = function () {
|
1553 | return signals$1
|
1554 | };
|
1555 |
|
1556 | var load_1 = load;
|
1557 |
|
1558 | var loaded = false;
|
1559 |
|
1560 | function load () {
|
1561 | if (loaded) {
|
1562 | return
|
1563 | }
|
1564 | loaded = true;
|
1565 |
|
1566 | // This is the number of onSignalExit's that are in play.
|
1567 | // It's important so that we can count the correct number of
|
1568 | // listeners on signals, and don't wait for the other one to
|
1569 | // handle it instead of us.
|
1570 | emitter.count += 1;
|
1571 |
|
1572 | signals$1 = signals$1.filter(function (sig) {
|
1573 | try {
|
1574 | process.on(sig, sigListeners[sig]);
|
1575 | return true
|
1576 | } catch (er) {
|
1577 | return false
|
1578 | }
|
1579 | });
|
1580 |
|
1581 | process.emit = processEmit;
|
1582 | process.reallyExit = processReallyExit;
|
1583 | }
|
1584 |
|
1585 | var originalProcessReallyExit = process.reallyExit;
|
1586 | function processReallyExit (code) {
|
1587 | process.exitCode = code || 0;
|
1588 | emit('exit', process.exitCode, null);
|
1589 | /* istanbul ignore next */
|
1590 | emit('afterexit', process.exitCode, null);
|
1591 | /* istanbul ignore next */
|
1592 | originalProcessReallyExit.call(process, process.exitCode);
|
1593 | }
|
1594 |
|
1595 | var originalProcessEmit = process.emit;
|
1596 | function processEmit (ev, arg) {
|
1597 | if (ev === 'exit') {
|
1598 | if (arg !== undefined) {
|
1599 | process.exitCode = arg;
|
1600 | }
|
1601 | var ret = originalProcessEmit.apply(this, arguments);
|
1602 | emit('exit', process.exitCode, null);
|
1603 | /* istanbul ignore next */
|
1604 | emit('afterexit', process.exitCode, null);
|
1605 | return ret
|
1606 | } else {
|
1607 | return originalProcessEmit.apply(this, arguments)
|
1608 | }
|
1609 | }
|
1610 | signalExit.unload = unload_1;
|
1611 | signalExit.signals = signals_1;
|
1612 | signalExit.load = load_1;
|
1613 |
|
1614 | var ansiEscapes_1 = createCommonjsModule(function (module) {
|
1615 | const ansiEscapes = module.exports;
|
1616 | // TODO: remove this in the next major version
|
1617 | module.exports.default = ansiEscapes;
|
1618 |
|
1619 | const ESC = '\u001B[';
|
1620 | const OSC = '\u001B]';
|
1621 | const BEL = '\u0007';
|
1622 | const SEP = ';';
|
1623 | const isTerminalApp = process.env.TERM_PROGRAM === 'Apple_Terminal';
|
1624 |
|
1625 | ansiEscapes.cursorTo = (x, y) => {
|
1626 | if (typeof x !== 'number') {
|
1627 | throw new TypeError('The `x` argument is required');
|
1628 | }
|
1629 |
|
1630 | if (typeof y !== 'number') {
|
1631 | return ESC + (x + 1) + 'G';
|
1632 | }
|
1633 |
|
1634 | return ESC + (y + 1) + ';' + (x + 1) + 'H';
|
1635 | };
|
1636 |
|
1637 | ansiEscapes.cursorMove = (x, y) => {
|
1638 | if (typeof x !== 'number') {
|
1639 | throw new TypeError('The `x` argument is required');
|
1640 | }
|
1641 |
|
1642 | let ret = '';
|
1643 |
|
1644 | if (x < 0) {
|
1645 | ret += ESC + (-x) + 'D';
|
1646 | } else if (x > 0) {
|
1647 | ret += ESC + x + 'C';
|
1648 | }
|
1649 |
|
1650 | if (y < 0) {
|
1651 | ret += ESC + (-y) + 'A';
|
1652 | } else if (y > 0) {
|
1653 | ret += ESC + y + 'B';
|
1654 | }
|
1655 |
|
1656 | return ret;
|
1657 | };
|
1658 |
|
1659 | ansiEscapes.cursorUp = (count = 1) => ESC + count + 'A';
|
1660 | ansiEscapes.cursorDown = (count = 1) => ESC + count + 'B';
|
1661 | ansiEscapes.cursorForward = (count = 1) => ESC + count + 'C';
|
1662 | ansiEscapes.cursorBackward = (count = 1) => ESC + count + 'D';
|
1663 |
|
1664 | ansiEscapes.cursorLeft = ESC + 'G';
|
1665 | ansiEscapes.cursorSavePosition = ESC + (isTerminalApp ? '7' : 's');
|
1666 | ansiEscapes.cursorRestorePosition = ESC + (isTerminalApp ? '8' : 'u');
|
1667 | ansiEscapes.cursorGetPosition = ESC + '6n';
|
1668 | ansiEscapes.cursorNextLine = ESC + 'E';
|
1669 | ansiEscapes.cursorPrevLine = ESC + 'F';
|
1670 | ansiEscapes.cursorHide = ESC + '?25l';
|
1671 | ansiEscapes.cursorShow = ESC + '?25h';
|
1672 |
|
1673 | ansiEscapes.eraseLines = count => {
|
1674 | let clear = '';
|
1675 |
|
1676 | for (let i = 0; i < count; i++) {
|
1677 | clear += ansiEscapes.eraseLine + (i < count - 1 ? ansiEscapes.cursorUp() : '');
|
1678 | }
|
1679 |
|
1680 | if (count) {
|
1681 | clear += ansiEscapes.cursorLeft;
|
1682 | }
|
1683 |
|
1684 | return clear;
|
1685 | };
|
1686 |
|
1687 | ansiEscapes.eraseEndLine = ESC + 'K';
|
1688 | ansiEscapes.eraseStartLine = ESC + '1K';
|
1689 | ansiEscapes.eraseLine = ESC + '2K';
|
1690 | ansiEscapes.eraseDown = ESC + 'J';
|
1691 | ansiEscapes.eraseUp = ESC + '1J';
|
1692 | ansiEscapes.eraseScreen = ESC + '2J';
|
1693 | ansiEscapes.scrollUp = ESC + 'S';
|
1694 | ansiEscapes.scrollDown = ESC + 'T';
|
1695 |
|
1696 | ansiEscapes.clearScreen = '\u001Bc';
|
1697 |
|
1698 | ansiEscapes.clearTerminal = process.platform === 'win32' ?
|
1699 | `${ansiEscapes.eraseScreen}${ESC}0f` :
|
1700 | // 1. Erases the screen (Only done in case `2` is not supported)
|
1701 | // 2. Erases the whole screen including scrollback buffer
|
1702 | // 3. Moves cursor to the top-left position
|
1703 | // More info: https://www.real-world-systems.com/docs/ANSIcode.html
|
1704 | `${ansiEscapes.eraseScreen}${ESC}3J${ESC}H`;
|
1705 |
|
1706 | ansiEscapes.beep = BEL;
|
1707 |
|
1708 | ansiEscapes.link = (text, url) => {
|
1709 | return [
|
1710 | OSC,
|
1711 | '8',
|
1712 | SEP,
|
1713 | SEP,
|
1714 | url,
|
1715 | BEL,
|
1716 | text,
|
1717 | OSC,
|
1718 | '8',
|
1719 | SEP,
|
1720 | SEP,
|
1721 | BEL
|
1722 | ].join('');
|
1723 | };
|
1724 |
|
1725 | ansiEscapes.image = (buffer, options = {}) => {
|
1726 | let ret = `${OSC}1337;File=inline=1`;
|
1727 |
|
1728 | if (options.width) {
|
1729 | ret += `;width=${options.width}`;
|
1730 | }
|
1731 |
|
1732 | if (options.height) {
|
1733 | ret += `;height=${options.height}`;
|
1734 | }
|
1735 |
|
1736 | if (options.preserveAspectRatio === false) {
|
1737 | ret += ';preserveAspectRatio=0';
|
1738 | }
|
1739 |
|
1740 | return ret + ':' + buffer.toString('base64') + BEL;
|
1741 | };
|
1742 |
|
1743 | ansiEscapes.iTerm = {
|
1744 | setCwd: (cwd = process.cwd()) => `${OSC}50;CurrentDir=${cwd}${BEL}`
|
1745 | };
|
1746 | });
|
1747 |
|
1748 | var SHOW_ALTERNATE_SCREEN = '\u001B[?1049h';
|
1749 | var HIDE_ALTERNATE_SCREEN = '\u001B[?1049l';
|
1750 | var isWindows = process.platform === 'win32';
|
1751 | var isMintty = isWindows && !!(process.env.SHELL || process.env.TERM);
|
1752 | var isConEmuAnsiOn = (process.env.ConEmuANSI || '').toLowerCase() === 'on';
|
1753 | var supportsAnsi = !isWindows || isMintty || isConEmuAnsiOn;
|
1754 | function alternateScreen(enabled) {
|
1755 | if (!enabled) {
|
1756 | var needAnnounce_1 = true;
|
1757 | return {
|
1758 | open: function () { },
|
1759 | close: function () { },
|
1760 | reset: function (heading) {
|
1761 | if (needAnnounce_1) {
|
1762 | stderr(heading);
|
1763 | needAnnounce_1 = false;
|
1764 | }
|
1765 | }
|
1766 | };
|
1767 | }
|
1768 | return {
|
1769 | open: function () {
|
1770 | if (supportsAnsi) {
|
1771 | process.stderr.write(SHOW_ALTERNATE_SCREEN);
|
1772 | }
|
1773 | },
|
1774 | close: function () {
|
1775 | if (supportsAnsi) {
|
1776 | process.stderr.write(HIDE_ALTERNATE_SCREEN);
|
1777 | }
|
1778 | },
|
1779 | reset: function (heading) {
|
1780 | stderr("" + ansiEscapes_1.eraseScreen + ansiEscapes_1.cursorTo(0, 0) + heading);
|
1781 | }
|
1782 | };
|
1783 | }
|
1784 |
|
1785 | function watch(configFile, configs, command, silent) {
|
1786 | if (silent === void 0) { silent = false; }
|
1787 | var isTTY = Boolean(process.stderr.isTTY);
|
1788 | var warnings = batchWarnings();
|
1789 | var initialConfigs = processConfigs(configs);
|
1790 | var clearScreen = initialConfigs.every(function (config) { return config.watch.clearScreen !== false; });
|
1791 | var screen = alternateScreen(isTTY && clearScreen);
|
1792 | screen.open();
|
1793 | var watcher;
|
1794 | var configWatcher;
|
1795 | var processConfigsErr;
|
1796 | function processConfigs(configs) {
|
1797 | return configs.map(function (options) {
|
1798 | var merged = mergeOptions({
|
1799 | command: command,
|
1800 | config: options,
|
1801 | defaultOnWarnHandler: warnings.add
|
1802 | });
|
1803 | var result = __assign({}, merged.inputOptions, { output: merged.outputOptions });
|
1804 | if (!result.watch)
|
1805 | result.watch = {};
|
1806 | if (merged.optionError)
|
1807 | merged.inputOptions.onwarn({
|
1808 | code: 'UNKNOWN_OPTION',
|
1809 | message: merged.optionError
|
1810 | });
|
1811 | if (merged.inputOptions.watch &&
|
1812 | merged.inputOptions.watch.clearScreen === false) {
|
1813 | processConfigsErr = stderr;
|
1814 | }
|
1815 | return result;
|
1816 | });
|
1817 | }
|
1818 | function start(configs) {
|
1819 | var screenWriter = processConfigsErr || screen.reset;
|
1820 | watcher = rollup.watch(configs);
|
1821 | watcher.on('event', function (event) {
|
1822 | switch (event.code) {
|
1823 | case 'FATAL':
|
1824 | screen.close();
|
1825 | handleError(event.error, true);
|
1826 | process.exit(1);
|
1827 | break;
|
1828 | case 'ERROR':
|
1829 | warnings.flush();
|
1830 | handleError(event.error, true);
|
1831 | break;
|
1832 | case 'START':
|
1833 | if (!silent) {
|
1834 | screenWriter(turbocolor.underline("rollup v" + rollup.VERSION));
|
1835 | }
|
1836 | break;
|
1837 | case 'BUNDLE_START':
|
1838 | if (!silent) {
|
1839 | var input_1 = event.input;
|
1840 | if (typeof input_1 !== 'string') {
|
1841 | input_1 = Array.isArray(input_1)
|
1842 | ? input_1.join(', ')
|
1843 | : Object.keys(input_1)
|
1844 | .map(function (key) { return input_1[key]; })
|
1845 | .join(', ');
|
1846 | }
|
1847 | stderr(turbocolor.cyan("bundles " + turbocolor.bold(input_1) + " \u2192 " + turbocolor.bold(event.output.map(relativeId).join(', ')) + "..."));
|
1848 | }
|
1849 | break;
|
1850 | case 'BUNDLE_END':
|
1851 | warnings.flush();
|
1852 | if (!silent)
|
1853 | stderr(turbocolor.green("created " + turbocolor.bold(event.output.map(relativeId).join(', ')) + " in " + turbocolor.bold(prettyMs(event.duration))));
|
1854 | if (event.result && event.result.getTimings) {
|
1855 | printTimings(event.result.getTimings());
|
1856 | }
|
1857 | break;
|
1858 | case 'END':
|
1859 | if (!silent && isTTY) {
|
1860 | stderr("\n[" + dateTime_1() + "] waiting for changes...");
|
1861 | }
|
1862 | }
|
1863 | });
|
1864 | }
|
1865 | // catch ctrl+c, kill, and uncaught errors
|
1866 | var removeOnExit = signalExit(close);
|
1867 | process.on('uncaughtException', close);
|
1868 | // only listen to stdin if it is a pipe
|
1869 | if (!process.stdin.isTTY) {
|
1870 | process.stdin.on('end', close); // in case we ever support stdin!
|
1871 | }
|
1872 | function close(err) {
|
1873 | removeOnExit();
|
1874 | process.removeListener('uncaughtException', close);
|
1875 | // removing a non-existent listener is a no-op
|
1876 | process.stdin.removeListener('end', close);
|
1877 | screen.close();
|
1878 | if (watcher)
|
1879 | watcher.close();
|
1880 | if (configWatcher)
|
1881 | configWatcher.close();
|
1882 | if (err) {
|
1883 | console.error(err);
|
1884 | process.exit(1);
|
1885 | }
|
1886 | }
|
1887 | try {
|
1888 | start(initialConfigs);
|
1889 | }
|
1890 | catch (err) {
|
1891 | close(err);
|
1892 | return;
|
1893 | }
|
1894 | if (configFile && !configFile.startsWith('node:')) {
|
1895 | var restarting_1 = false;
|
1896 | var aborted_1 = false;
|
1897 | var configFileData_1 = fs__default.readFileSync(configFile, 'utf-8');
|
1898 | var restart_1 = function () {
|
1899 | var newConfigFileData = fs__default.readFileSync(configFile, 'utf-8');
|
1900 | if (newConfigFileData === configFileData_1)
|
1901 | return;
|
1902 | configFileData_1 = newConfigFileData;
|
1903 | if (restarting_1) {
|
1904 | aborted_1 = true;
|
1905 | return;
|
1906 | }
|
1907 | restarting_1 = true;
|
1908 | loadConfigFile(configFile, command)
|
1909 | .then(function (_configs) {
|
1910 | restarting_1 = false;
|
1911 | if (aborted_1) {
|
1912 | aborted_1 = false;
|
1913 | restart_1();
|
1914 | }
|
1915 | else {
|
1916 | watcher.close();
|
1917 | start(initialConfigs);
|
1918 | }
|
1919 | })
|
1920 | .catch(function (err) {
|
1921 | handleError(err, true);
|
1922 | });
|
1923 | };
|
1924 | configWatcher = fs__default.watch(configFile, function (event) {
|
1925 | if (event === 'change')
|
1926 | restart_1();
|
1927 | });
|
1928 | }
|
1929 | }
|
1930 |
|
1931 | function runRollup(command) {
|
1932 | var inputSource;
|
1933 | if (command._.length > 0) {
|
1934 | if (command.input) {
|
1935 | handleError({
|
1936 | code: 'DUPLICATE_IMPORT_OPTIONS',
|
1937 | message: 'use --input, or pass input path as argument'
|
1938 | });
|
1939 | }
|
1940 | inputSource = command._;
|
1941 | }
|
1942 | else if (typeof command.input === 'string') {
|
1943 | inputSource = [command.input];
|
1944 | }
|
1945 | else {
|
1946 | inputSource = command.input;
|
1947 | }
|
1948 | if (inputSource && inputSource.length > 0) {
|
1949 | if (inputSource.some(function (input) { return input.indexOf('=') !== -1; })) {
|
1950 | command.input = {};
|
1951 | inputSource.forEach(function (input) {
|
1952 | var equalsIndex = input.indexOf('=');
|
1953 | var value = input.substr(equalsIndex + 1);
|
1954 | var key = input.substr(0, equalsIndex);
|
1955 | if (!key)
|
1956 | key = getAliasName(input);
|
1957 | command.input[key] = value;
|
1958 | });
|
1959 | }
|
1960 | else {
|
1961 | command.input = inputSource;
|
1962 | }
|
1963 | }
|
1964 | if (command.environment) {
|
1965 | var environment = Array.isArray(command.environment)
|
1966 | ? command.environment
|
1967 | : [command.environment];
|
1968 | environment.forEach(function (arg) {
|
1969 | arg.split(',').forEach(function (pair) {
|
1970 | var _a = pair.split(':'), key = _a[0], value = _a[1];
|
1971 | if (value) {
|
1972 | process.env[key] = value;
|
1973 | }
|
1974 | else {
|
1975 | process.env[key] = String(true);
|
1976 | }
|
1977 | });
|
1978 | });
|
1979 | }
|
1980 | var configFile = command.config === true ? 'rollup.config.js' : command.config;
|
1981 | if (configFile) {
|
1982 | if (configFile.slice(0, 5) === 'node:') {
|
1983 | var pkgName = configFile.slice(5);
|
1984 | try {
|
1985 | configFile = requireRelative_1.resolve("rollup-config-" + pkgName, process.cwd());
|
1986 | }
|
1987 | catch (err) {
|
1988 | try {
|
1989 | configFile = requireRelative_1.resolve(pkgName, process.cwd());
|
1990 | }
|
1991 | catch (err) {
|
1992 | if (err.code === 'MODULE_NOT_FOUND') {
|
1993 | handleError({
|
1994 | code: 'MISSING_EXTERNAL_CONFIG',
|
1995 | message: "Could not resolve config file " + configFile
|
1996 | });
|
1997 | }
|
1998 | throw err;
|
1999 | }
|
2000 | }
|
2001 | }
|
2002 | else {
|
2003 | // find real path of config so it matches what Node provides to callbacks in require.extensions
|
2004 | configFile = fs.realpathSync(configFile);
|
2005 | }
|
2006 | if (command.watch)
|
2007 | process.env.ROLLUP_WATCH = 'true';
|
2008 | loadConfigFile(configFile, command)
|
2009 | .then(function (configs) { return execute(configFile, configs, command); })
|
2010 | .catch(handleError);
|
2011 | }
|
2012 | else {
|
2013 | return execute(configFile, [{ input: null }], command);
|
2014 | }
|
2015 | }
|
2016 | function execute(configFile, configs, command) {
|
2017 | if (command.watch) {
|
2018 | watch(configFile, configs, command, command.silent);
|
2019 | }
|
2020 | else {
|
2021 | var promise = Promise.resolve();
|
2022 | var _loop_1 = function (config) {
|
2023 | promise = promise.then(function () {
|
2024 | var warnings = batchWarnings();
|
2025 | var _a = mergeOptions({
|
2026 | command: command,
|
2027 | config: config,
|
2028 | defaultOnWarnHandler: warnings.add
|
2029 | }), inputOptions = _a.inputOptions, outputOptions = _a.outputOptions, optionError = _a.optionError;
|
2030 | if (optionError)
|
2031 | inputOptions.onwarn({ code: 'UNKNOWN_OPTION', message: optionError });
|
2032 | return build(inputOptions, outputOptions, warnings, command.silent);
|
2033 | });
|
2034 | };
|
2035 | for (var _i = 0, configs_1 = configs; _i < configs_1.length; _i++) {
|
2036 | var config = configs_1[_i];
|
2037 | _loop_1(config);
|
2038 | }
|
2039 | return promise;
|
2040 | }
|
2041 | }
|
2042 |
|
2043 | var command = minimist(process.argv.slice(2), {
|
2044 | alias: commandAliases
|
2045 | });
|
2046 | if (command.help || (process.argv.length <= 2 && process.stdin.isTTY)) {
|
2047 | console.log("\n" + help.replace('__VERSION__', version) + "\n"); // eslint-disable-line no-console
|
2048 | }
|
2049 | else if (command.version) {
|
2050 | console.log("rollup v" + version); // eslint-disable-line no-console
|
2051 | }
|
2052 | else {
|
2053 | try {
|
2054 | require('source-map-support').install();
|
2055 | }
|
2056 | catch (err) {
|
2057 | // do nothing
|
2058 | }
|
2059 | runRollup(command);
|
2060 | }
|