#!/usr/bin/env node 'use strict'; function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } var fs = require('fs'); var fs__default = _interopDefault(fs); var path = require('path'); var path__default = _interopDefault(path); var module$1 = _interopDefault(require('module')); var rollup = require('../dist/rollup.js'); var rollup__default = _interopDefault(rollup); var assert = _interopDefault(require('assert')); var events = _interopDefault(require('events')); var help = "rollup version __VERSION__\n=====================================\n\nUsage: rollup [options] \n\nBasic options:\n\n-c, --config Use this config file (if argument is used but value\n is unspecified, defaults to rollup.config.js)\n-d, --dir Directory for chunks (if absent, prints to stdout)\n-e, --external Comma-separate list of module IDs to exclude\n-f, --format Type of output (amd, cjs, esm, iife, umd)\n-g, --globals Comma-separate list of `moduleID:Global` pairs\n-h, --help Show this help message\n-i, --input Input (alternative to )\n-m, --sourcemap Generate sourcemap (`-m inline` for inline map)\n-n, --name Name for UMD export\n-o, --file 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 for AMD module (default is anonymous)\n--amd.define Function to use in place of `define`\n--assetFileNames Name pattern for emitted assets\n--banner Code to insert at top of bundle (outside wrapper)\n--chunkFileNames Name pattern for emitted secondary chunks\n--compact Minify wrapper code\n--context Specify top-level `this` value\n--dynamicImportFunction Rename the dynamic `import()` function\n--entryFileNames Name pattern for emitted entry chunks\n--environment Settings passed to config file (see example)\n--no-esModule Do not add __esModule property\n--exports Specify export mode (auto, default, named, none)\n--extend Extend global variable defined by --name\n--footer 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 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 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 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"; var minimist = function (args, opts) { if (!opts) opts = {}; var flags = { bools : {}, strings : {}, unknownFn: null }; if (typeof opts['unknown'] === 'function') { flags.unknownFn = opts['unknown']; } if (typeof opts['boolean'] === 'boolean' && opts['boolean']) { flags.allBools = true; } else { [].concat(opts['boolean']).filter(Boolean).forEach(function (key) { flags.bools[key] = true; }); } var aliases = {}; Object.keys(opts.alias || {}).forEach(function (key) { aliases[key] = [].concat(opts.alias[key]); aliases[key].forEach(function (x) { aliases[x] = [key].concat(aliases[key].filter(function (y) { return x !== y; })); }); }); [].concat(opts.string).filter(Boolean).forEach(function (key) { flags.strings[key] = true; if (aliases[key]) { flags.strings[aliases[key]] = true; } }); var defaults = opts['default'] || {}; var argv = { _ : [] }; Object.keys(flags.bools).forEach(function (key) { setArg(key, defaults[key] === undefined ? false : defaults[key]); }); var notFlags = []; if (args.indexOf('--') !== -1) { notFlags = args.slice(args.indexOf('--')+1); args = args.slice(0, args.indexOf('--')); } function argDefined(key, arg) { return (flags.allBools && /^--[^=]+$/.test(arg)) || flags.strings[key] || flags.bools[key] || aliases[key]; } function setArg (key, val, arg) { if (arg && flags.unknownFn && !argDefined(key, arg)) { if (flags.unknownFn(arg) === false) return; } var value = !flags.strings[key] && isNumber(val) ? Number(val) : val ; setKey(argv, key.split('.'), value); (aliases[key] || []).forEach(function (x) { setKey(argv, x.split('.'), value); }); } function setKey (obj, keys, value) { var o = obj; keys.slice(0,-1).forEach(function (key) { if (o[key] === undefined) o[key] = {}; o = o[key]; }); var key = keys[keys.length - 1]; if (o[key] === undefined || flags.bools[key] || typeof o[key] === 'boolean') { o[key] = value; } else if (Array.isArray(o[key])) { o[key].push(value); } else { o[key] = [ o[key], value ]; } } function aliasIsBoolean(key) { return aliases[key].some(function (x) { return flags.bools[x]; }); } for (var i = 0; i < args.length; i++) { var arg = args[i]; if (/^--.+=/.test(arg)) { // Using [\s\S] instead of . because js doesn't support the // 'dotall' regex modifier. See: // http://stackoverflow.com/a/1068308/13216 var m = arg.match(/^--([^=]+)=([\s\S]*)$/); var key = m[1]; var value = m[2]; if (flags.bools[key]) { value = value !== 'false'; } setArg(key, value, arg); } else if (/^--no-.+/.test(arg)) { var key = arg.match(/^--no-(.+)/)[1]; setArg(key, false, arg); } else if (/^--.+/.test(arg)) { var key = arg.match(/^--(.+)/)[1]; var next = args[i + 1]; if (next !== undefined && !/^-/.test(next) && !flags.bools[key] && !flags.allBools && (aliases[key] ? !aliasIsBoolean(key) : true)) { setArg(key, next, arg); i++; } else if (/^(true|false)$/.test(next)) { setArg(key, next === 'true', arg); i++; } else { setArg(key, flags.strings[key] ? '' : true, arg); } } else if (/^-[^-]+/.test(arg)) { var letters = arg.slice(1,-1).split(''); var broken = false; for (var j = 0; j < letters.length; j++) { var next = arg.slice(j+2); if (next === '-') { setArg(letters[j], next, arg); continue; } if (/[A-Za-z]/.test(letters[j]) && /=/.test(next)) { setArg(letters[j], next.split('=')[1], arg); broken = true; break; } if (/[A-Za-z]/.test(letters[j]) && /-?\d+(\.\d*)?(e-?\d+)?$/.test(next)) { setArg(letters[j], next, arg); broken = true; break; } if (letters[j+1] && letters[j+1].match(/\W/)) { setArg(letters[j], arg.slice(j+2), arg); broken = true; break; } else { setArg(letters[j], flags.strings[letters[j]] ? '' : true, arg); } } var key = arg.slice(-1)[0]; if (!broken && key !== '-') { if (args[i+1] && !/^(-|--)[^-]/.test(args[i+1]) && !flags.bools[key] && (aliases[key] ? !aliasIsBoolean(key) : true)) { setArg(key, args[i+1], arg); i++; } else if (args[i+1] && /true|false/.test(args[i+1])) { setArg(key, args[i+1] === 'true', arg); i++; } else { setArg(key, flags.strings[key] ? '' : true, arg); } } } else { if (!flags.unknownFn || flags.unknownFn(arg) !== false) { argv._.push( flags.strings['_'] || !isNumber(arg) ? arg : Number(arg) ); } if (opts.stopEarly) { argv._.push.apply(argv._, args.slice(i + 1)); break; } } } Object.keys(defaults).forEach(function (key) { if (!hasKey(argv, key.split('.'))) { setKey(argv, key.split('.'), defaults[key]); (aliases[key] || []).forEach(function (x) { setKey(argv, x.split('.'), defaults[key]); }); } }); if (opts['--']) { argv['--'] = new Array(); notFlags.forEach(function(key) { argv['--'].push(key); }); } else { notFlags.forEach(function(key) { argv._.push(key); }); } return argv; }; function hasKey (obj, keys) { var o = obj; keys.slice(0,-1).forEach(function (key) { o = (o[key] || {}); }); var key = keys[keys.length - 1]; return key in o; } function isNumber (x) { if (typeof x === 'number') return true; if (/^0x[0-9a-f]+$/i.test(x)) return true; return /^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(x); } var version = "1.11.0"; /*! ***************************************************************************** Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT. See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ /* global Reflect, Promise */ var extendStatics = function(d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); }; function __extends(d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); } var __assign = function() { __assign = Object.assign || function __assign(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; function __rest(s, e) { var t = {}; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0) t[p[i]] = s[p[i]]; return t; } function __decorate(decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); 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; return c > 3 && r && Object.defineProperty(target, key, r), r; } function __param(paramIndex, decorator) { return function (target, key) { decorator(target, key, paramIndex); } } function __metadata(metadataKey, metadataValue) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue); } function __awaiter(thisArg, _arguments, P, generator) { return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); } function __generator(thisArg, body) { var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; function verb(n) { return function (v) { return step([n, v]); }; } function step(op) { if (f) throw new TypeError("Generator is already executing."); while (_) try { 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; if (y = 0, t) op = [op[0] & 2, t.value]; switch (op[0]) { case 0: case 1: t = op; break; case 4: _.label++; return { value: op[1], done: false }; case 5: _.label++; y = op[1]; op = [0]; continue; case 7: op = _.ops.pop(); _.trys.pop(); continue; default: if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } if (t[2]) _.ops.pop(); _.trys.pop(); continue; } op = body.call(thisArg, _); } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } } function __exportStar(m, exports) { for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; } function __values(o) { var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0; if (m) return m.call(o); return { next: function () { if (o && i >= o.length) o = void 0; return { value: o && o[i++], done: !o }; } }; } function __read(o, n) { var m = typeof Symbol === "function" && o[Symbol.iterator]; if (!m) return o; var i = m.call(o), r, ar = [], e; try { while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); } catch (error) { e = { error: error }; } finally { try { if (r && !r.done && (m = i["return"])) m.call(i); } finally { if (e) throw e.error; } } return ar; } function __spread() { for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i])); return ar; } function __await(v) { return this instanceof __await ? (this.v = v, this) : new __await(v); } function __asyncGenerator(thisArg, _arguments, generator) { if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var g = generator.apply(thisArg, _arguments || []), i, q = []; return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; 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); }); }; } function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } function fulfill(value) { resume("next", value); } function reject(value) { resume("throw", value); } function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } } function __asyncDelegator(o) { var i, p; return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i; 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; } } function __asyncValues(o) { if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var m = o[Symbol.asyncIterator], i; 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); 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); }); }; } function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } } function __makeTemplateObject(cooked, raw) { if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } return cooked; } function __importStar(mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; result.default = mod; return result; } function __importDefault(mod) { return (mod && mod.__esModule) ? mod : { default: mod }; } var tslib_1 = /*#__PURE__*/Object.freeze({ __extends: __extends, get __assign () { return __assign; }, __rest: __rest, __decorate: __decorate, __param: __param, __metadata: __metadata, __awaiter: __awaiter, __generator: __generator, __exportStar: __exportStar, __values: __values, __read: __read, __spread: __spread, __await: __await, __asyncGenerator: __asyncGenerator, __asyncDelegator: __asyncDelegator, __asyncValues: __asyncValues, __makeTemplateObject: __makeTemplateObject, __importStar: __importStar, __importDefault: __importDefault }); var createGetOption = function (config, command) { return function (name, defaultValue) { return command[name] !== undefined ? command[name] : config[name] !== undefined ? config[name] : defaultValue; }; }; var normalizeObjectOptionValue = function (optionValue) { if (!optionValue) { return optionValue; } if (typeof optionValue !== 'object') { return {}; } return optionValue; }; var getObjectOption = function (config, command, name) { var commandOption = normalizeObjectOptionValue(command[name]); var configOption = normalizeObjectOptionValue(config[name]); if (commandOption !== undefined) { return commandOption && configOption ? __assign({}, configOption, commandOption) : commandOption; } return configOption; }; var defaultOnWarn = function (warning) { if (typeof warning === 'string') { console.warn(warning); } else { console.warn(warning.message); } }; var getOnWarn = function (config, command, defaultOnWarnHandler) { if (defaultOnWarnHandler === void 0) { defaultOnWarnHandler = defaultOnWarn; } return command.silent ? function () { } : config.onwarn ? function (warning) { return config.onwarn(warning, defaultOnWarnHandler); } : defaultOnWarnHandler; }; // TODO Lukas manual chunks should receive the same treatment var getExternal = function (config, command) { var configExternal = config.external; return typeof configExternal === 'function' ? function (id) { var rest = []; for (var _i = 1; _i < arguments.length; _i++) { rest[_i - 1] = arguments[_i]; } return configExternal.apply(void 0, [id].concat(rest)) || command.external.indexOf(id) !== -1; } : (configExternal || []).concat(command.external); }; var commandAliases = { c: 'config', d: 'dir', e: 'external', f: 'format', g: 'globals', h: 'help', i: 'input', m: 'sourcemap', n: 'name', o: 'file', v: 'version', w: 'watch' }; function mergeOptions(_a) { var _b = _a.config, config = _b === void 0 ? {} : _b, _c = _a.command, rawCommandOptions = _c === void 0 ? {} : _c, defaultOnWarnHandler = _a.defaultOnWarnHandler; var command = getCommandOptions(rawCommandOptions); var inputOptions = getInputOptions(config, command, defaultOnWarnHandler); if (command.output) { Object.assign(command, command.output); } var output = config.output; var normalizedOutputOptions = Array.isArray(output) ? output : output ? [output] : []; if (normalizedOutputOptions.length === 0) normalizedOutputOptions.push({}); var outputOptions = normalizedOutputOptions.map(function (singleOutputOptions) { return getOutputOptions(singleOutputOptions, command); }); var unknownOptionErrors = []; var validInputOptions = Object.keys(inputOptions); addUnknownOptionErrors(unknownOptionErrors, Object.keys(config), validInputOptions, 'input option', /^output$/); var validOutputOptions = Object.keys(outputOptions[0]); addUnknownOptionErrors(unknownOptionErrors, outputOptions.reduce(function (allKeys, options) { return allKeys.concat(Object.keys(options)); }, []), validOutputOptions, 'output option'); var validCliOutputOptions = validOutputOptions.filter(function (option) { return option !== 'sourcemapPathTransform'; }); addUnknownOptionErrors(unknownOptionErrors, Object.keys(command), validInputOptions.concat(validCliOutputOptions, Object.keys(commandAliases), 'config', 'environment', 'silent'), 'CLI flag', /^_|output|(config.*)$/); return { inputOptions: inputOptions, optionError: unknownOptionErrors.length > 0 ? unknownOptionErrors.join('\n') : null, outputOptions: outputOptions }; } function addUnknownOptionErrors(errors, options, validOptions, optionType, ignoredKeys) { if (ignoredKeys === void 0) { ignoredKeys = /$./; } var unknownOptions = options.filter(function (key) { return validOptions.indexOf(key) === -1 && !ignoredKeys.test(key); }); if (unknownOptions.length > 0) errors.push("Unknown " + optionType + ": " + unknownOptions.join(', ') + ". Allowed options: " + validOptions.sort().join(', ')); } function getCommandOptions(rawCommandOptions) { var command = __assign({}, rawCommandOptions); command.external = rawCommandOptions.external ? rawCommandOptions.external.split(',') : []; if (rawCommandOptions.globals) { command.globals = Object.create(null); rawCommandOptions.globals.split(',').forEach(function (str) { var names = str.split(':'); command.globals[names[0]] = names[1]; // Add missing Module IDs to external. if (command.external.indexOf(names[0]) === -1) { command.external.push(names[0]); } }); } return command; } function getInputOptions(config, command, defaultOnWarnHandler) { if (command === void 0) { command = {}; } var getOption = createGetOption(config, command); var inputOptions = { acorn: config.acorn, acornInjectPlugins: config.acornInjectPlugins, cache: getOption('cache'), chunkGroupingSize: getOption('chunkGroupingSize', 5000), context: config.context, experimentalCacheExpiry: getOption('experimentalCacheExpiry', 10), experimentalOptimizeChunks: getOption('experimentalOptimizeChunks'), experimentalTopLevelAwait: getOption('experimentalTopLevelAwait'), external: getExternal(config, command), inlineDynamicImports: getOption('inlineDynamicImports', false), input: getOption('input', []), manualChunks: getOption('manualChunks'), moduleContext: config.moduleContext, onwarn: getOnWarn(config, command, defaultOnWarnHandler), perf: getOption('perf', false), plugins: config.plugins, preserveModules: getOption('preserveModules'), preserveSymlinks: getOption('preserveSymlinks'), shimMissingExports: getOption('shimMissingExports'), treeshake: getObjectOption(config, command, 'treeshake'), watch: config.watch }; // support rollup({ cache: prevBuildObject }) if (inputOptions.cache && inputOptions.cache.cache) inputOptions.cache = inputOptions.cache.cache; return inputOptions; } function getOutputOptions(config, command) { if (command === void 0) { command = {}; } var getOption = createGetOption(config, command); var format = getOption('format'); // Handle format aliases switch (format) { case 'esm': case 'module': format = 'es'; break; case 'commonjs': format = 'cjs'; } return { amd: __assign({}, config.amd, command.amd), assetFileNames: getOption('assetFileNames'), banner: getOption('banner'), chunkFileNames: getOption('chunkFileNames'), compact: getOption('compact', false), dir: getOption('dir'), dynamicImportFunction: getOption('dynamicImportFunction'), entryFileNames: getOption('entryFileNames'), esModule: getOption('esModule', true), exports: getOption('exports'), extend: getOption('extend'), file: getOption('file'), footer: getOption('footer'), format: format === 'esm' ? 'es' : format, freeze: getOption('freeze', true), globals: getOption('globals'), indent: getOption('indent', true), interop: getOption('interop', true), intro: getOption('intro'), name: getOption('name'), namespaceToStringTag: getOption('namespaceToStringTag', false), noConflict: getOption('noConflict'), outro: getOption('outro'), paths: getOption('paths'), preferConst: getOption('preferConst'), sourcemap: getOption('sourcemap'), sourcemapExcludeSources: getOption('sourcemapExcludeSources'), sourcemapFile: getOption('sourcemapFile'), sourcemapPathTransform: getOption('sourcemapPathTransform'), strict: getOption('strict', true) }; } var modules = {}; var getModule = function(dir) { var rootPath = dir ? path__default.resolve(dir) : process.cwd(); var rootName = path__default.join(rootPath, '@root'); var root = modules[rootName]; if (!root) { root = new module$1(rootName); root.filename = rootName; root.paths = module$1._nodeModulePaths(rootPath); modules[rootName] = root; } return root; }; var requireRelative = function(requested, relativeTo) { var root = getModule(relativeTo); return root.require(requested); }; requireRelative.resolve = function(requested, relativeTo) { var root = getModule(relativeTo); return module$1._resolveFilename(requested, root); }; var requireRelative_1 = requireRelative; var absolutePath = /^(?:\/|(?:[A-Za-z]:)?[\\|/])/; function isAbsolute(path) { return absolutePath.test(path); } function getAliasName(id) { var base = path.basename(id); return base.substr(0, base.length - path.extname(id).length); } function relativeId(id) { if (typeof process === 'undefined' || !isAbsolute(id)) return id; return path.relative(process.cwd(), id); } const tc = { enabled: process.env.FORCE_COLOR || process.platform === "win32" || (process.stdout.isTTY && process.env.TERM && process.env.TERM !== "dumb") }; const Styles = (tc.Styles = {}); const defineProp = Object.defineProperty; const init = (style, open, close, re) => { let i, len = 1, seq = [(Styles[style] = { open, close, re })]; const fn = s => { if (tc.enabled) { for (i = 0, s += ""; i < len; i++) { style = seq[i]; s = (open = style.open) + (~s.indexOf((close = style.close), 4) // skip first \x1b[ ? s.replace(style.re, open) : s) + close; } len = 1; } return s }; defineProp(tc, style, { get: () => { for (let k in Styles) defineProp(fn, k, { get: () => ((seq[len++] = Styles[k]), fn) }); delete tc[style]; return (tc[style] = fn) }, configurable: true }); }; init("reset", "\x1b[0m", "\x1b[0m", /\x1b\[0m/g); init("bold", "\x1b[1m", "\x1b[22m", /\x1b\[22m/g); init("dim", "\x1b[2m", "\x1b[22m", /\x1b\[22m/g); init("italic", "\x1b[3m", "\x1b[23m", /\x1b\[23m/g); init("underline", "\x1b[4m", "\x1b[24m", /\x1b\[24m/g); init("inverse", "\x1b[7m", "\x1b[27m", /\x1b\[27m/g); init("hidden", "\x1b[8m", "\x1b[28m", /\x1b\[28m/g); init("strikethrough", "\x1b[9m", "\x1b[29m", /\x1b\[29m/g); init("black", "\x1b[30m", "\x1b[39m", /\x1b\[39m/g); init("red", "\x1b[31m", "\x1b[39m", /\x1b\[39m/g); init("green", "\x1b[32m", "\x1b[39m", /\x1b\[39m/g); init("yellow", "\x1b[33m", "\x1b[39m", /\x1b\[39m/g); init("blue", "\x1b[34m", "\x1b[39m", /\x1b\[39m/g); init("magenta", "\x1b[35m", "\x1b[39m", /\x1b\[39m/g); init("cyan", "\x1b[36m", "\x1b[39m", /\x1b\[39m/g); init("white", "\x1b[37m", "\x1b[39m", /\x1b\[39m/g); init("gray", "\x1b[90m", "\x1b[39m", /\x1b\[39m/g); init("bgBlack", "\x1b[40m", "\x1b[49m", /\x1b\[49m/g); init("bgRed", "\x1b[41m", "\x1b[49m", /\x1b\[49m/g); init("bgGreen", "\x1b[42m", "\x1b[49m", /\x1b\[49m/g); init("bgYellow", "\x1b[43m", "\x1b[49m", /\x1b\[49m/g); init("bgBlue", "\x1b[44m", "\x1b[49m", /\x1b\[49m/g); init("bgMagenta", "\x1b[45m", "\x1b[49m", /\x1b\[49m/g); init("bgCyan", "\x1b[46m", "\x1b[49m", /\x1b\[49m/g); init("bgWhite", "\x1b[47m", "\x1b[49m", /\x1b\[49m/g); var turbocolor = tc; // log to stderr to keep `rollup main.js > bundle.js` from breaking var stderr = console.error.bind(console); function handleError(err, recover) { if (recover === void 0) { recover = false; } var description = err.message || err; if (err.name) description = err.name + ": " + description; var message = (err.plugin ? "(" + err.plugin + " plugin) " + description : description) || err; stderr(turbocolor.bold.red("[!] " + turbocolor.bold(message.toString()))); if (err.url) { stderr(turbocolor.cyan(err.url)); } if (err.loc) { stderr(relativeId(err.loc.file || err.id) + " (" + err.loc.line + ":" + err.loc.column + ")"); } else if (err.id) { stderr(relativeId(err.id)); } if (err.frame) { stderr(turbocolor.dim(err.frame)); } if (err.stack) { stderr(turbocolor.dim(err.stack)); } stderr(''); if (!recover) process.exit(1); } function batchWarnings() { var allWarnings = new Map(); var count = 0; return { get count() { return count; }, add: function (warning) { if (typeof warning === 'string') { warning = { code: 'UNKNOWN', message: warning }; } if (warning.code in immediateHandlers) { immediateHandlers[warning.code](warning); return; } if (!allWarnings.has(warning.code)) allWarnings.set(warning.code, []); allWarnings.get(warning.code).push(warning); count += 1; }, flush: function () { if (count === 0) return; var codes = Array.from(allWarnings.keys()).sort(function (a, b) { if (deferredHandlers[a] && deferredHandlers[b]) { return deferredHandlers[a].priority - deferredHandlers[b].priority; } if (deferredHandlers[a]) return -1; if (deferredHandlers[b]) return 1; return allWarnings.get(b).length - allWarnings.get(a).length; }); codes.forEach(function (code) { var handler = deferredHandlers[code]; var warnings = allWarnings.get(code); if (handler) { handler.fn(warnings); } else { warnings.forEach(function (warning) { title(warning.message); if (warning.url) info(warning.url); var id = (warning.loc && warning.loc.file) || warning.id; if (id) { var loc = warning.loc ? relativeId(id) + ": (" + warning.loc.line + ":" + warning.loc.column + ")" : relativeId(id); stderr(turbocolor.bold(relativeId(loc))); } if (warning.frame) info(warning.frame); }); } }); allWarnings = new Map(); count = 0; } }; } var immediateHandlers = { UNKNOWN_OPTION: function (warning) { title("You have passed an unrecognized option"); stderr(warning.message); }, MISSING_NODE_BUILTINS: function (warning) { title("Missing shims for Node.js built-ins"); var detail = warning.modules.length === 1 ? "'" + warning.modules[0] + "'" : warning.modules .slice(0, -1) .map(function (name) { return "'" + name + "'"; }) .join(', ') + " and '" + warning.modules.slice(-1) + "'"; stderr("Creating a browser bundle that depends on " + detail + ". You might need to include https://www.npmjs.com/package/rollup-plugin-node-builtins"); }, MIXED_EXPORTS: function () { title('Mixing named and default exports'); 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"); }, EMPTY_BUNDLE: function () { title("Generated an empty bundle"); } }; // TODO select sensible priorities var deferredHandlers = { UNUSED_EXTERNAL_IMPORT: { fn: function (warnings) { title('Unused external imports'); warnings.forEach(function (warning) { stderr(warning.names + " imported from external module '" + warning.source + "' but never used"); }); }, priority: 1 }, UNRESOLVED_IMPORT: { fn: function (warnings) { title('Unresolved dependencies'); info('https://rollupjs.org/guide/en#warning-treating-module-as-external-dependency'); var dependencies = new Map(); warnings.forEach(function (warning) { if (!dependencies.has(warning.source)) dependencies.set(warning.source, []); dependencies.get(warning.source).push(warning.importer); }); Array.from(dependencies.keys()).forEach(function (dependency) { var importers = dependencies.get(dependency); stderr(turbocolor.bold(dependency) + " (imported by " + importers.join(', ') + ")"); }); }, priority: 1 }, MISSING_EXPORT: { fn: function (warnings) { title('Missing exports'); info('https://rollupjs.org/guide/en#error-name-is-not-exported-by-module-'); warnings.forEach(function (warning) { stderr(turbocolor.bold(warning.importer)); stderr(warning.missing + " is not exported by " + warning.exporter); stderr(turbocolor.gray(warning.frame)); }); }, priority: 1 }, THIS_IS_UNDEFINED: { fn: function (warnings) { title('`this` has been rewritten to `undefined`'); info('https://rollupjs.org/guide/en#error-this-is-undefined'); showTruncatedWarnings(warnings); }, priority: 1 }, EVAL: { fn: function (warnings) { title('Use of eval is strongly discouraged'); info('https://rollupjs.org/guide/en#avoiding-eval'); showTruncatedWarnings(warnings); }, priority: 1 }, NON_EXISTENT_EXPORT: { fn: function (warnings) { title("Import of non-existent " + (warnings.length > 1 ? 'exports' : 'export')); showTruncatedWarnings(warnings); }, priority: 1 }, NAMESPACE_CONFLICT: { fn: function (warnings) { title("Conflicting re-exports"); warnings.forEach(function (warning) { stderr(turbocolor.bold(relativeId(warning.reexporter)) + " re-exports '" + warning.name + "' from both " + relativeId(warning.sources[0]) + " and " + relativeId(warning.sources[1]) + " (will be ignored)"); }); }, priority: 1 }, MISSING_GLOBAL_NAME: { fn: function (warnings) { title("Missing global variable " + (warnings.length > 1 ? 'names' : 'name')); stderr("Use output.globals to specify browser global variable names corresponding to external modules"); warnings.forEach(function (warning) { stderr(turbocolor.bold(warning.source) + " (guessing '" + warning.guess + "')"); }); }, priority: 1 }, SOURCEMAP_BROKEN: { fn: function (warnings) { title("Broken sourcemap"); info('https://rollupjs.org/guide/en#warning-sourcemap-is-likely-to-be-incorrect'); var plugins = Array.from(new Set(warnings.map(function (w) { return w.plugin; }).filter(Boolean))); var detail = plugins.length === 0 ? '' : plugins.length > 1 ? " (such as " + plugins .slice(0, -1) .map(function (p) { return "'" + p + "'"; }) .join(', ') + " and '" + plugins.slice(-1) + "')" : " (such as '" + plugins[0] + "')"; stderr("Plugins that transform code" + detail + " should generate accompanying sourcemaps"); }, priority: 1 }, PLUGIN_WARNING: { fn: function (warnings) { var nestedByPlugin = nest(warnings, 'plugin'); nestedByPlugin.forEach(function (_a) { var plugin = _a.key, items = _a.items; var nestedByMessage = nest(items, 'message'); var lastUrl; nestedByMessage.forEach(function (_a) { var message = _a.key, items = _a.items; title(plugin + " plugin: " + message); items.forEach(function (warning) { if (warning.url !== lastUrl) info((lastUrl = warning.url)); if (warning.id) { var loc = relativeId(warning.id); if (warning.loc) { loc += ": (" + warning.loc.line + ":" + warning.loc.column + ")"; } stderr(turbocolor.bold(loc)); } if (warning.frame) info(warning.frame); }); }); }); }, priority: 1 } }; function title(str) { stderr(turbocolor.bold.yellow('(!)') + " " + turbocolor.bold.yellow(str)); } function info(url) { stderr(turbocolor.gray(url)); } function nest(array, prop) { var nested = []; var lookup = new Map(); array.forEach(function (item) { var key = item[prop]; if (!lookup.has(key)) { lookup.set(key, { items: [], key: key }); nested.push(lookup.get(key)); } lookup.get(key).items.push(item); }); return nested; } function showTruncatedWarnings(warnings) { var nestedByModule = nest(warnings, 'id'); var sliced = nestedByModule.length > 5 ? nestedByModule.slice(0, 3) : nestedByModule; sliced.forEach(function (_a) { var id = _a.key, items = _a.items; stderr(turbocolor.bold(relativeId(id))); stderr(turbocolor.gray(items[0].frame)); if (items.length > 1) { stderr("...and " + (items.length - 1) + " other " + (items.length > 2 ? 'occurrences' : 'occurrence')); } }); if (nestedByModule.length > sliced.length) { stderr("\n...and " + (nestedByModule.length - sliced.length) + " other files"); } } var parseMs = milliseconds => { if (typeof milliseconds !== 'number') { throw new TypeError('Expected a number'); } const roundTowardsZero = milliseconds > 0 ? Math.floor : Math.ceil; return { days: roundTowardsZero(milliseconds / 86400000), hours: roundTowardsZero(milliseconds / 3600000) % 24, minutes: roundTowardsZero(milliseconds / 60000) % 60, seconds: roundTowardsZero(milliseconds / 1000) % 60, milliseconds: roundTowardsZero(milliseconds) % 1000, microseconds: roundTowardsZero(milliseconds * 1000) % 1000, nanoseconds: roundTowardsZero(milliseconds * 1e6) % 1000 }; }; const pluralize = (word, count) => count === 1 ? word : word + 's'; var prettyMs = (milliseconds, options = {}) => { if (!Number.isFinite(milliseconds)) { throw new TypeError('Expected a finite number'); } if (options.compact) { options.secondsDecimalDigits = 0; options.millisecondsDecimalDigits = 0; } const result = []; const add = (value, long, short, valueString) => { if (value === 0) { return; } const postfix = options.verbose ? ' ' + pluralize(long, value) : short; result.push((valueString || value) + postfix); }; const secondsDecimalDigits = typeof options.secondsDecimalDigits === 'number' ? options.secondsDecimalDigits : 1; if (secondsDecimalDigits < 1) { const difference = 1000 - (milliseconds % 1000); if (difference < 500) { milliseconds += difference; } } const parsed = parseMs(milliseconds); add(Math.trunc(parsed.days / 365), 'year', 'y'); add(parsed.days % 365, 'day', 'd'); add(parsed.hours, 'hour', 'h'); add(parsed.minutes, 'minute', 'm'); if ( options.separateMilliseconds || options.formatSubMilliseconds || milliseconds < 1000 ) { add(parsed.seconds, 'second', 's'); if (options.formatSubMilliseconds) { add(parsed.milliseconds, 'millisecond', 'ms'); add(parsed.microseconds, 'microsecond', 'µs'); add(parsed.nanoseconds, 'nanosecond', 'ns'); } else { const millisecondsAndBelow = parsed.milliseconds + (parsed.microseconds / 1000) + (parsed.nanoseconds / 1e6); const millisecondsDecimalDigits = typeof options.millisecondsDecimalDigits === 'number' ? options.millisecondsDecimalDigits : 0; const millisecondsString = millisecondsDecimalDigits ? millisecondsAndBelow.toFixed(millisecondsDecimalDigits) : Math.ceil(millisecondsAndBelow); add( parseFloat(millisecondsString, 10), 'millisecond', 'ms', millisecondsString ); } } else { const seconds = (milliseconds / 1000) % 60; const secondsDecimalDigits = typeof options.secondsDecimalDigits === 'number' ? options.secondsDecimalDigits : 1; const secondsFixed = seconds.toFixed(secondsDecimalDigits); const secondsString = options.keepDecimalsOnWholeSeconds ? secondsFixed : secondsFixed.replace(/\.0+$/, ''); add(parseFloat(secondsString, 10), 'second', 's', secondsString); } if (result.length === 0) { return '0' + (options.verbose ? ' milliseconds' : 'ms'); } if (options.compact) { return '~' + result[0]; } if (typeof options.unitCount === 'number') { return '~' + result.slice(0, Math.max(options.unitCount, 1)).join(' '); } return result.join(' '); }; var SOURCEMAPPING_URL = 'sourceMa'; SOURCEMAPPING_URL += 'ppingURL'; var SOURCEMAPPING_URL$1 = SOURCEMAPPING_URL; const UNITS = [ 'B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB' ]; /* Formats the given number using `Number#toLocaleString`. - If locale is a string, the value is expected to be a locale-key (for example: `de`). - If locale is true, the system default locale is used for translation. - If no value for locale is specified, the number is returned unmodified. */ const toLocaleString = (number, locale) => { let result = number; if (typeof locale === 'string') { result = number.toLocaleString(locale); } else if (locale === true) { result = number.toLocaleString(); } return result; }; var prettyBytes = (number, options) => { if (!Number.isFinite(number)) { throw new TypeError(`Expected a finite number, got ${typeof number}: ${number}`); } options = Object.assign({}, options); if (options.signed && number === 0) { return ' 0 B'; } const isNegative = number < 0; const prefix = isNegative ? '-' : (options.signed ? '+' : ''); if (isNegative) { number = -number; } if (number < 1) { const numberString = toLocaleString(number, options.locale); return prefix + numberString + ' B'; } const exponent = Math.min(Math.floor(Math.log10(number) / 3), UNITS.length - 1); // eslint-disable-next-line unicorn/prefer-exponentiation-operator number = Number((number / Math.pow(1000, exponent)).toPrecision(3)); const numberString = toLocaleString(number, options.locale); const unit = UNITS[exponent]; return prefix + numberString + ' ' + unit; }; function printTimings(timings) { Object.keys(timings).forEach(function (label) { var color = label[0] === '#' ? (label[1] !== '#' ? turbocolor.underline : turbocolor.bold) : function (text) { return text; }; var _a = timings[label], time = _a[0], memory = _a[1], total = _a[2]; var row = label + ": " + time.toFixed(0) + "ms, " + prettyBytes(memory) + " / " + prettyBytes(total); console.info(color(row)); }); } function build(inputOptions, outputOptions, warnings, silent) { if (silent === void 0) { silent = false; } var useStdout = !outputOptions[0].file && !outputOptions[0].dir; var start = Date.now(); var files = useStdout ? ['stdout'] : outputOptions.map(function (t) { return relativeId(t.file || t.dir); }); if (!silent) { var inputFiles = void 0; if (typeof inputOptions.input === 'string') { inputFiles = inputOptions.input; } else if (inputOptions.input instanceof Array) { inputFiles = inputOptions.input.join(', '); } else if (typeof inputOptions.input === 'object' && inputOptions.input !== null) { inputFiles = Object.keys(inputOptions.input) .map(function (name) { return inputOptions.input[name]; }) .join(', '); } stderr(turbocolor.cyan("\n" + turbocolor.bold(inputFiles) + " \u2192 " + turbocolor.bold(files.join(', ')) + "...")); } return rollup.rollup(inputOptions) .then(function (bundle) { if (useStdout) { var output_1 = outputOptions[0]; if (output_1.sourcemap && output_1.sourcemap !== 'inline') { handleError({ code: 'MISSING_OUTPUT_OPTION', message: 'You must specify a --file (-o) option when creating a file with a sourcemap' }); } return bundle.generate(output_1).then(function (_a) { var outputs = _a.output; for (var _i = 0, outputs_1 = outputs; _i < outputs_1.length; _i++) { var file = outputs_1[_i]; var source = void 0; if (file.isAsset) { source = file.source; } else { source = file.code; if (output_1.sourcemap === 'inline') { source += "\n//# " + SOURCEMAPPING_URL$1 + "=" + file.map.toUrl() + "\n"; } } if (outputs.length > 1) process.stdout.write('\n' + turbocolor.cyan(turbocolor.bold('//→ ' + file.fileName + ':')) + '\n'); process.stdout.write(source); } }); } return Promise.all(outputOptions.map(function (output) { return bundle.write(output); })).then(function () { return bundle; }); }) .then(function (bundle) { warnings.flush(); if (!silent) stderr(turbocolor.green("created " + turbocolor.bold(files.join(', ')) + " in " + turbocolor.bold(prettyMs(Date.now() - start)))); if (bundle && bundle.getTimings) { printTimings(bundle.getTimings()); } }) .catch(function (err) { if (warnings.count > 0) warnings.flush(); handleError(err); }); } function loadConfigFile(configFile, commandOptions) { if (commandOptions === void 0) { commandOptions = {}; } var silent = commandOptions.silent || false; var warnings = batchWarnings(); return rollup__default .rollup({ external: function (id) { return (id[0] !== '.' && !path__default.isAbsolute(id)) || id.slice(-5, id.length) === '.json'; }, input: configFile, onwarn: warnings.add, treeshake: false }) .then(function (bundle) { if (!silent && warnings.count > 0) { stderr(turbocolor.bold("loaded " + relativeId(configFile) + " with warnings")); warnings.flush(); } return bundle.generate({ exports: 'named', format: 'cjs' }); }) .then(function (_a) { var code = _a.output[0].code; // temporarily override require var defaultLoader = require.extensions['.js']; require.extensions['.js'] = function (module, filename) { if (filename === configFile) { module._compile(code, filename); } else { defaultLoader(module, filename); } }; delete require.cache[configFile]; return Promise.resolve(require(configFile)) .then(function (configFileContent) { if (configFileContent.default) configFileContent = configFileContent.default; if (typeof configFileContent === 'function') { return configFileContent(commandOptions); } return configFileContent; }) .then(function (configs) { if (Object.keys(configs).length === 0) { handleError({ code: 'MISSING_CONFIG', message: 'Config file must export an options object, or an array of options objects', url: 'https://rollupjs.org/guide/en#configuration-files' }); } require.extensions['.js'] = defaultLoader; return Array.isArray(configs) ? configs : [configs]; }); }); } var timeZone = date => { const offset = (date || new Date()).getTimezoneOffset(); const absOffset = Math.abs(offset); const hours = Math.floor(absOffset / 60); const minutes = absOffset % 60; const minutesOut = minutes > 0 ? ':' + ('0' + minutes).slice(-2) : ''; return (offset < 0 ? '+' : '-') + hours + minutesOut; }; const dateTime = options => { options = Object.assign({ date: new Date(), local: true, showTimeZone: false, showMilliseconds: false }, options); let {date} = options; if (options.local) { // Offset the date so it will return the correct value when getting the ISO string date = new Date(date.getTime() - (date.getTimezoneOffset() * 60000)); } let end = ''; if (options.showTimeZone) { end = ' UTC' + (options.local ? timeZone(date) : ''); } if (options.showMilliseconds && date.getUTCMilliseconds() > 0) { end = ` ${date.getUTCMilliseconds()}ms${end}`; } return date .toISOString() .replace(/T/, ' ') .replace(/\..+/, end); }; var dateTime_1 = dateTime; // TODO: Remove this for the next major release var default_1 = dateTime; dateTime_1.default = default_1; function createCommonjsModule(fn, module) { return module = { exports: {} }, fn(module, module.exports), module.exports; } var signals = createCommonjsModule(function (module) { // This is not the set of all possible signals. // // It IS, however, the set of all signals that trigger // an exit on either Linux or BSD systems. Linux is a // superset of the signal names supported on BSD, and // the unknown signals just fail to register, so we can // catch that easily enough. // // Don't bother with SIGKILL. It's uncatchable, which // means that we can't fire any callbacks anyway. // // If a user does happen to register a handler on a non- // fatal signal like SIGWINCH or something, and then // exit, it'll end up firing `process.emit('exit')`, so // the handler will be fired anyway. // // SIGBUS, SIGFPE, SIGSEGV and SIGILL, when not raised // artificially, inherently leave the process in a // state from which it is not safe to try and enter JS // listeners. module.exports = [ 'SIGABRT', 'SIGALRM', 'SIGHUP', 'SIGINT', 'SIGTERM' ]; if (process.platform !== 'win32') { module.exports.push( 'SIGVTALRM', 'SIGXCPU', 'SIGXFSZ', 'SIGUSR2', 'SIGTRAP', 'SIGSYS', 'SIGQUIT', 'SIGIOT' // should detect profiler and enable/disable accordingly. // see #21 // 'SIGPROF' ); } if (process.platform === 'linux') { module.exports.push( 'SIGIO', 'SIGPOLL', 'SIGPWR', 'SIGSTKFLT', 'SIGUNUSED' ); } }); // Note: since nyc uses this module to output coverage, any lines // that are in the direct sync flow of nyc's outputCoverage are // ignored, since we can never get coverage for them. var signals$1 = signals; var EE = events; /* istanbul ignore if */ if (typeof EE !== 'function') { EE = EE.EventEmitter; } var emitter; if (process.__signal_exit_emitter__) { emitter = process.__signal_exit_emitter__; } else { emitter = process.__signal_exit_emitter__ = new EE(); emitter.count = 0; emitter.emitted = {}; } // Because this emitter is a global, we have to check to see if a // previous version of this library failed to enable infinite listeners. // I know what you're about to say. But literally everything about // signal-exit is a compromise with evil. Get used to it. if (!emitter.infinite) { emitter.setMaxListeners(Infinity); emitter.infinite = true; } var signalExit = function (cb, opts) { assert.equal(typeof cb, 'function', 'a callback must be provided for exit handler'); if (loaded === false) { load(); } var ev = 'exit'; if (opts && opts.alwaysLast) { ev = 'afterexit'; } var remove = function () { emitter.removeListener(ev, cb); if (emitter.listeners('exit').length === 0 && emitter.listeners('afterexit').length === 0) { unload(); } }; emitter.on(ev, cb); return remove }; var unload_1 = unload; function unload () { if (!loaded) { return } loaded = false; signals$1.forEach(function (sig) { try { process.removeListener(sig, sigListeners[sig]); } catch (er) {} }); process.emit = originalProcessEmit; process.reallyExit = originalProcessReallyExit; emitter.count -= 1; } function emit (event, code, signal) { if (emitter.emitted[event]) { return } emitter.emitted[event] = true; emitter.emit(event, code, signal); } // { : , ... } var sigListeners = {}; signals$1.forEach(function (sig) { sigListeners[sig] = function listener () { // If there are no other listeners, an exit is coming! // Simplest way: remove us and then re-send the signal. // We know that this will kill the process, so we can // safely emit now. var listeners = process.listeners(sig); if (listeners.length === emitter.count) { unload(); emit('exit', null, sig); /* istanbul ignore next */ emit('afterexit', null, sig); /* istanbul ignore next */ process.kill(process.pid, sig); } }; }); var signals_1 = function () { return signals$1 }; var load_1 = load; var loaded = false; function load () { if (loaded) { return } loaded = true; // This is the number of onSignalExit's that are in play. // It's important so that we can count the correct number of // listeners on signals, and don't wait for the other one to // handle it instead of us. emitter.count += 1; signals$1 = signals$1.filter(function (sig) { try { process.on(sig, sigListeners[sig]); return true } catch (er) { return false } }); process.emit = processEmit; process.reallyExit = processReallyExit; } var originalProcessReallyExit = process.reallyExit; function processReallyExit (code) { process.exitCode = code || 0; emit('exit', process.exitCode, null); /* istanbul ignore next */ emit('afterexit', process.exitCode, null); /* istanbul ignore next */ originalProcessReallyExit.call(process, process.exitCode); } var originalProcessEmit = process.emit; function processEmit (ev, arg) { if (ev === 'exit') { if (arg !== undefined) { process.exitCode = arg; } var ret = originalProcessEmit.apply(this, arguments); emit('exit', process.exitCode, null); /* istanbul ignore next */ emit('afterexit', process.exitCode, null); return ret } else { return originalProcessEmit.apply(this, arguments) } } signalExit.unload = unload_1; signalExit.signals = signals_1; signalExit.load = load_1; var ansiEscapes_1 = createCommonjsModule(function (module) { const ansiEscapes = module.exports; // TODO: remove this in the next major version module.exports.default = ansiEscapes; const ESC = '\u001B['; const OSC = '\u001B]'; const BEL = '\u0007'; const SEP = ';'; const isTerminalApp = process.env.TERM_PROGRAM === 'Apple_Terminal'; ansiEscapes.cursorTo = (x, y) => { if (typeof x !== 'number') { throw new TypeError('The `x` argument is required'); } if (typeof y !== 'number') { return ESC + (x + 1) + 'G'; } return ESC + (y + 1) + ';' + (x + 1) + 'H'; }; ansiEscapes.cursorMove = (x, y) => { if (typeof x !== 'number') { throw new TypeError('The `x` argument is required'); } let ret = ''; if (x < 0) { ret += ESC + (-x) + 'D'; } else if (x > 0) { ret += ESC + x + 'C'; } if (y < 0) { ret += ESC + (-y) + 'A'; } else if (y > 0) { ret += ESC + y + 'B'; } return ret; }; ansiEscapes.cursorUp = (count = 1) => ESC + count + 'A'; ansiEscapes.cursorDown = (count = 1) => ESC + count + 'B'; ansiEscapes.cursorForward = (count = 1) => ESC + count + 'C'; ansiEscapes.cursorBackward = (count = 1) => ESC + count + 'D'; ansiEscapes.cursorLeft = ESC + 'G'; ansiEscapes.cursorSavePosition = ESC + (isTerminalApp ? '7' : 's'); ansiEscapes.cursorRestorePosition = ESC + (isTerminalApp ? '8' : 'u'); ansiEscapes.cursorGetPosition = ESC + '6n'; ansiEscapes.cursorNextLine = ESC + 'E'; ansiEscapes.cursorPrevLine = ESC + 'F'; ansiEscapes.cursorHide = ESC + '?25l'; ansiEscapes.cursorShow = ESC + '?25h'; ansiEscapes.eraseLines = count => { let clear = ''; for (let i = 0; i < count; i++) { clear += ansiEscapes.eraseLine + (i < count - 1 ? ansiEscapes.cursorUp() : ''); } if (count) { clear += ansiEscapes.cursorLeft; } return clear; }; ansiEscapes.eraseEndLine = ESC + 'K'; ansiEscapes.eraseStartLine = ESC + '1K'; ansiEscapes.eraseLine = ESC + '2K'; ansiEscapes.eraseDown = ESC + 'J'; ansiEscapes.eraseUp = ESC + '1J'; ansiEscapes.eraseScreen = ESC + '2J'; ansiEscapes.scrollUp = ESC + 'S'; ansiEscapes.scrollDown = ESC + 'T'; ansiEscapes.clearScreen = '\u001Bc'; ansiEscapes.clearTerminal = process.platform === 'win32' ? `${ansiEscapes.eraseScreen}${ESC}0f` : // 1. Erases the screen (Only done in case `2` is not supported) // 2. Erases the whole screen including scrollback buffer // 3. Moves cursor to the top-left position // More info: https://www.real-world-systems.com/docs/ANSIcode.html `${ansiEscapes.eraseScreen}${ESC}3J${ESC}H`; ansiEscapes.beep = BEL; ansiEscapes.link = (text, url) => { return [ OSC, '8', SEP, SEP, url, BEL, text, OSC, '8', SEP, SEP, BEL ].join(''); }; ansiEscapes.image = (buffer, options = {}) => { let ret = `${OSC}1337;File=inline=1`; if (options.width) { ret += `;width=${options.width}`; } if (options.height) { ret += `;height=${options.height}`; } if (options.preserveAspectRatio === false) { ret += ';preserveAspectRatio=0'; } return ret + ':' + buffer.toString('base64') + BEL; }; ansiEscapes.iTerm = { setCwd: (cwd = process.cwd()) => `${OSC}50;CurrentDir=${cwd}${BEL}` }; }); var SHOW_ALTERNATE_SCREEN = '\u001B[?1049h'; var HIDE_ALTERNATE_SCREEN = '\u001B[?1049l'; var isWindows = process.platform === 'win32'; var isMintty = isWindows && !!(process.env.SHELL || process.env.TERM); var isConEmuAnsiOn = (process.env.ConEmuANSI || '').toLowerCase() === 'on'; var supportsAnsi = !isWindows || isMintty || isConEmuAnsiOn; function alternateScreen(enabled) { if (!enabled) { var needAnnounce_1 = true; return { open: function () { }, close: function () { }, reset: function (heading) { if (needAnnounce_1) { stderr(heading); needAnnounce_1 = false; } } }; } return { open: function () { if (supportsAnsi) { process.stderr.write(SHOW_ALTERNATE_SCREEN); } }, close: function () { if (supportsAnsi) { process.stderr.write(HIDE_ALTERNATE_SCREEN); } }, reset: function (heading) { stderr("" + ansiEscapes_1.eraseScreen + ansiEscapes_1.cursorTo(0, 0) + heading); } }; } function watch(configFile, configs, command, silent) { if (silent === void 0) { silent = false; } var isTTY = Boolean(process.stderr.isTTY); var warnings = batchWarnings(); var initialConfigs = processConfigs(configs); var clearScreen = initialConfigs.every(function (config) { return config.watch.clearScreen !== false; }); var screen = alternateScreen(isTTY && clearScreen); screen.open(); var watcher; var configWatcher; var processConfigsErr; function processConfigs(configs) { return configs.map(function (options) { var merged = mergeOptions({ command: command, config: options, defaultOnWarnHandler: warnings.add }); var result = __assign({}, merged.inputOptions, { output: merged.outputOptions }); if (!result.watch) result.watch = {}; if (merged.optionError) merged.inputOptions.onwarn({ code: 'UNKNOWN_OPTION', message: merged.optionError }); if (merged.inputOptions.watch && merged.inputOptions.watch.clearScreen === false) { processConfigsErr = stderr; } return result; }); } function start(configs) { var screenWriter = processConfigsErr || screen.reset; watcher = rollup.watch(configs); watcher.on('event', function (event) { switch (event.code) { case 'FATAL': screen.close(); handleError(event.error, true); process.exit(1); break; case 'ERROR': warnings.flush(); handleError(event.error, true); break; case 'START': if (!silent) { screenWriter(turbocolor.underline("rollup v" + rollup.VERSION)); } break; case 'BUNDLE_START': if (!silent) { var input_1 = event.input; if (typeof input_1 !== 'string') { input_1 = Array.isArray(input_1) ? input_1.join(', ') : Object.keys(input_1) .map(function (key) { return input_1[key]; }) .join(', '); } stderr(turbocolor.cyan("bundles " + turbocolor.bold(input_1) + " \u2192 " + turbocolor.bold(event.output.map(relativeId).join(', ')) + "...")); } break; case 'BUNDLE_END': warnings.flush(); if (!silent) stderr(turbocolor.green("created " + turbocolor.bold(event.output.map(relativeId).join(', ')) + " in " + turbocolor.bold(prettyMs(event.duration)))); if (event.result && event.result.getTimings) { printTimings(event.result.getTimings()); } break; case 'END': if (!silent && isTTY) { stderr("\n[" + dateTime_1() + "] waiting for changes..."); } } }); } // catch ctrl+c, kill, and uncaught errors var removeOnExit = signalExit(close); process.on('uncaughtException', close); // only listen to stdin if it is a pipe if (!process.stdin.isTTY) { process.stdin.on('end', close); // in case we ever support stdin! } function close(err) { removeOnExit(); process.removeListener('uncaughtException', close); // removing a non-existent listener is a no-op process.stdin.removeListener('end', close); screen.close(); if (watcher) watcher.close(); if (configWatcher) configWatcher.close(); if (err) { console.error(err); process.exit(1); } } try { start(initialConfigs); } catch (err) { close(err); return; } if (configFile && !configFile.startsWith('node:')) { var restarting_1 = false; var aborted_1 = false; var configFileData_1 = fs__default.readFileSync(configFile, 'utf-8'); var restart_1 = function () { var newConfigFileData = fs__default.readFileSync(configFile, 'utf-8'); if (newConfigFileData === configFileData_1) return; configFileData_1 = newConfigFileData; if (restarting_1) { aborted_1 = true; return; } restarting_1 = true; loadConfigFile(configFile, command) .then(function (_configs) { restarting_1 = false; if (aborted_1) { aborted_1 = false; restart_1(); } else { watcher.close(); start(initialConfigs); } }) .catch(function (err) { handleError(err, true); }); }; configWatcher = fs__default.watch(configFile, function (event) { if (event === 'change') restart_1(); }); } } function runRollup(command) { var inputSource; if (command._.length > 0) { if (command.input) { handleError({ code: 'DUPLICATE_IMPORT_OPTIONS', message: 'use --input, or pass input path as argument' }); } inputSource = command._; } else if (typeof command.input === 'string') { inputSource = [command.input]; } else { inputSource = command.input; } if (inputSource && inputSource.length > 0) { if (inputSource.some(function (input) { return input.indexOf('=') !== -1; })) { command.input = {}; inputSource.forEach(function (input) { var equalsIndex = input.indexOf('='); var value = input.substr(equalsIndex + 1); var key = input.substr(0, equalsIndex); if (!key) key = getAliasName(input); command.input[key] = value; }); } else { command.input = inputSource; } } if (command.environment) { var environment = Array.isArray(command.environment) ? command.environment : [command.environment]; environment.forEach(function (arg) { arg.split(',').forEach(function (pair) { var _a = pair.split(':'), key = _a[0], value = _a[1]; if (value) { process.env[key] = value; } else { process.env[key] = String(true); } }); }); } var configFile = command.config === true ? 'rollup.config.js' : command.config; if (configFile) { if (configFile.slice(0, 5) === 'node:') { var pkgName = configFile.slice(5); try { configFile = requireRelative_1.resolve("rollup-config-" + pkgName, process.cwd()); } catch (err) { try { configFile = requireRelative_1.resolve(pkgName, process.cwd()); } catch (err) { if (err.code === 'MODULE_NOT_FOUND') { handleError({ code: 'MISSING_EXTERNAL_CONFIG', message: "Could not resolve config file " + configFile }); } throw err; } } } else { // find real path of config so it matches what Node provides to callbacks in require.extensions configFile = fs.realpathSync(configFile); } if (command.watch) process.env.ROLLUP_WATCH = 'true'; loadConfigFile(configFile, command) .then(function (configs) { return execute(configFile, configs, command); }) .catch(handleError); } else { return execute(configFile, [{ input: null }], command); } } function execute(configFile, configs, command) { if (command.watch) { watch(configFile, configs, command, command.silent); } else { var promise = Promise.resolve(); var _loop_1 = function (config) { promise = promise.then(function () { var warnings = batchWarnings(); var _a = mergeOptions({ command: command, config: config, defaultOnWarnHandler: warnings.add }), inputOptions = _a.inputOptions, outputOptions = _a.outputOptions, optionError = _a.optionError; if (optionError) inputOptions.onwarn({ code: 'UNKNOWN_OPTION', message: optionError }); return build(inputOptions, outputOptions, warnings, command.silent); }); }; for (var _i = 0, configs_1 = configs; _i < configs_1.length; _i++) { var config = configs_1[_i]; _loop_1(config); } return promise; } } var command = minimist(process.argv.slice(2), { alias: commandAliases }); if (command.help || (process.argv.length <= 2 && process.stdin.isTTY)) { console.log("\n" + help.replace('__VERSION__', version) + "\n"); } else if (command.version) { console.log("rollup v" + version); } else { try { require('source-map-support').install(); } catch (err) { // do nothing } runRollup(command); }