rollup 2.71.1 → 2.73.0

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.
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v2.71.1
4
- Sat, 30 Apr 2022 13:35:44 GMT - commit f44a3a38b357c2ba80a99aca36cfd30dcfb84476
3
+ Rollup.js v2.73.0
4
+ Fri, 13 May 2022 15:50:44 GMT - commit 931a19940f58c745e9da9eae5585b551f356b2ed
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -19,6 +19,7 @@ const rollup = require('./rollup.js');
19
19
  const require$$0 = require('assert');
20
20
  const require$$0$1 = require('events');
21
21
  const loadConfigFile = require('./loadConfigFile.js');
22
+ const child_process = require('child_process');
22
23
  require('util');
23
24
  require('stream');
24
25
  require('path');
@@ -357,6 +358,33 @@ function getResetScreen(configs, allowClearScreen) {
357
358
  };
358
359
  }
359
360
 
361
+ function extractWatchHooks(command) {
362
+ if (!Array.isArray(command.watch))
363
+ return {};
364
+ return command.watch
365
+ .filter(value => typeof value === 'object')
366
+ .reduce((acc, keyValueOption) => ({ ...acc, ...keyValueOption }), {});
367
+ }
368
+ function createWatchHooks(command) {
369
+ const watchHooks = extractWatchHooks(command);
370
+ return function (hook) {
371
+ if (watchHooks[hook]) {
372
+ const cmd = watchHooks[hook];
373
+ if (!command.silent) {
374
+ loadConfigFile.stderr(loadConfigFile.cyan(`watch.${hook} ${loadConfigFile.bold(`$ ${cmd}`)}`));
375
+ }
376
+ try {
377
+ // !! important - use stderr for all writes from execSync
378
+ const stdio = [process.stdin, process.stderr, process.stderr];
379
+ child_process.execSync(cmd, { stdio: command.silent ? 'ignore' : stdio });
380
+ }
381
+ catch (e) {
382
+ loadConfigFile.stderr(e.message);
383
+ }
384
+ }
385
+ };
386
+ }
387
+
360
388
  async function watch(command) {
361
389
  process$2.env.ROLLUP_WATCH = 'true';
362
390
  const isTTY = process$2.stderr.isTTY;
@@ -365,6 +393,7 @@ async function watch(command) {
365
393
  let configWatcher;
366
394
  let resetScreen;
367
395
  const configFile = command.config ? await cli.getConfigPath(command.config) : null;
396
+ const runWatchHook = createWatchHooks(command);
368
397
  signalExit.exports(close);
369
398
  process$2.on('uncaughtException', close);
370
399
  if (!process$2.stdin.isTTY) {
@@ -421,6 +450,7 @@ async function watch(command) {
421
450
  case 'ERROR':
422
451
  warnings.flush();
423
452
  loadConfigFile.handleError(event.error, true);
453
+ runWatchHook('onError');
424
454
  break;
425
455
  case 'START':
426
456
  if (!silent) {
@@ -429,6 +459,7 @@ async function watch(command) {
429
459
  }
430
460
  resetScreen(loadConfigFile.underline(`rollup v${rollup.version}`));
431
461
  }
462
+ runWatchHook('onStart');
432
463
  break;
433
464
  case 'BUNDLE_START':
434
465
  if (!silent) {
@@ -440,16 +471,19 @@ async function watch(command) {
440
471
  }
441
472
  loadConfigFile.stderr(loadConfigFile.cyan(`bundles ${loadConfigFile.bold(input)} → ${loadConfigFile.bold(event.output.map(rollup.relativeId).join(', '))}...`));
442
473
  }
474
+ runWatchHook('onBundleStart');
443
475
  break;
444
476
  case 'BUNDLE_END':
445
477
  warnings.flush();
446
478
  if (!silent)
447
479
  loadConfigFile.stderr(loadConfigFile.green(`created ${loadConfigFile.bold(event.output.map(rollup.relativeId).join(', '))} in ${loadConfigFile.bold(cli.ms(event.duration))}`));
480
+ runWatchHook('onBundleEnd');
448
481
  if (event.result && event.result.getTimings) {
449
482
  cli.printTimings(event.result.getTimings());
450
483
  }
451
484
  break;
452
485
  case 'END':
486
+ runWatchHook('onEnd');
453
487
  if (!silent && isTTY) {
454
488
  loadConfigFile.stderr(`\n[${dateTime()}] waiting for changes...`);
455
489
  }
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v2.71.1
4
- Sat, 30 Apr 2022 13:35:44 GMT - commit f44a3a38b357c2ba80a99aca36cfd30dcfb84476
3
+ Rollup.js v2.73.0
4
+ Fri, 13 May 2022 15:50:44 GMT - commit 931a19940f58c745e9da9eae5585b551f356b2ed
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rollup",
3
- "version": "2.71.1",
3
+ "version": "2.73.0",
4
4
  "description": "Next-generation ES module bundler",
5
5
  "main": "dist/rollup.js",
6
6
  "module": "dist/es/rollup.js",