rollup 2.70.0 → 2.70.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/dist/es/rollup.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v2.70.0
4
- Mon, 07 Mar 2022 06:21:56 GMT - commit 6d8924c8acd7fd124da5fa8026537e1c629f1515
3
+ Rollup.js v2.70.1
4
+ Mon, 14 Mar 2022 05:50:08 GMT - commit b8315e03f9790d610a413316fbf6d565f9340cab
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v2.70.0
4
- Mon, 07 Mar 2022 06:21:56 GMT - commit 6d8924c8acd7fd124da5fa8026537e1c629f1515
3
+ Rollup.js v2.70.1
4
+ Mon, 14 Mar 2022 05:50:08 GMT - commit b8315e03f9790d610a413316fbf6d565f9340cab
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -14,7 +14,7 @@ import { createHash as createHash$1 } from 'crypto';
14
14
  import { promises } from 'fs';
15
15
  import { EventEmitter } from 'events';
16
16
 
17
- var version$1 = "2.70.0";
17
+ var version$1 = "2.70.1";
18
18
 
19
19
  var charToInteger = {};
20
20
  var chars$1 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
@@ -22484,41 +22484,6 @@ function getPluginContext(plugin, pluginCache, graph, options, fileEmitter, exis
22484
22484
  return context;
22485
22485
  }
22486
22486
 
