rollup 2.69.2 → 2.70.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.
package/dist/es/rollup.js CHANGED
@@ -1,8 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v2.69.2
4
- Sun, 06 Mar 2022 06:43:03 GMT - commit 68817534499a6a1392c465d7fe92a1ef6804ad45
5
-
3
+ Rollup.js v2.70.0
4
+ Mon, 07 Mar 2022 06:21:56 GMT - commit 6d8924c8acd7fd124da5fa8026537e1c629f1515
6
5
 
7
6
  https://github.com/rollup/rollup
8
7
 
@@ -1,8 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v2.69.2
4
- Sun, 06 Mar 2022 06:43:03 GMT - commit 68817534499a6a1392c465d7fe92a1ef6804ad45
5
-
3
+ Rollup.js v2.70.0
4
+ Mon, 07 Mar 2022 06:21:56 GMT - commit 6d8924c8acd7fd124da5fa8026537e1c629f1515
6
5
 
7
6
  https://github.com/rollup/rollup
8
7
 
@@ -15,7 +14,7 @@ import { createHash as createHash$1 } from 'crypto';
15
14
  import { promises } from 'fs';
16
15
  import { EventEmitter } from 'events';
17
16
 
18
- var version$1 = "2.69.2";
17
+ var version$1 = "2.70.0";
19
18
 
20
19
  var charToInteger = {};
21
20
  var chars$1 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
@@ -22658,12 +22657,6 @@ class PluginDriver {
22658
22657
  }
22659
22658
  return promise;
22660
22659
  }
