rollup 2.58.3 → 2.60.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/rollup.d.ts CHANGED
@@ -198,6 +198,7 @@ export interface PluginContext extends MinimalPluginContext {
198
198
  getWatchFiles: () => string[];
199
199
  /** @deprecated Use `this.resolve` instead */
200
200
  isExternal: IsExternal;
201
+ load: (options: { id: string } & Partial<PartialNull<ModuleOptions>>) => Promise<ModuleInfo>;
201
202
  /** @deprecated Use `this.getModuleIds` instead */
202
203
  moduleIds: IterableIterator<string>;
203
204
  parse: (input: string, options?: any) => AcornNode;
package/dist/rollup.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v2.58.3
4
- Mon, 25 Oct 2021 13:49:07 GMT - commit 0b8d4c668683c7702f20fcf480db077dbe2be774
3
+ Rollup.js v2.60.0
4
+ Fri, 12 Nov 2021 05:12:41 GMT - commit 8d98341bf746d4baa57bbd730b1fa6449555cfca
5
5
 
6
6
 
7
7
  https://github.com/rollup/rollup
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v2.58.3
4
- Mon, 25 Oct 2021 13:49:07 GMT - commit 0b8d4c668683c7702f20fcf480db077dbe2be774
3
+ Rollup.js v2.60.0
4
+ Fri, 12 Nov 2021 05:12:41 GMT - commit 8d98341bf746d4baa57bbd730b1fa6449555cfca
5
5
 
6
6
 
7
7
  https://github.com/rollup/rollup
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v2.58.3
4
- Mon, 25 Oct 2021 13:49:07 GMT - commit 0b8d4c668683c7702f20fcf480db077dbe2be774
3
+ Rollup.js v2.60.0
4
+ Fri, 12 Nov 2021 05:12:41 GMT - commit 8d98341bf746d4baa57bbd730b1fa6449555cfca
5
5
 
6
6
 
7
7
  https://github.com/rollup/rollup
@@ -385,33 +385,35 @@ function waitForInputPlugin() {
385
385
  };
386
386
  }
387
387
 
388
- function addCommandPluginsToInputOptions(inputOptions, command) {
388
+ async function addCommandPluginsToInputOptions(inputOptions, command) {
389
389
  if (command.stdin !== false) {
390
390
  inputOptions.plugins.push(stdinPlugin(command.stdin));
391
391
  }
392
392
  if (command.waitForBundleInput === true) {
393
393
  inputOptions.plugins.push(waitForInputPlugin());
394
394
  }
395
- addPluginsFromCommandOption(command.plugin, inputOptions);
395
+ await addPluginsFromCommandOption(command.plugin, inputOptions);
396
396
  }
397
- function addPluginsFromCommandOption(commandPlugin, inputOptions) {
397
+ async function addPluginsFromCommandOption(commandPlugin, inputOptions) {
398
398
  if (commandPlugin) {
399
399
  const plugins = Array.isArray(commandPlugin) ? commandPlugin : [commandPlugin];
400
400
  for (const plugin of plugins) {
401
401
  if (/[={}]/.test(plugin)) {
402
402
  // -p plugin=value
403
403
  // -p "{transform(c,i){...}}"
404
- loadAndRegisterPlugin(inputOptions, plugin);
404
+ await loadAndRegisterPlugin(inputOptions, plugin);
405
405
  }
406
406
  else {
407
407
  // split out plugins joined by commas
408
408
  // -p node-resolve,commonjs,buble
409
- plugin.split(',').forEach((plugin) => loadAndRegisterPlugin(inputOptions, plugin));
409
+ for (const p of plugin.split(',')) {
410
+ await loadAndRegisterPlugin(inputOptions, p);
411
+ }
410
412
  }
411
413
  }
412
414
  }
413
415
  }
414
- function loadAndRegisterPlugin(inputOptions, pluginText) {
416
+ async function loadAndRegisterPlugin(inputOptions, pluginText) {
415
417
  let plugin = null;
416
418
  let pluginArg = undefined;
417
419
  if (pluginText[0] === '{') {
@@ -434,7 +436,7 @@ function loadAndRegisterPlugin(inputOptions, pluginText) {
434
436
  // Prefix order is significant - left has higher precedence.
435
437
  for (const prefix of ['@rollup/plugin-', 'rollup-plugin-']) {
436
438
  try {
437
- plugin = require(prefix + pluginText);
439
+ plugin = await requireOrImport(prefix + pluginText);
438
440
  break;
439
441
  }
440
442
  catch (_a) {
@@ -446,7 +448,7 @@ function loadAndRegisterPlugin(inputOptions, pluginText) {
446
448
  try {
447
449
  if (pluginText[0] == '.')
448
450
  pluginText = path__namespace.resolve(pluginText);
449
- plugin = require(pluginText);
451
+ plugin = await requireOrImport(pluginText);
450
452
  }
451
453
  catch (err) {
452
454
  throw new Error(`Cannot load plugin "${pluginText}": ${err.message}.`);
@@ -473,6 +475,14 @@ function getCamelizedPluginBaseName(pluginText) {
473
475
  .map((part, index) => (index === 0 || !part ? part : part[0].toUpperCase() + part.slice(1)))
474
476
  .join('');
475
477
  }
478
+ async function requireOrImport(pluginPath) {
479
+ try {
480
+ return require(pluginPath);
481
+ }
482
+ catch (_a) {
483
+ return import(pluginPath);
484
+ }
485
+ }
476
486
 
477
487
  function supportsNativeESM() {
478
488
  return Number(/^v(\d+)/.exec(process.version)[1]) >= 13;
@@ -481,11 +491,12 @@ async function loadAndParseConfigFile(fileName, commandOptions = {}) {
481
491
  const configs = await loadConfigFile(fileName, commandOptions);
482
492
  const warnings = batchWarnings();
483
493
  try {
484
- const normalizedConfigs = configs.map(config => {
494
+ const normalizedConfigs = [];
495
+ for (const config of configs) {
485
496
  const options = mergeOptions.mergeOptions(config, commandOptions, warnings.add);
486
- addCommandPluginsToInputOptions(options, commandOptions);
487
- return options;
488
- });
497
+ await addCommandPluginsToInputOptions(options, commandOptions);
498
+ normalizedConfigs.push(options);
499
+ }
489
500
  return { options: normalizedConfigs, warnings };
490
501
  }
491
502
  catch (err) {
@@ -515,7 +526,7 @@ async function getDefaultFromTranspiledConfigFile(fileName, commandOptions) {
515
526
  plugins: [],
516
527
  treeshake: false
517
528
  };
518
- addPluginsFromCommandOption(commandOptions.configPlugin, inputOptions);
529
+ await addPluginsFromCommandOption(commandOptions.configPlugin, inputOptions);
519
530
  const bundle = await rollup.rollup(inputOptions);
520
531
  if (!commandOptions.silent && warnings.count > 0) {
521
532
  stderr(bold(`loaded ${rollup.relativeId(fileName)} with warnings`));
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v2.58.3
4
- Mon, 25 Oct 2021 13:49:07 GMT - commit 0b8d4c668683c7702f20fcf480db077dbe2be774
3
+ Rollup.js v2.60.0
4
+ Fri, 12 Nov 2021 05:12:41 GMT - commit 8d98341bf746d4baa57bbd730b1fa6449555cfca
5
5
 
6
6
 
7
7
  https://github.com/rollup/rollup