22487
- const unfulfilledActions = new Set();
22488
- function addUnresolvedAction(actionTuple) {
22489
- unfulfilledActions.add(actionTuple);
22490
- }
22491
- function resolveAction(actionTuple) {
22492
- unfulfilledActions.delete(actionTuple);
22493
- }
22494
- function formatAction([pluginName, hookName, args]) {
22495
- const action = `(${pluginName}) ${hookName}`;
22496
- const s = JSON.stringify;
22497
- switch (hookName) {
22498
- case 'resolveId':
22499
- return `${action} ${s(args[0])} ${s(args[1])}`;
22500
- case 'load':
22501
- return `${action} ${s(args[0])}`;
22502
- case 'transform':
22503
- return `${action} ${s(args[1])}`;
22504
- case 'shouldTransformCachedModule':
22505
- return `${action} ${s(args[0].id)}`;
22506
- case 'moduleParsed':
22507
- return `${action} ${s(args[0].id)}`;
22508
- }
22509
- return action;
22510
- }
22511
- process$1.on('exit', () => {
22512
- if (unfulfilledActions.size) {
22513
- let err = '[!] Error: unfinished hook action(s) on exit:\n';
22514
- for (const action of unfulfilledActions) {
22515
- err += formatAction(action) + '\n';
22516
- }
22517
- console.error('%s', err);
22518
- process$1.exitCode = 1;
22519
- }
22520
- });
22521
-
22522
22487
  const inputHookNames = {
22523
22488
  buildEnd: 1,
22524
22489
  buildStart: 1,
@@ -22544,6 +22509,7 @@ class PluginDriver {
22544
22509
  constructor(graph, options, userPlugins, pluginCache, basePluginDriver) {
22545
22510
  this.graph = graph;
22546
22511
  this.options = options;
22512
+ this.unfulfilledActions = new Set();
22547
22513
  warnDeprecatedHooks(userPlugins, options);
22548
22514
  this.pluginCache = pluginCache;
22549
22515
  this.fileEmitter = new FileEmitter(graph, options, basePluginDriver && basePluginDriver.fileEmitter);
@@ -22570,6 +22536,9 @@ class PluginDriver {
22570
22536
  createOutputPluginDriver(plugins) {
22571
22537
  return new PluginDriver(this.graph, this.options, plugins, this.pluginCache, this);
22572
22538
  }
22539
+ getUnfulfilledHookActions() {
22540
+ return this.unfulfilledActions;
22541
+ }
22573
22542
  // chains, first non-null result stops and returns
22574
22543
  hookFirst(hookName, args, replaceContext, skipped) {
22575
22544
  let promise = Promise.resolve(undefined);
@@ -22685,22 +22654,21 @@ class PluginDriver {
22685
22654
  // exit with a successful 0 return code but without producing any
22686
22655
  // output, errors or warnings.
22687
22656
  action = [plugin.name, hookName, args];
22688
- addUnresolvedAction(action);
22657
+ this.unfulfilledActions.add(action);
22689
22658
  // Although it would be more elegant to just return hookResult here
22690
22659
  // and put the .then() handler just above the .catch() handler below,
22691
22660
  // doing so would subtly change the defacto async event dispatch order
22692
22661
  // which at least one test and some plugins in the wild may depend on.
22693
- const promise = Promise.resolve(hookResult);
22694
- return promise.then(() => {
22662
+ return Promise.resolve(hookResult).then(result => {
22695
22663
  // action was fulfilled
22696
- resolveAction(action);
22697
- return promise;
22664
+ this.unfulfilledActions.delete(action);
22665
+ return result;
22698
22666
  });
22699
22667
  })
22700
22668
  .catch(err => {
22701
22669
  if (action !== null) {
22702
22670
  // action considered to be fulfilled since error being handled
22703
- resolveAction(action);
22671
+ this.unfulfilledActions.delete(action);
22704
22672
  }
22705
22673
  return throwPluginError(err, plugin.name, { hook: hookName });
22706
22674
  });
@@ -22957,6 +22925,38 @@ function ensureArray(items) {
22957
22925
  return [];
22958
22926
  }
22959
22927
 
22928
+ function formatAction([pluginName, hookName, args]) {
22929
+ const action = `(${pluginName}) ${hookName}`;
22930
+ const s = JSON.stringify;
22931
+ switch (hookName) {
22932
+ case 'resolveId':
22933
+ return `${action} ${s(args[0])} ${s(args[1])}`;
22934
+ case 'load':
22935
+ return `${action} ${s(args[0])}`;
22936
+ case 'transform':
22937
+ return `${action} ${s(args[1])}`;
22938
+ case 'shouldTransformCachedModule':
22939
+ return `${action} ${s(args[0].id)}`;
22940
+ case 'moduleParsed':
22941
+ return `${action} ${s(args[0].id)}`;
22942
+ }
22943
+ return action;
22944
+ }
22945
+ async function catchUnfinishedHookActions(pluginDriver, callback) {
22946
+ let handleEmptyEventLoop;
22947
+ const emptyEventLoopPromise = new Promise((_, reject) => {
22948
+ handleEmptyEventLoop = () => {
22949
+ const unfulfilledActions = pluginDriver.getUnfulfilledHookActions();
22950
+ reject(new Error(`Unexpected early exit. This happens when Promises returned by plugins cannot resolve. Unfinished hook action(s) on exit:\n` +
22951
+ [...unfulfilledActions].map(formatAction).join('\n')));
22952
+ };
22953
+ process$1.once('beforeExit', handleEmptyEventLoop);
22954
+ });
22955
+ const result = await Promise.race([callback(), emptyEventLoopPromise]);
22956
+ process$1.off('beforeExit', handleEmptyEventLoop);
22957
+ return result;
22958
+ }
22959
+
22960
22960
  const defaultOnWarn = warning => console.warn(warning.message || warning);
22961
22961
  function warnUnknownOptions(passedOptions, validOptions, optionType, warn, ignoredKeys = /$./) {
22962
22962
  const validOptionSet = new Set(validOptions);
@@ -23524,20 +23524,22 @@ async function rollupInternal(rawInputOptions, watcher) {
23524
23524
  delete inputOptions.cache;
23525
23525
  delete rawInputOptions.cache;
23526
23526
  timeStart('BUILD', 1);
23527
- try {
23528
- await graph.pluginDriver.hookParallel('buildStart', [inputOptions]);
23529
- await graph.build();
23530
- }
23531
- catch (err) {
23532
- const watchFiles = Object.keys(graph.watchFiles);
23533
- if (watchFiles.length > 0) {
23534
- err.watchFiles = watchFiles;
23527
+ await catchUnfinishedHookActions(graph.pluginDriver, async () => {
23528
+ try {
23529
+ await graph.pluginDriver.hookParallel('buildStart', [inputOptions]);
23530
+ await graph.build();
23535
23531
  }
23536
- await graph.pluginDriver.hookParallel('buildEnd', [err]);
23537
- await graph.pluginDriver.hookParallel('closeBundle', []);
23538
- throw err;
23539
- }
23540
- await graph.pluginDriver.hookParallel('buildEnd', []);
23532
+ catch (err) {
23533
+ const watchFiles = Object.keys(graph.watchFiles);
23534
+ if (watchFiles.length > 0) {
23535
+ err.watchFiles = watchFiles;
23536
+ }
23537
+ await graph.pluginDriver.hookParallel('buildEnd', [err]);
23538
+ await graph.pluginDriver.hookParallel('closeBundle', []);
23539
+ throw err;
23540
+ }
23541
+ await graph.pluginDriver.hookParallel('buildEnd', []);
23542
+ });
23541
23543
  timeEnd('BUILD', 1);
23542
23544
  const result = {
23543
23545
  cache: useCache ? graph.getCache() : undefined,
@@ -23588,21 +23590,23 @@ function normalizePlugins(plugins, anonymousPrefix) {
23588
23590
  }
23589
23591
  });
23590
23592
  }
23591
- async function handleGenerateWrite(isWrite, inputOptions, unsetInputOptions, rawOutputOptions, graph) {
23593
+ function handleGenerateWrite(isWrite, inputOptions, unsetInputOptions, rawOutputOptions, graph) {
23592
23594
  const { options: outputOptions, outputPluginDriver, unsetOptions } = getOutputOptionsAndPluginDriver(rawOutputOptions, graph.pluginDriver, inputOptions, unsetInputOptions);
23593
- const bundle = new Bundle(outputOptions, unsetOptions, inputOptions, outputPluginDriver, graph);
23594
- const generated = await bundle.generate(isWrite);
23595
- if (isWrite) {
23596
- if (!outputOptions.dir && !outputOptions.file) {
23597
- return error({
23598
- code: 'MISSING_OPTION',
23599
- message: 'You must specify "output.file" or "output.dir" for the build.'
23600
- });
23595
+ return catchUnfinishedHookActions(outputPluginDriver, async () => {
23596
+ const bundle = new Bundle(outputOptions, unsetOptions, inputOptions, outputPluginDriver, graph);
23597
+ const generated = await bundle.generate(isWrite);
23598
+ if (isWrite) {
23599
+ if (!outputOptions.dir && !outputOptions.file) {
23600
+ return error({
23601
+ code: 'MISSING_OPTION',
23602
+ message: 'You must specify "output.file" or "output.dir" for the build.'
23603
+ });
23604
+ }
23605
+ await Promise.all(Object.values(generated).map(chunk => writeOutputFile(chunk, outputOptions)));
23606
+ await outputPluginDriver.hookParallel('writeBundle', [outputOptions, generated]);
23601
23607
  }
23602
- await Promise.all(Object.values(generated).map(chunk => writeOutputFile(chunk, outputOptions)));
23603
- await outputPluginDriver.hookParallel('writeBundle', [outputOptions, generated]);
23604
- }
23605
- return createOutput(generated);
23608
+ return createOutput(generated);
23609
+ });
23606
23610
  }
23607
23611
  function getOutputOptionsAndPluginDriver(rawOutputOptions, inputPluginDriver, inputOptions, unsetInputOptions) {
23608
23612
  if (!rawOutputOptions) {
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v2.70.0
4
- Mon, 07 Mar 2022 06:21:56 GMT - commit 6d8924c8acd7fd124da5fa8026537e1c629f1515
3
+ Rollup.js v2.70.1
4
+ Mon, 14 Mar 2022 05:50:08 GMT - commit b8315e03f9790d610a413316fbf6d565f9340cab
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v2.70.0
4
- Mon, 07 Mar 2022 06:21:56 GMT - commit 6d8924c8acd7fd124da5fa8026537e1c629f1515
3
+ Rollup.js v2.70.1
4
+ Mon, 14 Mar 2022 05:50:08 GMT - commit b8315e03f9790d610a413316fbf6d565f9340cab
5
5
 
6
6
  https://github.com/rollup/rollup
7
7