22661
- // chains synchronously, ignores returns
22662
- hookSeqSync(hookName, args, replaceContext) {
22663
- for (const plugin of this.plugins) {
22664
- this.runHookSync(hookName, args, plugin, replaceContext);
22665
- }
22666
- }
22667
22660
  runHook(hookName, args, plugin, permitValues, hookContext) {
22668
22661
  const hook = plugin[hookName];
22669
22662
  if (!hook)
@@ -22796,14 +22789,10 @@ class Graph {
22796
22789
  }
22797
22790
  if (watcher) {
22798
22791
  this.watchMode = true;
22799
- const handleChange = (...args) => this.pluginDriver.hookSeqSync('watchChange', args);
22800
- const handleClose = () => this.pluginDriver.hookSeqSync('closeWatcher', []);
22801
- watcher.on('change', handleChange);
22802
- watcher.on('close', handleClose);
22803
- watcher.once('restart', () => {
22804
- watcher.removeListener('change', handleChange);
22805
- watcher.removeListener('close', handleClose);
22806
- });
22792
+ const handleChange = (...args) => this.pluginDriver.hookParallel('watchChange', args);
22793
+ const handleClose = () => this.pluginDriver.hookParallel('closeWatcher', []);
22794
+ watcher.onCurrentAwaited('change', handleChange);
22795
+ watcher.onCurrentAwaited('close', handleClose);
22807
22796
  }
22808
22797
  this.pluginDriver = new PluginDriver(this, options, options.plugins, this.pluginCache);
22809
22798
  this.acornParser = Parser.extend(...options.acornInjectPlugins);
@@ -23699,6 +23688,33 @@ function defineConfig(options) {
23699
23688
  return options;
23700
23689
  }
23701
23690
 
23691
+ class WatchEmitter extends EventEmitter {
23692
+ constructor() {
23693
+ super();
23694
+ this.awaitedHandlers = Object.create(null);
23695
+ // Allows more than 10 bundles to be watched without
23696
+ // showing the `MaxListenersExceededWarning` to the user.
23697
+ this.setMaxListeners(Infinity);
23698
+ }
23699
+ // Will be overwritten by Rollup
23700
+ async close() { }
23701
+ emitAndAwait(event, ...args) {
23702
+ this.emit(event, ...args);
23703
+ return Promise.all(this.getHandlers(event).map(handler => handler(...args)));
23704
+ }
23705
+ onCurrentAwaited(event, listener) {
23706
+ this.getHandlers(event).push(listener);
23707
+ return this;
23708
+ }
23709
+ removeAwaited() {
23710
+ this.awaitedHandlers = {};
23711
+ return this;
23712
+ }
23713
+ getHandlers(event) {
23714
+ return this.awaitedHandlers[event] || (this.awaitedHandlers[event] = []);
23715
+ }
23716
+ }
23717
+
23702
23718
  let fsEvents;
23703
23719
  let fsEventsImportError;
23704
23720
  async function loadFsEvents() {
@@ -23722,15 +23738,6 @@ const fseventsImporter = /*#__PURE__*/Object.defineProperty({
23722
23738
  getFsEvents
23723
23739
  }, Symbol.toStringTag, { value: 'Module' });
23724
23740
 
23725
- class WatchEmitter extends EventEmitter {
23726
- constructor() {
23727
- super();
23728
- // Allows more than 10 bundles to be watched without
23729
- // showing the `MaxListenersExceededWarning` to the user.
23730
- this.setMaxListeners(Infinity);
23731
- }
23732
- close() { }
23733
- }
23734
23741
  function watch(configs) {
23735
23742
  const emitter = new WatchEmitter();
23736
23743
  const configArray = ensureArray(configs);
@@ -1,8 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v2.69.2
4
- Sun, 06 Mar 2022 06:43:03 GMT - commit 68817534499a6a1392c465d7fe92a1ef6804ad45
5
-
3
+ Rollup.js v2.70.0
4
+ Mon, 07 Mar 2022 06:21:56 GMT - commit 6d8924c8acd7fd124da5fa8026537e1c629f1515
6
5
 
7
6
  https://github.com/rollup/rollup
8
7
 
@@ -4807,13 +4806,13 @@ class Watcher {
4807
4806
  : buildDelay, this.buildDelay);
4808
4807
  process$1.nextTick(() => this.run());
4809
4808
  }
4810
- close() {
4809
+ async close() {
4811
4810
  if (this.buildTimeout)
4812
4811
  clearTimeout(this.buildTimeout);
4813
4812
  for (const task of this.tasks) {
4814
4813
  task.close();
4815
4814
  }
4816
- this.emitter.emit('close');
4815
+ await this.emitter.emitAndAwait('close');
4817
4816
  this.emitter.removeAllListeners();
4818
4817
  }
4819
4818
  invalidate(file) {
@@ -4837,14 +4836,26 @@ class Watcher {
4837
4836
  }
4838
4837
  if (this.buildTimeout)
4839
4838
  clearTimeout(this.buildTimeout);
4840
- this.buildTimeout = setTimeout(() => {
4839
+ this.buildTimeout = setTimeout(async () => {
4841
4840
  this.buildTimeout = null;
4842
- for (const [id, event] of this.invalidatedIds) {
4843
- this.emitter.emit('change', id, { event });
4841
+ try {
4842
+ await Promise.all([...this.invalidatedIds].map(([id, event]) => this.emitter.emitAndAwait('change', id, { event })));
4843
+ this.invalidatedIds.clear();
4844
+ this.emitter.emit('restart');
4845
+ this.emitter.removeAwaited();
4846
+ this.run();
4847
+ }
4848
+ catch (error) {
4849
+ this.invalidatedIds.clear();
4850
+ this.emitter.emit('event', {
4851
+ code: 'ERROR',
4852
+ error,
4853
+ result: null
4854
+ });
4855
+ this.emitter.emit('event', {
4856
+ code: 'END'
4857
+ });
4844
4858
  }
4845
- this.invalidatedIds.clear();
4846
- this.emitter.emit('restart');
4847
- this.run();
4848
4859
  }, this.buildDelay);
4849
4860
  }
4850
4861
  async run() {
@@ -1,8 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v2.69.2
4
- Sun, 06 Mar 2022 06:43:03 GMT - commit 68817534499a6a1392c465d7fe92a1ef6804ad45
5
-
3
+ Rollup.js v2.70.0
4
+ Mon, 07 Mar 2022 06:21:56 GMT - commit 6d8924c8acd7fd124da5fa8026537e1c629f1515
6
5
 
7
6
  https://github.com/rollup/rollup
8
7