rollup 0.57.0 → 0.57.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # rollup changelog
2
2
 
3
+ ## 0.57.1
4
+ * Improve sourcemap generation performance ([#2062](https://github.com/rollup/rollup/pull/2062))
5
+ * Add reserved config option namespace and improve CLI interface ([#2063](https://github.com/rollup/rollup/pull/2063))
6
+ * Fix issue with default exported function and class expressions ([#2059](https://github.com/rollup/rollup/pull/2059))
7
+ * Replace `forEach` with faster `for` loops in some places ([#2064](https://github.com/rollup/rollup/pull/2064))
8
+
3
9
  ## 0.57.0
4
10
  * Add option to preserve the module structure instead of bundling ([#1922](https://github.com/rollup/rollup/pull/1922))
5
11
  * Enable watch mode when code-splitting ([#2035](https://github.com/rollup/rollup/pull/2035))
package/bin/rollup CHANGED
@@ -249,9 +249,9 @@ function isNumber (x) {
249
249
  return /^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(x);
250
250
  }
251
251
 
252
- var help = "rollup version __VERSION__\n=====================================\n\nUsage: rollup [options] <entry file>\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 <entry file>)\n-o, --output.file <output> Output (if absent, prints to stdout)\n-f, --output.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-m, --sourcemap Generate sourcemap (`-m inline` for inline map)\n-l, --legacy Support IE8\n--amd.id ID for AMD module (default is anonymous)\n--amd.define Function to use in place of `define`\n--no-strict Don't emit a `\"use strict\";` in the generated modules.\n--no-indent Don't indent result\n--environment <values> Settings passed to config file (see example)\n--no-conflict Generate a noConflict method for UMD globals\n--no-treeshake Disable tree-shaking\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--interop Include interop block (true by default)\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://rollupjs.org\n";
252
+ var help = "rollup version __VERSION__\n=====================================\n\nUsage: rollup [options] <entry file>\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 <entry file>)\n-o, --file <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-m, --sourcemap Generate sourcemap (`-m inline` for inline map)\n-l, --legacy Support IE8\n--amd.id ID for AMD module (default is anonymous)\n--amd.define Function to use in place of `define`\n--no-strict Don't emit a `\"use strict\";` in the generated modules.\n--no-indent Don't indent result\n--environment <values> Settings passed to config file (see example)\n--no-conflict Generate a noConflict method for UMD globals\n--no-treeshake Disable tree-shaking\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--no-interop Do not include interop block\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";
253
253
 
254
- var version = "0.57.0";
254
+ var version = "0.57.1";
255
255
 
256
256
  var modules = {};
257
257
 
@@ -2328,7 +2328,12 @@ function deprecateOptions(options, deprecateConfig) {
2328
2328
  }
2329
2329
  }
2330
2330
 
2331
- function normalizeObjectOptionValue(optionValue) {
2331
+ var createGetOption = function (config, command) { return function (name, defaultValue) {
2332
+ return command[name] !== undefined
2333
+ ? command[name]
2334
+ : config[name] !== undefined ? config[name] : defaultValue;
2335
+ }; };
2336
+ var normalizeObjectOptionValue = function (optionValue) {
2332
2337
  if (!optionValue) {
2333
2338
  return optionValue;
2334
2339
  }
@@ -2336,7 +2341,17 @@ function normalizeObjectOptionValue(optionValue) {
2336
2341
  return {};
2337
2342
  }
2338
2343
  return optionValue;
2339
- }
2344
+ };
2345
+ var getObjectOption = function (config, command, name) {
2346
+ var commandOption = normalizeObjectOptionValue(command[name]);
2347
+ var configOption = normalizeObjectOptionValue(config[name]);
2348
+ if (commandOption !== undefined) {
2349
+ return commandOption && configOption
2350
+ ? Object.assign({}, configOption, commandOption)
2351
+ : commandOption;
2352
+ }
2353
+ return configOption;
2354
+ };
2340
2355
  var defaultOnWarn = function (warning) {
2341
2356
  if (typeof warning === 'string') {
2342
2357
  console.warn(warning); // eslint-disable-line no-console
@@ -2345,148 +2360,147 @@ var defaultOnWarn = function (warning) {
2345
2360
  console.warn(warning.message); // eslint-disable-line no-console
2346
2361
  }
2347
2362
  };
2348
- function mergeOptions(_a) {
2349
- var config = _a.config, _b = _a.command, command = _b === void 0 ? {} : _b, deprecateConfig = _a.deprecateConfig, _c = _a.defaultOnWarnHandler, defaultOnWarnHandler = _c === void 0 ? defaultOnWarn : _c;
2350
- var deprecations = deprecate(config, command, deprecateConfig);
2351
- var getOption = function (config) { return function (name) {
2352
- return command[name] !== undefined ? command[name] : config[name];
2353
- }; };
2354
- var getInputOption = getOption(config);
2355
- var getOutputOption = getOption(config.output || {});
2356
- function getObjectOption(name) {
2357
- var commandOption = normalizeObjectOptionValue(command[name]);
2358
- var configOption = normalizeObjectOptionValue(config[name]);
2359
- if (commandOption !== undefined) {
2360
- return commandOption && configOption
2361
- ? Object.assign({}, configOption, commandOption)
2362
- : commandOption;
2363
+ var getOnWarn = function (config, command, defaultOnWarnHandler) {
2364
+ if (defaultOnWarnHandler === void 0) { defaultOnWarnHandler = defaultOnWarn; }
2365
+ return command.silent
2366
+ ? function () { }
2367
+ : config.onwarn
2368
+ ? function (warning) { return config.onwarn(warning, defaultOnWarnHandler); }
2369
+ : defaultOnWarnHandler;
2370
+ };
2371
+ var getExternal = function (config, command) {
2372
+ var configExternal = config.external;
2373
+ return typeof configExternal === 'function'
2374
+ ? function (id) {
2375
+ var rest = [];
2376
+ for (var _i = 1; _i < arguments.length; _i++) {
2377
+ rest[_i - 1] = arguments[_i];
2378
+ }
2379
+ return configExternal.apply(void 0, [id].concat(rest)) || command.external.indexOf(id) !== -1;
2363
2380
  }
2364
- return configOption;
2365
- }
2366
- var onwarn = config.onwarn;
2367
- var warn;
2368
- if (onwarn) {
2369
- warn = function (warning) { return onwarn(warning, defaultOnWarnHandler); };
2381
+ : (configExternal || []).concat(command.external);
2382
+ };
2383
+ var commandAliases = {
2384
+ c: 'config',
2385
+ d: 'indent',
2386
+ e: 'external',
2387
+ f: 'format',
2388
+ g: 'globals',
2389
+ h: 'help',
2390
+ i: 'input',
2391
+ l: 'legacy',
2392
+ m: 'sourcemap',
2393
+ n: 'name',
2394
+ o: 'file',
2395
+ v: 'version',
2396
+ w: 'watch'
2397
+ };
2398
+ function mergeOptions(_a) {
2399
+ var _b = _a.config, config = _b === void 0 ? {} : _b, _c = _a.command, rawCommandOptions = _c === void 0 ? {} : _c, deprecateConfig = _a.deprecateConfig, defaultOnWarnHandler = _a.defaultOnWarnHandler;
2400
+ var deprecations = deprecate(config, rawCommandOptions, deprecateConfig);
2401
+ var command = getCommandOptions(rawCommandOptions);
2402
+ var inputOptions = getInputOptions(config, command, defaultOnWarnHandler);
2403
+ if (command.output) {
2404
+ Object.assign(command, command.output);
2370
2405
  }
2371
- else {
2372
- warn = defaultOnWarnHandler;
2406
+ var normalizedOutputOptions = ensureArray(config.output);
2407
+ if (normalizedOutputOptions.length === 0)
2408
+ normalizedOutputOptions.push({});
2409
+ var outputOptions = normalizedOutputOptions.map(function (singleOutputOptions) {
2410
+ return getOutputOptions(singleOutputOptions, command);
2411
+ });
2412
+ var unknownOptionErrors = [];
2413
+ var validInputOptions = Object.keys(inputOptions);
2414
+ addUnknownOptionErrors(unknownOptionErrors, Object.keys(config), validInputOptions, 'input option', /^output$/);
2415
+ var validOutputOptions = Object.keys(outputOptions[0]);
2416
+ addUnknownOptionErrors(unknownOptionErrors, outputOptions.reduce(function (allKeys, options) { return allKeys.concat(Object.keys(options)); }, []), validOutputOptions, 'output option');
2417
+ addUnknownOptionErrors(unknownOptionErrors, Object.keys(command), validInputOptions.concat(validOutputOptions, Object.keys(commandAliases), 'config', 'environment', 'silent'), 'CLI flag', /^_|output|(config.*)$/);
2418
+ return {
2419
+ inputOptions: inputOptions,
2420
+ outputOptions: outputOptions,
2421
+ deprecations: deprecations,
2422
+ optionError: unknownOptionErrors.length > 0 ? unknownOptionErrors.join('\n') : null
2423
+ };
2424
+ }
2425
+ function addUnknownOptionErrors(errors, options, validOptions, optionType, ignoredKeys) {
2426
+ if (ignoredKeys === void 0) { ignoredKeys = /$./; }
2427
+ var unknownOptions = options.filter(function (key) { return validOptions.indexOf(key) === -1 && !ignoredKeys.test(key); });
2428
+ if (unknownOptions.length > 0)
2429
+ errors.push("Unknown " + optionType + ": " + unknownOptions.join(', ') + ". Allowed options: " + validOptions.sort().join(', '));
2430
+ }
2431
+ function getCommandOptions(rawCommandOptions) {
2432
+ var command = Object.assign({}, rawCommandOptions);
2433
+ command.external = (rawCommandOptions.external || '').split(',');
2434
+ if (rawCommandOptions.globals) {
2435
+ command.globals = Object.create(null);
2436
+ rawCommandOptions.globals.split(',').forEach(function (str) {
2437
+ var names = str.split(':');
2438
+ command.globals[names[0]] = names[1];
2439
+ // Add missing Module IDs to external.
2440
+ if (command.external.indexOf(names[0]) === -1) {
2441
+ command.external.push(names[0]);
2442
+ }
2443
+ });
2373
2444
  }
2445
+ return command;
2446
+ }
2447
+ function getInputOptions(config, command, defaultOnWarnHandler) {
2448
+ if (command === void 0) { command = {}; }
2449
+ var getOption = createGetOption(config, command);
2374
2450
  var inputOptions = {
2375
2451
  acorn: config.acorn,
2376
2452
  acornInjectPlugins: config.acornInjectPlugins,
2377
- cache: getInputOption('cache'),
2453
+ cache: getOption('cache'),
2378
2454
  context: config.context,
2379
- experimentalCodeSplitting: getInputOption('experimentalCodeSplitting'),
2380
- experimentalDynamicImport: getInputOption('experimentalDynamicImport'),
2381
- experimentalPreserveModules: getInputOption('experimentalPreserveModules'),
2382
- input: getInputOption('input'),
2383
- legacy: getInputOption('legacy'),
2455
+ experimentalCodeSplitting: getOption('experimentalCodeSplitting'),
2456
+ experimentalDynamicImport: getOption('experimentalDynamicImport'),
2457
+ experimentalPreserveModules: getOption('experimentalPreserveModules'),
2458
+ external: getExternal(config, command),
2459
+ input: getOption('input'),
2384
2460
  moduleContext: config.moduleContext,
2385
- onwarn: warn,
2386
- perf: getInputOption('perf'),
2461
+ onwarn: getOnWarn(config, command, defaultOnWarnHandler),
2462
+ perf: getOption('perf', false),
2387
2463
  plugins: config.plugins,
2388
- preferConst: getInputOption('preferConst'),
2389
- preserveSymlinks: getInputOption('preserveSymlinks'),
2390
- treeshake: getObjectOption('treeshake'),
2464
+ preferConst: getOption('preferConst'),
2465
+ preserveSymlinks: getOption('preserveSymlinks'),
2466
+ treeshake: getObjectOption(config, command, 'treeshake'),
2391
2467
  watch: config.watch
2392
2468
  };
2393
- // legacy, to ensure e.g. commonjs plugin still works
2394
- inputOptions.entry = inputOptions.input;
2395
- var commandExternal = (command.external || '').split(',');
2396
- var configExternal = config.external;
2397
- if (command.globals) {
2398
- var globals_1 = Object.create(null);
2399
- command.globals.split(',').forEach(function (str) {
2400
- var names = str.split(':');
2401
- globals_1[names[0]] = names[1];
2402
- // Add missing Module IDs to external.
2403
- if (commandExternal.indexOf(names[0]) === -1) {
2404
- commandExternal.push(names[0]);
2405
- }
2406
- });
2407
- command.globals = globals_1;
2408
- }
2409
- if (typeof configExternal === 'function') {
2410
- inputOptions.external = function (id) {
2411
- var rest = [];
2412
- for (var _i = 1; _i < arguments.length; _i++) {
2413
- rest[_i - 1] = arguments[_i];
2414
- }
2415
- return configExternal.apply(void 0, [id].concat(rest)) || commandExternal.indexOf(id) !== -1;
2416
- };
2417
- }
2418
- else {
2419
- inputOptions.external = (configExternal || []).concat(commandExternal);
2420
- }
2421
- if (command.silent) {
2422
- inputOptions.onwarn = function () { };
2423
- }
2424
- // Make sure the CLI treats this the same way as when we are code-splitting
2425
2469
  if (inputOptions.experimentalPreserveModules && !Array.isArray(inputOptions.input)) {
2426
2470
  inputOptions.input = [inputOptions.input];
2427
2471
  }
2428
- var baseOutputOptions = {
2429
- amd: Object.assign({}, config.amd, command.amd),
2430
- banner: getOutputOption('banner'),
2431
- dir: getOutputOption('dir'),
2432
- exports: getOutputOption('exports'),
2433
- extend: getOutputOption('extend'),
2434
- file: getOutputOption('file'),
2435
- footer: getOutputOption('footer'),
2436
- format: getOutputOption('format'),
2437
- freeze: getOutputOption('freeze'),
2438
- globals: getOutputOption('globals'),
2439
- indent: getOutputOption('indent'),
2440
- interop: getOutputOption('interop'),
2441
- intro: getOutputOption('intro'),
2442
- legacy: getOutputOption('legacy'),
2443
- name: getOutputOption('name'),
2444
- namespaceToStringTag: getOutputOption('namespaceToStringTag'),
2445
- noConflict: getOutputOption('noConflict'),
2446
- outro: getOutputOption('outro'),
2447
- paths: getOutputOption('paths'),
2448
- sourcemap: getOutputOption('sourcemap'),
2449
- sourcemapFile: getOutputOption('sourcemapFile'),
2450
- strict: getOutputOption('strict')
2451
- };
2452
- var mergedOutputOptions;
2453
- if (Array.isArray(config.output)) {
2454
- mergedOutputOptions = config.output.map(function (output) {
2455
- return Object.assign({}, output, command.output);
2456
- });
2457
- }
2458
- else if (config.output && command.output) {
2459
- mergedOutputOptions = [Object.assign({}, config.output, command.output)];
2460
- }
2461
- else {
2462
- mergedOutputOptions =
2463
- command.output || config.output
2464
- ? ensureArray(command.output || config.output)
2465
- : [
2466
- {
2467
- file: command.output ? command.output.file : null,
2468
- format: command.output ? command.output.format : null
2469
- }
2470
- ];
2471
- }
2472
- var outputOptions = mergedOutputOptions.map(function (output) {
2473
- return Object.assign({}, baseOutputOptions, output);
2474
- });
2475
- // check for errors
2476
- var validKeys = Object.keys(inputOptions).concat(Object.keys(baseOutputOptions), [
2477
- 'pureExternalModules' // (backward compatibility) till everyone moves to treeshake.pureExternalModules
2478
- ]);
2479
- var outputOptionKeys = Array.isArray(config.output)
2480
- ? config.output.reduce(function (keys, o) { return keys.concat(Object.keys(o)); }, [])
2481
- : Object.keys(config.output || {});
2482
- var errors = Object.keys(config || {}).concat(outputOptionKeys).filter(function (k) { return k !== 'output' && validKeys.indexOf(k) === -1; });
2472
+ // legacy to make sure certain plugins still work
2473
+ inputOptions.entry = Array.isArray(inputOptions.input)
2474
+ ? inputOptions.input[0]
2475
+ : inputOptions.input;
2476
+ return inputOptions;
2477
+ }
2478
+ function getOutputOptions(config, command) {
2479
+ if (command === void 0) { command = {}; }
2480
+ var getOption = createGetOption(config, command);
2483
2481
  return {
2484
- inputOptions: inputOptions,
2485
- outputOptions: outputOptions,
2486
- deprecations: deprecations,
2487
- optionError: errors.length
2488
- ? "Unknown option found: " + errors.join(', ') + ". Allowed keys: " + validKeys.join(', ')
2489
- : null
2482
+ amd: Object.assign({}, config.amd, command.amd),
2483
+ banner: getOption('banner'),
2484
+ dir: getOption('dir'),
2485
+ exports: getOption('exports'),
2486
+ extend: getOption('extend'),
2487
+ file: getOption('file'),
2488
+ footer: getOption('footer'),
2489
+ format: getOption('format'),
2490
+ freeze: getOption('freeze'),
2491
+ globals: getOption('globals'),
2492
+ indent: getOption('indent', true),
2493
+ interop: getOption('interop', true),
2494
+ intro: getOption('intro'),
2495
+ legacy: getOption('legacy', false),
2496
+ name: getOption('name'),
2497
+ namespaceToStringTag: getOption('namespaceToStringTag'),
2498
+ noConflict: getOption('noConflict'),
2499
+ outro: getOption('outro'),
2500
+ paths: getOption('paths'),
2501
+ sourcemap: getOption('sourcemap'),
2502
+ sourcemapFile: getOption('sourcemapFile'),
2503
+ strict: getOption('strict', true)
2490
2504
  };
2491
2505
  }
2492
2506
  function deprecate(config, command, deprecateConfig) {
@@ -2504,17 +2518,10 @@ function deprecate(config, command, deprecateConfig) {
2504
2518
  if (typeof command.output === 'string') {
2505
2519
  deprecations.push({
2506
2520
  old: '--output',
2507
- new: '--output.file'
2521
+ new: '--file'
2508
2522
  });
2509
2523
  command.output = { file: command.output };
2510
2524
  }
2511
- if (command.format) {
2512
- deprecations.push({
2513
- old: '--format',
2514
- new: '--output.format'
2515
- });
2516
- (command.output || (command.output = {})).format = command.format;
2517
- }
2518
2525
  // config file
2519
2526
  deprecations.push.apply(deprecations, deprecateOptions(config, deprecateConfig));
2520
2527
  return deprecations;
@@ -4059,25 +4066,7 @@ function execute(configFile, configs, command) {
4059
4066
  }
4060
4067
 
4061
4068
  var command = minimist(process.argv.slice(2), {
4062
- alias: {
4063
- // Aliases
4064
- strict: 'useStrict',
4065
- dir: 'output.dir',
4066
- // Short options
4067
- c: 'config',
4068
- d: 'indent',
4069
- e: 'external',
4070
- f: 'output.format',
4071
- g: 'globals',
4072
- h: 'help',
4073
- i: 'input',
4074
- l: 'legacy',
4075
- m: 'sourcemap',
4076
- n: 'name',
4077
- o: 'output.file',
4078
- v: 'version',
4079
- w: 'watch'
4080
- }
4069
+ alias: commandAliases
4081
4070
  });
4082
4071
  if (command.help || (process.argv.length <= 2 && process.stdin.isTTY)) {
4083
4072
  console.log("\n" + help.replace('__VERSION__', version) + "\n"); // eslint-disable-line no-console