#!/usr/bin/env node 'use strict'; function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } var path = require('path'); var path__default = _interopDefault(path); var fs = require('fs'); var rollup = require('../dist/rollup.js'); var module$1 = _interopDefault(require('module')); var index$1 = 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 help = "rollup version __VERSION__\n=====================================\n\nUsage: rollup [options] \n\nBasic options:\n\n-v, --version Show version number\n-h, --help Show this help message\n-c, --config Use this config file (if argument is used but value\n is unspecified, defaults to rollup.config.js)\n-w, --watch Watch files in bundle and rebuild on changes\n-i, --input Input (alternative to )\n-o, --output Output (if absent, prints to stdout)\n-f, --format [es] Type of output (amd, cjs, es, iife, umd)\n-e, --external Comma-separate list of module IDs to exclude\n-g, --globals Comma-separate list of `module ID:Global` pairs\n Any module IDs defined here are added to external\n-n, --name Name for UMD export\n-u, --id ID for AMD module (default is anonymous)\n-m, --sourcemap Generate sourcemap (`-m inline` for inline map)\n--no-strict Don't emit a `\"use strict\";` in the generated modules.\n--no-indent Don't indent result\n--environment Settings passed to config file (see example)\n--no-conflict Generate a noConflict method for UMD globals\n--silent Don't print warnings\n--intro Content to insert at top of bundle (inside wrapper)\n--outro Content to insert at end of bundle (inside wrapper)\n--banner Content to insert at top of bundle (outside wrapper)\n--footer Content to insert at end of bundle (outside wrapper)\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 --output=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://github.com/rollup/rollup/wiki\n"; var version = "0.46.1"; var matchOperatorsRe = /[|\\{}()[\]^$+*?.]/g; var index$3 = function (str) { if (typeof str !== 'string') { throw new TypeError('Expected a string'); } return str.replace(matchOperatorsRe, '\\$&'); }; function createCommonjsModule(fn, module) { return module = { exports: {} }, fn(module, module.exports), module.exports; } var index$5 = createCommonjsModule(function (module) { 'use strict'; function assembleStyles () { var styles = { modifiers: { reset: [0, 0], bold: [1, 22], // 21 isn't widely supported and 22 does the same thing dim: [2, 22], italic: [3, 23], underline: [4, 24], inverse: [7, 27], hidden: [8, 28], strikethrough: [9, 29] }, colors: { black: [30, 39], red: [31, 39], green: [32, 39], yellow: [33, 39], blue: [34, 39], magenta: [35, 39], cyan: [36, 39], white: [37, 39], gray: [90, 39] }, bgColors: { bgBlack: [40, 49], bgRed: [41, 49], bgGreen: [42, 49], bgYellow: [43, 49], bgBlue: [44, 49], bgMagenta: [45, 49], bgCyan: [46, 49], bgWhite: [47, 49] } }; // fix humans styles.colors.grey = styles.colors.gray; Object.keys(styles).forEach(function (groupName) { var group = styles[groupName]; Object.keys(group).forEach(function (styleName) { var style = group[styleName]; styles[styleName] = group[styleName] = { open: '\u001b[' + style[0] + 'm', close: '\u001b[' + style[1] + 'm' }; }); Object.defineProperty(styles, groupName, { value: group, enumerable: false }); }); return styles; } Object.defineProperty(module, 'exports', { enumerable: true, get: assembleStyles }); }); var index$9 = function () { return /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-PRZcf-nqry=><]/g; }; var ansiRegex = index$9(); var index$7 = function (str) { return typeof str === 'string' ? str.replace(ansiRegex, '') : str; }; var re = new RegExp(index$9().source); // remove the `g` flag var index$11 = re.test.bind(re); var argv = process.argv; var terminator = argv.indexOf('--'); var hasFlag = function (flag) { flag = '--' + flag; var pos = argv.indexOf(flag); return pos !== -1 && (terminator !== -1 ? pos < terminator : true); }; var index$13 = (function () { if ('FORCE_COLOR' in process.env) { return true; } if (hasFlag('no-color') || hasFlag('no-colors') || hasFlag('color=false')) { return false; } if (hasFlag('color') || hasFlag('colors') || hasFlag('color=true') || hasFlag('color=always')) { return true; } if (process.stdout && !process.stdout.isTTY) { return false; } if (process.platform === 'win32') { return true; } if ('COLORTERM' in process.env) { return true; } if (process.env.TERM === 'dumb') { return false; } if (/^screen|^xterm|^vt100|color|ansi|cygwin|linux/i.test(process.env.TERM)) { return true; } return false; })(); var defineProps = Object.defineProperties; var isSimpleWindowsTerm = process.platform === 'win32' && !/^xterm/i.test(process.env.TERM); function Chalk(options) { // detect mode if not set manually this.enabled = !options || options.enabled === undefined ? index$13 : options.enabled; } // use bright blue on Windows as the normal blue color is illegible if (isSimpleWindowsTerm) { index$5.blue.open = '\u001b[94m'; } var styles = (function () { var ret = {}; Object.keys(index$5).forEach(function (key) { index$5[key].closeRe = new RegExp(index$3(index$5[key].close), 'g'); ret[key] = { get: function () { return build.call(this, this._styles.concat(key)); } }; }); return ret; })(); var proto = defineProps(function chalk() {}, styles); function build(_styles) { var builder = function () { return applyStyle.apply(builder, arguments); }; builder._styles = _styles; builder.enabled = this.enabled; // __proto__ is used because we must return a function, but there is // no way to create a function with a different prototype. /* eslint-disable no-proto */ builder.__proto__ = proto; return builder; } function applyStyle() { // support varags, but simply cast to string in case there's only one arg var args = arguments; var argsLen = args.length; var str = argsLen !== 0 && String(arguments[0]); if (argsLen > 1) { // don't slice `arguments`, it prevents v8 optimizations for (var a = 1; a < argsLen; a++) { str += ' ' + args[a]; } } if (!this.enabled || !str) { return str; } var nestedStyles = this._styles; var i = nestedStyles.length; // Turns out that on Windows dimmed gray text becomes invisible in cmd.exe, // see https://github.com/chalk/chalk/issues/58 // If we're on Windows and we're dealing with a gray color, temporarily make 'dim' a noop. var originalDim = index$5.dim.open; if (isSimpleWindowsTerm && (nestedStyles.indexOf('gray') !== -1 || nestedStyles.indexOf('grey') !== -1)) { index$5.dim.open = ''; } while (i--) { var code = index$5[nestedStyles[i]]; // Replace any instances already present with a re-opening code // otherwise only the part of the string until said closing code // will be colored, and the rest will simply be 'plain'. str = code.open + str.replace(code.closeRe, code.open) + code.close; } // Reset the original 'dim' if we changed it to work around the Windows dimmed gray issue. index$5.dim.open = originalDim; return str; } function init() { var ret = {}; Object.keys(styles).forEach(function (name) { ret[name] = { get: function () { return build.call(this, [name]); } }; }); return ret; } defineProps(Chalk.prototype, init()); var index$2 = new Chalk(); var styles_1 = index$5; var hasColor = index$11; var stripColor = index$7; var supportsColor_1 = index$13; index$2.styles = styles_1; index$2.hasColor = hasColor; index$2.stripColor = stripColor; index$2.supportsColor = supportsColor_1; 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 index$15 = requireRelative; const absolutePath = /^(?:\/|(?:[A-Za-z]:)?[\\|\/])/; function isAbsolute ( path$$1 ) { return absolutePath.test( path$$1 ); } function relativeId ( id ) { if ( typeof process === 'undefined' || !isAbsolute( id ) ) { return id; } return path.relative( process.cwd(), id ); } if ( !process.stderr.isTTY ) { index$2.enabled = false; } // log to stderr to keep `rollup main.js > bundle.js` from breaking const stderr = console.error.bind( console ); // eslint-disable-line no-console function handleError ( err, recover ) { let description = err.message || err; if (err.name) { description = `${err.name}: ${description}`; } const message = (err.plugin ? `(${err.plugin} plugin) ${description}` : description) || err; stderr( index$2.bold.red( `[!] ${index$2.bold( message )}` ) ); // TODO should this be "err.url || (err.file && err.loc.file) || err.id"? if ( err.url ) { stderr( index$2.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( index$2.dim( err.frame ) ); } else if ( err.stack ) { stderr( index$2.dim( err.stack ) ); } stderr( '' ); if ( !recover ) { process.exit( 1 ); } } function batchWarnings () { let allWarnings = new Map(); let count = 0; return { get count() { return count; }, add: 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: () => { if ( count === 0 ) { return; } const codes = Array.from( allWarnings.keys() ) .sort( ( 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( code => { const handler = deferredHandlers[ code ]; const warnings = allWarnings.get( code ); if ( handler ) { handler.fn( warnings ); } else { warnings.forEach( warning => { stderr( `${index$2.bold.yellow('(!)')} ${index$2.bold.yellow( warning.message )}` ); if ( warning.url ) { info( warning.url ); } const id = warning.loc && warning.loc.file || warning.id; if ( id ) { const loc = warning.loc ? `${relativeId( id )}: (${warning.loc.line}:${warning.loc.column})` : relativeId( id ); stderr( index$2.bold( relativeId( loc ) ) ); } if ( warning.frame ) { info( warning.frame ); } }); } }); allWarnings = new Map(); } }; } const immediateHandlers = { MISSING_NODE_BUILTINS: warning => { title( `Missing shims for Node.js built-ins` ); const detail = warning.modules.length === 1 ? `'${warning.modules[0]}'` : `${warning.modules.slice( 0, -1 ).map( name => `'${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: () => { 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 \`exports: 'named'\` to disable this warning` ); }, EMPTY_BUNDLE: () => { title( `Generated an empty bundle` ); } }; // TODO select sensible priorities const deferredHandlers = { UNUSED_EXTERNAL_IMPORT: { priority: 1, fn: warnings => { title( 'Unused external imports' ); warnings.forEach( warning => { stderr( `${warning.names} imported from external module '${warning.source}' but never used` ); }); } }, UNRESOLVED_IMPORT: { priority: 1, fn: warnings => { title( 'Unresolved dependencies' ); info( 'https://github.com/rollup/rollup/wiki/Troubleshooting#treating-module-as-external-dependency' ); const dependencies = new Map(); warnings.forEach( warning => { if ( !dependencies.has( warning.source ) ) { dependencies.set( warning.source, [] ); } dependencies.get( warning.source ).push( warning.importer ); }); Array.from( dependencies.keys() ).forEach( dependency => { const importers = dependencies.get( dependency ); stderr( `${index$2.bold( dependency )} (imported by ${importers.join( ', ' )})` ); }); } }, MISSING_EXPORT: { priority: 1, fn: warnings => { title( 'Missing exports' ); info( 'https://github.com/rollup/rollup/wiki/Troubleshooting#name-is-not-exported-by-module' ); warnings.forEach( warning => { stderr( index$2.bold( warning.importer ) ); stderr( `${warning.missing} is not exported by ${warning.exporter}` ); stderr( index$2.grey( warning.frame ) ); }); } }, THIS_IS_UNDEFINED: { priority: 1, fn: warnings => { title( '`this` has been rewritten to `undefined`' ); info( 'https://github.com/rollup/rollup/wiki/Troubleshooting#this-is-undefined' ); showTruncatedWarnings(warnings); } }, EVAL: { priority: 1, fn: warnings => { title( 'Use of eval is strongly discouraged' ); info( 'https://github.com/rollup/rollup/wiki/Troubleshooting#avoiding-eval' ); showTruncatedWarnings(warnings); } }, NON_EXISTENT_EXPORT: { priority: 1, fn: warnings => { title( `Import of non-existent ${warnings.length > 1 ? 'exports' : 'export'}` ); showTruncatedWarnings(warnings); } }, NAMESPACE_CONFLICT: { priority: 1, fn: warnings => { title( `Conflicting re-exports` ); warnings.forEach(warning => { stderr( `${index$2.bold(relativeId(warning.reexporter))} re-exports '${warning.name}' from both ${relativeId(warning.sources[0])} and ${relativeId(warning.sources[1])} (will be ignored)` ); }); } }, MISSING_GLOBAL_NAME: { priority: 1, fn: warnings => { title( `Missing global variable ${warnings.length > 1 ? 'names' : 'name'}` ); stderr( `Use options.globals to specify browser global variable names corresponding to external modules` ); warnings.forEach(warning => { stderr(`${index$2.bold(warning.source)} (guessing '${warning.guess}')`); }); } }, SOURCEMAP_BROKEN: { priority: 1, fn: warnings => { title( `Broken sourcemap` ); info( 'https://github.com/rollup/rollup/wiki/Troubleshooting#sourcemap-is-likely-to-be-incorrect' ); const plugins = Array.from( new Set( warnings.map( w => w.plugin ).filter( Boolean ) ) ); const detail = plugins.length === 0 ? '' : plugins.length > 1 ? ` (such as ${plugins.slice(0, -1).map(p => `'${p}'`).join(', ')} and '${plugins.slice(-1)}')` : ` (such as '${plugins[0]}')`; stderr( `Plugins that transform code${detail} should generate accompanying sourcemaps` ); } }, PLUGIN_WARNING: { priority: 1, fn: warnings => { const nestedByPlugin = nest(warnings, 'plugin'); nestedByPlugin.forEach((ref) => { var plugin = ref.key; var items = ref.items; const nestedByMessage = nest(items, 'message'); let lastUrl; nestedByMessage.forEach((ref) => { var message = ref.key; var items = ref.items; title( `${plugin} plugin: ${message}` ); items.forEach(warning => { if ( warning.url !== lastUrl ) { info( lastUrl = warning.url ); } const loc = warning.loc ? `${relativeId( warning.id )}: (${warning.loc.line}:${warning.loc.column})` : relativeId( warning.id ); stderr( index$2.bold( relativeId( loc ) ) ); if ( warning.frame ) { info( warning.frame ); } }); }); }); } } }; function title ( str ) { stderr( `${index$2.bold.yellow('(!)')} ${index$2.bold.yellow( str )}` ); } function info ( url ) { stderr( index$2.grey( url ) ); } function nest(array, prop) { const nested = []; const lookup = new Map(); array.forEach(item => { const key = item[prop]; if (!lookup.has(key)) { lookup.set(key, { key, items: [] }); nested.push(lookup.get(key)); } lookup.get(key).items.push(item); }); return nested; } function showTruncatedWarnings(warnings) { const nestedByModule = nest(warnings, 'id'); const sliced = nestedByModule.length > 5 ? nestedByModule.slice(0, 3) : nestedByModule; sliced.forEach((ref) => { var id = ref.key; var items = ref.items; stderr( index$2.bold( relativeId( id ) ) ); stderr( index$2.grey( 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` ); } } const equivalents = { useStrict: 'useStrict', banner: 'banner', footer: 'footer', format: 'format', globals: 'globals', id: 'moduleId', indent: 'indent', input: 'entry', intro: 'intro', legacy: 'legacy', name: 'moduleName', output: 'dest', outro: 'outro', sourcemap: 'sourceMap', treeshake: 'treeshake' }; function mergeOptions ( config, command ) { const options = Object.assign( {}, config ); let external; const commandExternal = ( command.external || '' ).split( ',' ); const optionsExternal = options.external; if ( command.globals ) { const globals = Object.create( null ); command.globals.split( ',' ).forEach( str => { const names = str.split( ':' ); globals[ names[0] ] = names[1]; // Add missing Module IDs to external. if ( commandExternal.indexOf( names[0] ) === -1 ) { commandExternal.push( names[0] ); } }); command.globals = globals; } if ( typeof optionsExternal === 'function' ) { external = id => { return optionsExternal( id ) || ~commandExternal.indexOf( id ); }; } else { external = ( optionsExternal || [] ).concat( commandExternal ); } if (typeof command.extend !== 'undefined') { options.extend = command.extend; } if (command.silent) { options.onwarn = () => {}; } options.external = external; // Use any options passed through the CLI as overrides. Object.keys( equivalents ).forEach( cliOption => { if ( command.hasOwnProperty( cliOption ) ) { options[ equivalents[ cliOption ] ] = command[ cliOption ]; } }); const targets = options.dest ? [{ dest: options.dest, format: options.format }] : options.targets; options.targets = targets; delete options.dest; return options; } function sequence ( array, fn ) { const results = []; let promise = Promise.resolve(); function next ( member, i ) { return fn( member ).then( value => results[i] = value ); } for ( let i = 0; i < array.length; i += 1 ) { promise = promise.then( () => next( array[i], i ) ); } return promise.then( () => results ); } var index$17 = function (ms) { if (typeof ms !== 'number') { throw new TypeError('Expected a number'); } var roundTowardZero = ms > 0 ? Math.floor : Math.ceil; return { days: roundTowardZero(ms / 86400000), hours: roundTowardZero(ms / 3600000) % 24, minutes: roundTowardZero(ms / 60000) % 60, seconds: roundTowardZero(ms / 1000) % 60, milliseconds: roundTowardZero(ms) % 1000 }; }; var addendum = "addenda"; var aircraft = "aircraft"; var alga = "algae"; var alumna = "alumnae"; var alumnus = "alumni"; var amoeba = "amoebae"; var analysis = "analyses"; var antenna = "antennae"; var antithesis = "antitheses"; var apex = "apices"; var appendix = "appendices"; var automaton = "automata"; var axis = "axes"; var bacillus = "bacilli"; var bacterium = "bacteria"; var barracks = "barracks"; var basis = "bases"; var beau = "beaux"; var bison = "bison"; var buffalo = "buffalo"; var bureau = "bureaus"; var cactus = "cacti"; var calf = "calves"; var carp = "carp"; var census = "censuses"; var chassis = "chassis"; var cherub = "cherubim"; var child = "children"; var cod = "cod"; var codex = "codices"; var concerto = "concerti"; var corpus = "corpora"; var crisis = "crises"; var criterion = "criteria"; var curriculum = "curricula"; var datum = "data"; var deer = "deer"; var diagnosis = "diagnoses"; var die = "dice"; var dwarf = "dwarfs"; var echo = "echoes"; var elf = "elves"; var elk = "elk"; var ellipsis = "ellipses"; var embargo = "embargoes"; var emphasis = "emphases"; var erratum = "errata"; var fez = "fezes"; var firmware = "firmware"; var fish = "fish"; var focus = "foci"; var foot = "feet"; var formula = "formulae"; var fungus = "fungi"; var gallows = "gallows"; var genus = "genera"; var goose = "geese"; var graffito = "graffiti"; var grouse = "grouse"; var half = "halves"; var hero = "heroes"; var hoof = "hooves"; var hovercraft = "hovercraft"; var hypothesis = "hypotheses"; var index$21 = "indices"; var kakapo = "kakapo"; var knife = "knives"; var larva = "larvae"; var leaf = "leaves"; var libretto = "libretti"; var life = "lives"; var loaf = "loaves"; var locus = "loci"; var louse = "lice"; var man = "men"; var matrix = "matrices"; var means = "means"; var medium = "media"; var memorandum = "memoranda"; var millennium = "millennia"; var minutia = "minutiae"; var moose = "moose"; var mouse = "mice"; var nebula = "nebulae"; var nemesis = "nemeses"; var neurosis = "neuroses"; var news = "news"; var nucleus = "nuclei"; var oasis = "oases"; var offspring = "offspring"; var opus = "opera"; var ovum = "ova"; var ox = "oxen"; var paralysis = "paralyses"; var parenthesis = "parentheses"; var person = "people"; var phenomenon = "phenomena"; var phylum = "phyla"; var pike = "pike"; var polyhedron = "polyhedra"; var potato = "potatoes"; var prognosis = "prognoses"; var quiz = "quizzes"; var radius = "radii"; var referendum = "referenda"; var salmon = "salmon"; var scarf = "scarves"; var self$1 = "selves"; var series = "series"; var sheep = "sheep"; var shelf = "shelves"; var shrimp = "shrimp"; var spacecraft = "spacecraft"; var species = "species"; var spectrum = "spectra"; var squid = "squid"; var stimulus = "stimuli"; var stratum = "strata"; var swine = "swine"; var syllabus = "syllabi"; var symposium = "symposia"; var synopsis = "synopses"; var synthesis = "syntheses"; var tableau = "tableaus"; var that = "those"; var thesis = "theses"; var thief = "thieves"; var tomato = "tomatoes"; var tooth = "teeth"; var trout = "trout"; var tuna = "tuna"; var vertebra = "vertebrae"; var vertex = "vertices"; var veto = "vetoes"; var vita = "vitae"; var vortex = "vortices"; var watercraft = "watercraft"; var wharf = "wharves"; var wife = "wives"; var wolf = "wolves"; var woman = "women"; var irregularPlurals = { addendum: addendum, aircraft: aircraft, alga: alga, alumna: alumna, alumnus: alumnus, amoeba: amoeba, analysis: analysis, antenna: antenna, antithesis: antithesis, apex: apex, appendix: appendix, automaton: automaton, axis: axis, bacillus: bacillus, bacterium: bacterium, barracks: barracks, basis: basis, beau: beau, bison: bison, buffalo: buffalo, bureau: bureau, cactus: cactus, calf: calf, carp: carp, census: census, chassis: chassis, cherub: cherub, child: child, cod: cod, codex: codex, concerto: concerto, corpus: corpus, crisis: crisis, criterion: criterion, curriculum: curriculum, datum: datum, deer: deer, diagnosis: diagnosis, die: die, dwarf: dwarf, echo: echo, elf: elf, elk: elk, ellipsis: ellipsis, embargo: embargo, emphasis: emphasis, erratum: erratum, fez: fez, firmware: firmware, fish: fish, focus: focus, foot: foot, formula: formula, fungus: fungus, gallows: gallows, genus: genus, goose: goose, graffito: graffito, grouse: grouse, half: half, hero: hero, hoof: hoof, hovercraft: hovercraft, hypothesis: hypothesis, index: index$21, kakapo: kakapo, knife: knife, larva: larva, leaf: leaf, libretto: libretto, life: life, loaf: loaf, locus: locus, louse: louse, man: man, matrix: matrix, means: means, medium: medium, memorandum: memorandum, millennium: millennium, minutia: minutia, moose: moose, mouse: mouse, nebula: nebula, nemesis: nemesis, neurosis: neurosis, news: news, nucleus: nucleus, oasis: oasis, offspring: offspring, opus: opus, ovum: ovum, ox: ox, paralysis: paralysis, parenthesis: parenthesis, person: person, phenomenon: phenomenon, phylum: phylum, pike: pike, polyhedron: polyhedron, potato: potato, prognosis: prognosis, quiz: quiz, radius: radius, referendum: referendum, salmon: salmon, scarf: scarf, self: self$1, series: series, sheep: sheep, shelf: shelf, shrimp: shrimp, spacecraft: spacecraft, species: species, spectrum: spectrum, squid: squid, stimulus: stimulus, stratum: stratum, swine: swine, syllabus: syllabus, symposium: symposium, synopsis: synopsis, synthesis: synthesis, tableau: tableau, that: that, thesis: thesis, thief: thief, tomato: tomato, tooth: tooth, trout: trout, tuna: tuna, vertebra: vertebra, vertex: vertex, veto: veto, vita: vita, vortex: vortex, watercraft: watercraft, wharf: wharf, wife: wife, wolf: wolf, woman: woman, "château": "châteaus", "faux pas": "faux pas" }; var irregularPlurals$1 = Object.freeze({ addendum: addendum, aircraft: aircraft, alga: alga, alumna: alumna, alumnus: alumnus, amoeba: amoeba, analysis: analysis, antenna: antenna, antithesis: antithesis, apex: apex, appendix: appendix, automaton: automaton, axis: axis, bacillus: bacillus, bacterium: bacterium, barracks: barracks, basis: basis, beau: beau, bison: bison, buffalo: buffalo, bureau: bureau, cactus: cactus, calf: calf, carp: carp, census: census, chassis: chassis, cherub: cherub, child: child, cod: cod, codex: codex, concerto: concerto, corpus: corpus, crisis: crisis, criterion: criterion, curriculum: curriculum, datum: datum, deer: deer, diagnosis: diagnosis, die: die, dwarf: dwarf, echo: echo, elf: elf, elk: elk, ellipsis: ellipsis, embargo: embargo, emphasis: emphasis, erratum: erratum, fez: fez, firmware: firmware, fish: fish, focus: focus, foot: foot, formula: formula, fungus: fungus, gallows: gallows, genus: genus, goose: goose, graffito: graffito, grouse: grouse, half: half, hero: hero, hoof: hoof, hovercraft: hovercraft, hypothesis: hypothesis, index: index$21, kakapo: kakapo, knife: knife, larva: larva, leaf: leaf, libretto: libretto, life: life, loaf: loaf, locus: locus, louse: louse, man: man, matrix: matrix, means: means, medium: medium, memorandum: memorandum, millennium: millennium, minutia: minutia, moose: moose, mouse: mouse, nebula: nebula, nemesis: nemesis, neurosis: neurosis, news: news, nucleus: nucleus, oasis: oasis, offspring: offspring, opus: opus, ovum: ovum, ox: ox, paralysis: paralysis, parenthesis: parenthesis, person: person, phenomenon: phenomenon, phylum: phylum, pike: pike, polyhedron: polyhedron, potato: potato, prognosis: prognosis, quiz: quiz, radius: radius, referendum: referendum, salmon: salmon, scarf: scarf, self: self$1, series: series, sheep: sheep, shelf: shelf, shrimp: shrimp, spacecraft: spacecraft, species: species, spectrum: spectrum, squid: squid, stimulus: stimulus, stratum: stratum, swine: swine, syllabus: syllabus, symposium: symposium, synopsis: synopsis, synthesis: synthesis, tableau: tableau, that: that, thesis: thesis, thief: thief, tomato: tomato, tooth: tooth, trout: trout, tuna: tuna, vertebra: vertebra, vertex: vertex, veto: veto, vita: vita, vortex: vortex, watercraft: watercraft, wharf: wharf, wife: wife, wolf: wolf, woman: woman, default: irregularPlurals }); var irregularPlurals$2 = ( irregularPlurals$1 && irregularPlurals ) || irregularPlurals$1; var index$19 = function (str, plural, count) { if (typeof plural === 'number') { count = plural; } if (str in irregularPlurals$2) { plural = irregularPlurals$2[str]; } else if (typeof plural !== 'string') { plural = (str.replace(/(?:s|x|z|ch|sh)$/i, '$&e').replace(/([^aeiou])y$/i, '$1ie') + 's') .replace(/i?e?s$/i, function (m) { var isTailLowerCase = str.slice(-1) === str.slice(-1).toLowerCase(); return isTailLowerCase ? m.toLowerCase() : m.toUpperCase(); }); } return count === 1 ? str : plural; }; var index$16 = createCommonjsModule(function (module) { 'use strict'; module.exports = (ms, opts) => { if (!Number.isFinite(ms)) { throw new TypeError('Expected a finite number'); } opts = opts || {}; if (ms < 1000) { const msDecimalDigits = typeof opts.msDecimalDigits === 'number' ? opts.msDecimalDigits : 0; return (msDecimalDigits ? ms.toFixed(msDecimalDigits) : Math.ceil(ms)) + (opts.verbose ? ' ' + index$19('millisecond', Math.ceil(ms)) : 'ms'); } const ret = []; const add = (val, long, short, valStr) => { if (val === 0) { return; } const postfix = opts.verbose ? ' ' + index$19(long, val) : short; ret.push((valStr || val) + postfix); }; const parsed = index$17(ms); 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 (opts.compact) { add(parsed.seconds, 'second', 's'); return '~' + ret[0]; } const sec = ms / 1000 % 60; const secDecimalDigits = typeof opts.secDecimalDigits === 'number' ? opts.secDecimalDigits : 1; const secStr = sec.toFixed(secDecimalDigits).replace(/\.0$/, ''); add(sec, 'second', 's', secStr); return ret.join(' '); }; }); function mapSequence ( array, fn ) { const results = []; let promise = Promise.resolve(); function next ( member, i ) { return fn( member ).then( value => results[i] = value ); } for ( let i = 0; i < array.length; i += 1 ) { promise = promise.then( () => next( array[i], i ) ); } return promise.then( () => results ); } let SOURCEMAPPING_URL = 'sourceMa'; SOURCEMAPPING_URL += 'ppingURL'; var SOURCEMAPPING_URL$1 = SOURCEMAPPING_URL; function build$1 ( options, warnings, silent ) { const useStdout = !options.targets && !options.dest; const targets = options.targets ? options.targets : [{ dest: options.dest, format: options.format }]; const start = Date.now(); const dests = useStdout ? [ 'stdout' ] : targets.map( t => relativeId( t.dest ) ); if ( !silent ) { stderr( index$2.cyan( `\n${index$2.bold( options.entry )} → ${index$2.bold( dests.join( ', ' ) )}...` ) ); } return rollup.rollup( options ) .then( bundle => { if ( useStdout ) { if ( options.sourceMap && options.sourceMap !== 'inline' ) { handleError({ code: 'MISSING_OUTPUT_OPTION', message: 'You must specify an --output (-o) option when creating a file with a sourcemap' }); } return bundle.generate(options).then( (ref) => { var code = ref.code; var map = ref.map; if ( options.sourceMap === 'inline' ) { code += `\n//# ${SOURCEMAPPING_URL$1}=${map.toUrl()}\n`; } process.stdout.write( code ); }); } return mapSequence( targets, target => { return bundle.write( assign( clone( options ), target ) ); }); }) .then( () => { warnings.flush(); if ( !silent ) { stderr( index$2.green( `created ${index$2.bold( dests.join( ', ' ) )} in ${index$2.bold(index$16( Date.now() - start))}` ) ); } }) .catch( handleError ); } function clone ( object ) { return assign( {}, object ); } function assign ( target, source ) { Object.keys( source ).forEach( key => { target[ key ] = source[ key ]; }); return target; } function watch$1(configs, command, silent) { process.stderr.write('\x1b[?1049h'); // alternate screen buffer const warnings = batchWarnings(); configs = configs.map(options => { const merged = mergeOptions(options, command); const onwarn = merged.onwarn; if ( onwarn ) { merged.onwarn = warning => { onwarn( warning, warnings.add ); }; } else { merged.onwarn = warnings.add; } return merged; }); const watcher = rollup.watch(configs); watcher.on('event', event => { switch (event.code) { case 'FATAL': process.stderr.write('\x1b[?1049l'); // reset screen buffer handleError(event.error, true); process.exit(1); break; case 'ERROR': warnings.flush(); handleError(event.error, true); break; case 'START': stderr(`\x1B[2J\x1B[0f${index$2.underline( 'rollup.watch' )}`); // clear, move to top-left break; case 'BUNDLE_START': if ( !silent ) { stderr( index$2.cyan( `\n${index$2.bold( event.input )} → ${index$2.bold( event.output.map( relativeId ).join( ', ' ) )}...` ) ); } break; case 'BUNDLE_END': warnings.flush(); if ( !silent ) { stderr( index$2.green( `created ${index$2.bold( event.output.map( relativeId ).join( ', ' ) )} in ${index$2.bold(index$16(event.duration))}` ) ); } break; case 'END': if ( !silent ) { stderr( `\nwaiting for changes...` ); } } }); let closed = false; const close = () => { if (!closed) { process.stderr.write('\x1b[?1049l'); // reset screen buffer closed = true; watcher.close(); } }; process.on('SIGINT', close); // ctrl-c process.on('SIGTERM', close); // killall node process.on('uncaughtException', close); // on error process.stdin.on('end', close); // in case we ever support stdin! } function runRollup ( command ) { if ( command._.length > 1 ) { handleError({ code: 'ONE_AT_A_TIME', message: 'rollup can only bundle one file at a time' }); } if ( command._.length === 1 ) { if ( command.input ) { handleError({ code: 'DUPLICATE_IMPORT_OPTIONS', message: 'use --input, or pass input path as argument' }); } command.input = command._[0]; } if ( command.environment ) { command.environment.split( ',' ).forEach( pair => { const index = pair.indexOf( ':' ); if ( ~index ) { process.env[ pair.slice( 0, index ) ] = pair.slice( index + 1 ); } else { process.env[ pair ] = true; } }); } let config = command.config === true ? 'rollup.config.js' : command.config; if ( config ) { if ( config.slice( 0, 5 ) === 'node:' ) { const pkgName = config.slice( 5 ); try { config = index$15.resolve( `rollup-config-${pkgName}`, process.cwd() ); } catch ( err ) { try { config = index$15.resolve( pkgName, process.cwd() ); } catch ( err ) { if ( err.code === 'MODULE_NOT_FOUND' ) { handleError({ code: 'MISSING_EXTERNAL_CONFIG', message: `Could not resolve config file ${config}` }); } throw err; } } } else { // find real path of config so it matches what Node provides to callbacks in require.extensions config = fs.realpathSync( config ); } const warnings = batchWarnings(); rollup.rollup({ entry: config, external: id => { return (id[0] !== '.' && !path__default.isAbsolute(id)) || id.slice(-5,id.length) === '.json'; }, onwarn: warnings.add }) .then( bundle => { if ( !command.silent && warnings.count > 0 ) { stderr( index$2.bold( `loaded ${relativeId( config )} with warnings` ) ); warnings.flush(); } return bundle.generate({ format: 'cjs' }); }) .then( (ref) => { var code = ref.code; // temporarily override require const defaultLoader = require.extensions[ '.js' ]; require.extensions[ '.js' ] = ( m, filename ) => { if ( filename === config ) { m._compile( code, filename ); } else { defaultLoader( m, filename ); } }; const configs = require( config ); 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://github.com/rollup/rollup/wiki/Command-Line-Interface#using-a-config-file' }); } require.extensions[ '.js' ] = defaultLoader; const normalized = Array.isArray( configs ) ? configs : [configs]; return execute( normalized, command ); }) .catch( handleError ); } else { return execute( [{}], command ); } } function execute ( configs, command ) { if ( command.watch ) { process.env.ROLLUP_WATCH = 'true'; watch$1( configs, command, command.silent ); } else { return sequence( configs, config => { const options = mergeOptions( config, command ); const warnings = batchWarnings(); const onwarn = options.onwarn; if ( onwarn ) { options.onwarn = warning => { onwarn( warning, warnings.add ); }; } else { options.onwarn = warnings.add; } return build$1( options, warnings, command.silent ); }); } } const command = index$1( process.argv.slice( 2 ), { alias: { // Aliases strict: 'useStrict', // Short options c: 'config', d: 'indent', e: 'external', f: 'format', g: 'globals', h: 'help', i: 'input', l: 'legacy', m: 'sourcemap', n: 'name', o: 'output', u: 'id', v: 'version', w: 'watch' } }); if ( command.help || ( process.argv.length <= 2 && process.stdin.isTTY ) ) { console.log( `\n${help.replace('__VERSION__', version)}\n` ); // eslint-disable-line no-console } else if ( command.version ) { console.log( `rollup version ${version}` ); // eslint-disable-line no-console } else { runRollup( command ); }