rollup 3.0.0-1 → 3.0.0-4

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 v3.0.0-1
4
- Fri, 08 Jul 2022 11:35:32 GMT - commit 48ce34db70ebc2b4c1be38e6b8b02881be90b9f1
3
+ Rollup.js v3.0.0-3
4
+ Mon, 15 Aug 2022 04:43:13 GMT - commit 84a4a595851ef71494b6f2ab558968bfbc148bdb
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -9,9 +9,12 @@
9
9
  */
10
10
  'use strict';
11
11
 
12
+ const node_path = require('node:path');
13
+ const node_url = require('node:url');
12
14
  const require$$0 = require('path');
13
- const process$1 = require('process');
14
- const url = require('url');
15
+ const require$$0$1 = require('fs');
16
+ const require$$2 = require('util');
17
+ const process$1 = require('node:process');
15
18
  const tty = require('tty');
16
19
  const rollup = require('./rollup.js');
17
20
  const mergeOptions = require('./mergeOptions.js');
@@ -145,10 +148,11 @@ const { bold, cyan, dim, gray, green, red, underline, yellow } = createColors({
145
148
  // log to stderr to keep `rollup main.js > bundle.js` from breaking
146
149
  const stderr = (...args) => process$1.stderr.write(`${args.join('')}\n`);
147
150
  function handleError(err, recover = false) {
148
- let description = err.message || err;
149
- if (err.name)
150
- description = `${err.name}: ${description}`;
151
- const message = (err.plugin ? `(plugin ${err.plugin}) ${description}` : description) || err;
151
+ var _a;
152
+ const name = err.name || ((_a = err.cause) === null || _a === void 0 ? void 0 : _a.name);
153
+ const nameSection = name ? `${name}: ` : '';
154
+ const pluginSection = err.plugin ? `(plugin ${err.plugin}) ` : '';
155
+ const message = `${pluginSection}${nameSection}${err.message}`;
152
156
  stderr(bold(red(`[!] ${bold(message.toString())}`)));
153
157
  if (err.url) {
154
158
  stderr(cyan(err.url));
@@ -170,12 +174,129 @@ function handleError(err, recover = false) {
170
174
  process$1.exit(1);
171
175
  }
172
176
 
177
+ var getPackageType$2 = {exports: {}};
178
+
179
+ const path$2 = require$$0;
180
+
181
+ function isNodeModules$2(directory) {
182
+ let basename = path$2.basename(directory);
183
+ /* istanbul ignore next: platform specific branch */
184
+ if (path$2.sep === '\\') {
185
+ basename = basename.toLowerCase();
186
+ }
187
+
188
+ return basename === 'node_modules';
189
+ }
190
+
191
+ var isNodeModules_1 = isNodeModules$2;
192
+
193
+ var cache = new Map();
194
+
195
+ const path$1 = require$$0;
196
+ const {promisify} = require$$2;
197
+ const readFile = promisify(require$$0$1.readFile);
198
+
199
+ const isNodeModules$1 = isNodeModules_1;
200
+ const resultsCache$1 = cache;
201
+
202
+ const promiseCache = new Map();
203
+
204
+ async function getDirectoryTypeActual$1(directory) {
205
+ if (isNodeModules$1(directory)) {
206
+ return 'commonjs';
207
+ }
208
+
209
+ try {
210
+ return JSON.parse(await readFile(path$1.resolve(directory, 'package.json'))).type || 'commonjs';
211
+ } catch (_) {
212
+ }
213
+
214
+ const parent = path$1.dirname(directory);
215
+ if (parent === directory) {
216
+ return 'commonjs';
217
+ }
218
+
219
+ return getDirectoryType$1(parent);
220
+ }
221
+
222
+ async function getDirectoryType$1(directory) {
223
+ if (resultsCache$1.has(directory)) {
224
+ return resultsCache$1.get(directory);
225
+ }
226
+
227
+ if (promiseCache.has(directory)) {
228
+ return promiseCache.get(directory);
229
+ }
230
+
231
+ const promise = getDirectoryTypeActual$1(directory);
232
+ promiseCache.set(directory, promise);
233
+ const result = await promise;
234
+ resultsCache$1.set(directory, result);
235
+ promiseCache.delete(directory);
236
+
237
+ return result;
238
+ }
239
+
240
+ function getPackageType$1(filename) {
241
+ return getDirectoryType$1(path$1.resolve(path$1.dirname(filename)));
242
+ }
243
+
244
+ var async = getPackageType$1;
245
+
246
+ const path = require$$0;
247
+ const {readFileSync} = require$$0$1;
248
+
249
+ const isNodeModules = isNodeModules_1;
250
+ const resultsCache = cache;
251
+
252
+ function getDirectoryTypeActual(directory) {
253
+ if (isNodeModules(directory)) {
254
+ return 'commonjs';
255
+ }
256
+
257
+ try {
258
+ return JSON.parse(readFileSync(path.resolve(directory, 'package.json'))).type || 'commonjs';
259
+ } catch (_) {
260
+ }
261
+
262
+ const parent = path.dirname(directory);
263
+ if (parent === directory) {
264
+ return 'commonjs';
265
+ }
266
+
267
+ return getDirectoryType(parent);
268
+ }
269
+
270
+ function getDirectoryType(directory) {
271
+ if (resultsCache.has(directory)) {
272
+ return resultsCache.get(directory);
273
+ }
274
+
275
+ const result = getDirectoryTypeActual(directory);
276
+ resultsCache.set(directory, result);
277
+
278
+ return result;
279
+ }
280
+
281
+ function getPackageTypeSync$1(filename) {
282
+ return getDirectoryType(path.resolve(path.dirname(filename)));
283
+ }
284
+
285
+ var sync = getPackageTypeSync$1;
286
+
287
+ const getPackageType = async;
288
+ const getPackageTypeSync = sync;
289
+
290
+ getPackageType$2.exports = filename => getPackageType(filename);
291
+ getPackageType$2.exports.sync = getPackageTypeSync;
292
+
173
293
  function batchWarnings() {
174
294
  let count = 0;
175
295
  const deferredWarnings = new Map();
176
296
  let warningOccurred = false;
177
297
  return {
178
298
  add(warning) {
299
+ var _a;
179
300
  count += 1;
180
301
  warningOccurred = true;
181
302
  if (warning.code in deferredHandlers) {
@@ -188,7 +309,7 @@ function batchWarnings() {
188
309
  title(warning.message);
189
310
  if (warning.url)
190
311
  info(warning.url);
191
- const id = (warning.loc && warning.loc.file) || warning.id;
312
+ const id = ((_a = warning.loc) === null || _a === void 0 ? void 0 : _a.file) || warning.id;
192
313
  if (id) {
193
314
  const loc = warning.loc
194
315
  ? `${rollup.relativeId(id)} (${warning.loc.line}:${warning.loc.column})`
@@ -220,7 +341,7 @@ function batchWarnings() {
220
341
  const immediateHandlers = {
221
342
  MISSING_NODE_BUILTINS(warning) {
222
343
  title(`Missing shims for Node.js built-ins`);
223
- stderr(`Creating a browser bundle that depends on ${rollup.printQuotedStringList(warning.modules)}. You might need to include https://github.com/FredKSchott/rollup-plugin-polyfill-node`);
344
+ stderr(`Creating a browser bundle that depends on ${rollup.printQuotedStringList(warning.ids)}. You might need to include https://github.com/FredKSchott/rollup-plugin-polyfill-node`);
224
345
  },
225
346
  UNKNOWN_OPTION(warning) {
226
347
  title(`You have passed an unrecognized option`);
@@ -232,7 +353,7 @@ const deferredHandlers = {
232
353
  title(`Circular dependenc${warnings.length > 1 ? 'ies' : 'y'}`);
233
354
  const displayed = warnings.length > 5 ? warnings.slice(0, 3) : warnings;
234
355
  for (const warning of displayed) {
235
- stderr(warning.cycle.join(' -> '));
356
+ stderr(warning.ids.map(rollup.relativeId).join(' -> '));
236
357
  }
237
358
  if (warnings.length > displayed.length) {
238
359
  stderr(`...and ${warnings.length - displayed.length} more`);
@@ -240,7 +361,7 @@ const deferredHandlers = {
240
361
  },
241
362
  EMPTY_BUNDLE(warnings) {
242
363
  title(`Generated${warnings.length === 1 ? ' an' : ''} empty ${warnings.length > 1 ? 'chunks' : 'chunk'}`);
243
- stderr(warnings.map(warning => warning.chunkName).join(', '));
364
+ stderr(rollup.printQuotedStringList(warnings.map(warning => warning.names[0])));
244
365
  },
245
366
  EVAL(warnings) {
246
367
  title('Use of eval is strongly discouraged');
@@ -251,16 +372,17 @@ const deferredHandlers = {
251
372
  title('Missing exports');
252
373
  info('https://rollupjs.org/guide/en/#error-name-is-not-exported-by-module');
253
374
  for (const warning of warnings) {
254
- stderr(bold(warning.importer));
255
- stderr(`${warning.missing} is not exported by ${warning.exporter}`);
375
+ stderr(bold(rollup.relativeId(warning.id)));
376
+ stderr(`${warning.binding} is not exported by ${rollup.relativeId(warning.exporter)}`);
256
377
  stderr(gray(warning.frame));
257
378
  }
258
379
  },
259
380
  MISSING_GLOBAL_NAME(warnings) {
260
381
  title(`Missing global variable ${warnings.length > 1 ? 'names' : 'name'}`);
261
- stderr(`Use output.globals to specify browser global variable names corresponding to external modules`);
382
+ info('https://rollupjs.org/guide/en/#outputglobals');
383
+ stderr(`Use "output.globals" to specify browser global variable names corresponding to external modules:`);
262
384
  for (const warning of warnings) {
263
- stderr(`${bold(warning.source)} (guessing '${warning.guess}')`);
385
+ stderr(`${bold(warning.id)} (guessing "${warning.names[0]}")`);
264
386
  }
265
387
  },
266
388
  MIXED_EXPORTS(warnings) {
@@ -275,18 +397,14 @@ const deferredHandlers = {
275
397
  if (displayedWarnings.length < warnings.length) {
276
398
  stderr(`...and ${warnings.length - displayedWarnings.length} other entry modules`);
277
399
  }
278
- stderr(`\nConsumers of your bundle will have to use chunk['default'] to access their default export, which may not be what you want. Use \`output.exports: 'named'\` to disable this warning`);
400
+ stderr(`\nConsumers of your bundle will have to use chunk.default to access their default export, which may not be what you want. Use \`output.exports: "named"\` to disable this warning.`);
279
401
  },
280
402
  NAMESPACE_CONFLICT(warnings) {
281
403
  title(`Conflicting re-exports`);
282
404
  for (const warning of warnings) {
283
- stderr(`"${bold(rollup.relativeId(warning.reexporter))}" re-exports "${warning.name}" from both "${rollup.relativeId(warning.sources[0])}" and "${rollup.relativeId(warning.sources[1])}" (will be ignored)`);
405
+ stderr(`"${bold(rollup.relativeId(warning.reexporter))}" re-exports "${warning.binding}" from both "${rollup.relativeId(warning.ids[0])}" and "${rollup.relativeId(warning.ids[1])}" (will be ignored).`);
284
406
  }
285
407
  },
286
- NON_EXISTENT_EXPORT(warnings) {
287
- title(`Import of non-existent ${warnings.length > 1 ? 'exports' : 'export'}`);
288
- showTruncatedWarnings(warnings);
289
- },
290
408
  PLUGIN_WARNING(warnings) {
291
409
  var _a;
292
410
  const nestedByPlugin = nest(warnings, 'plugin');
@@ -316,10 +434,10 @@ const deferredHandlers = {
316
434
  title(`Broken sourcemap`);
317
435
  info('https://rollupjs.org/guide/en/#warning-sourcemap-is-likely-to-be-incorrect');
318
436
  const plugins = [...new Set(warnings.map(({ plugin }) => plugin).filter(Boolean))];
319
- stderr(`Plugins that transform code (such as ${rollup.printQuotedStringList(plugins)}) should generate accompanying sourcemaps`);
437
+ stderr(`Plugins that transform code (such as ${rollup.printQuotedStringList(plugins)}) should generate accompanying sourcemaps.`);
320
438
  },
321
439
  THIS_IS_UNDEFINED(warnings) {
322
- title('`this` has been rewritten to `undefined`');
440
+ title('"this" has been rewritten to "undefined"');
323
441
  info('https://rollupjs.org/guide/en/#error-this-is-undefined');
324
442
  showTruncatedWarnings(warnings);
325
443
  },
@@ -328,10 +446,10 @@ const deferredHandlers = {
328
446
  info('https://rollupjs.org/guide/en/#warning-treating-module-as-external-dependency');
329
447
  const dependencies = new Map();
330
448
  for (const warning of warnings) {
331
- rollup.getOrCreate(dependencies, warning.source, () => []).push(warning.importer);
449
+ rollup.getOrCreate(dependencies, rollup.relativeId(warning.exporter), () => []).push(rollup.relativeId(warning.id));
332
450
  }
333
451
  for (const [dependency, importers] of dependencies) {
334
- stderr(`${bold(dependency)} (imported by ${importers.join(', ')})`);
452
+ stderr(`${bold(dependency)} (imported by ${rollup.printQuotedStringList(importers)})`);
335
453
  }
336
454
  },
337
455
  UNUSED_EXTERNAL_IMPORT(warnings) {
@@ -339,9 +457,10 @@ const deferredHandlers = {
339
457
  for (const warning of warnings) {
340
458
  stderr(warning.names +
341
459
  ' imported from external module "' +
342
- warning.source +
460
+ warning.exporter +
343
461
  '" but never used in ' +
344
- rollup.printQuotedStringList(warning.sources.map(id => rollup.relativeId(id))));
462
+ rollup.printQuotedStringList(warning.ids.map(rollup.relativeId)) +
463
+ '.');
345
464
  }
346
465
  }
347
466
  };
@@ -503,11 +622,11 @@ async function loadAndRegisterPlugin(inputOptions, pluginText) {
503
622
  if (!plugin) {
504
623
  try {
505
624
  if (pluginText[0] == '.')
506
- pluginText = require$$0.resolve(pluginText);
625
+ pluginText = node_path.resolve(pluginText);
507
626
  // Windows absolute paths must be specified as file:// protocol URL
508
627
  // Note that we do not have coverage for Windows-only code paths
509
628
  else if (pluginText.match(/^[A-Za-z]:\\/)) {
510
- pluginText = url.pathToFileURL(require$$0.resolve(pluginText)).href;
629
+ pluginText = node_url.pathToFileURL(node_path.resolve(pluginText)).href;
511
630
  }
512
631
  plugin = await requireOrImport(pluginText);
513
632
  }
@@ -545,11 +664,8 @@ async function requireOrImport(pluginPath) {
545
664
  }
546
665
  }
547
666
 
548
- function supportsNativeESM() {
549
- return Number(/^v(\d+)/.exec(process$1.version)[1]) >= 13;
550
- }
551
- async function loadAndParseConfigFile(fileName, commandOptions = {}) {
552
- const configs = await loadConfigFile(fileName, commandOptions);
667
+ async function loadConfigFile(fileName, commandOptions = {}) {
668
+ const configs = await loadConfigsFromFile(fileName, commandOptions);
553
669
  const warnings = batchWarnings();
554
670
  try {
555
671
  const normalizedConfigs = [];
@@ -565,14 +681,13 @@ async function loadAndParseConfigFile(fileName, commandOptions = {}) {
565
681
  throw err;
566
682
  }
567
683
  }
568
- async function loadConfigFile(fileName, commandOptions) {
569
- const extension = require$$0.extname(fileName);
684
+ async function loadConfigsFromFile(fileName, commandOptions) {
685
+ const extension = node_path.extname(fileName);
570
686
  const configFileExport = commandOptions.configPlugin ||
571
- !(extension === '.cjs' || (extension === '.mjs' && supportsNativeESM()))
687
+ // We always transpile the .js non-module case because many legacy code bases rely on this
688
+ (extension === '.js' && getPackageType$2.exports.sync(fileName) !== 'module')
572
689
  ? await getDefaultFromTranspiledConfigFile(fileName, commandOptions)
573
- : extension === '.cjs'
574
- ? getDefaultFromCjs(require(fileName))
575
- : (await import(url.pathToFileURL(fileName).href)).default;
690
+ : getDefaultFromCjs((await import(node_url.pathToFileURL(fileName).href)).default);
576
691
  return getConfigList(configFileExport, commandOptions);
577
692
  }
578
693
  function getDefaultFromCjs(namespace) {
@@ -581,7 +696,7 @@ function getDefaultFromCjs(namespace) {
581
696
  async function getDefaultFromTranspiledConfigFile(fileName, commandOptions) {
582
697
  const warnings = batchWarnings();
583
698
  const inputOptions = {
584
- external: (id) => (id[0] !== '.' && !require$$0.isAbsolute(id)) || id.slice(-5, id.length) === '.json',
699
+ external: (id) => (id[0] !== '.' && !node_path.isAbsolute(id)) || id.slice(-5, id.length) === '.json',
585
700
  input: fileName,
586
701
  onwarn: warnings.add,
587
702
  plugins: [],
@@ -601,10 +716,10 @@ async function getDefaultFromTranspiledConfigFile(fileName, commandOptions) {
601
716
  name: 'transpile-import-meta',
602
717
  resolveImportMeta(property, { moduleId }) {
603
718
  if (property === 'url') {
604
- return `'${url.pathToFileURL(moduleId).href}'`;
719
+ return `'${node_url.pathToFileURL(moduleId).href}'`;
605
720
  }
606
721
  if (property == null) {
607
- return `{url:'${url.pathToFileURL(moduleId).href}'}`;
722
+ return `{url:'${node_url.pathToFileURL(moduleId).href}'}`;
608
723
  }
609
724
  }
610
725
  }
@@ -614,7 +729,7 @@ async function getDefaultFromTranspiledConfigFile(fileName, commandOptions) {
614
729
  }
615
730
  function loadConfigFromBundledFile(fileName, bundledCode) {
616
731
  const resolvedFileName = require.resolve(fileName);
617
- const extension = require$$0.extname(resolvedFileName);
732
+ const extension = node_path.extname(resolvedFileName);
618
733
  const defaultLoader = require.extensions[extension];
619
734
  require.extensions[extension] = (module, requiredFileName) => {
620
735
  if (requiredFileName === resolvedFileName) {
@@ -634,11 +749,7 @@ function loadConfigFromBundledFile(fileName, bundledCode) {
634
749
  }
635
750
  catch (err) {
636
751
  if (err.code === 'ERR_REQUIRE_ESM') {
637
- return rollup.error({
638
- code: 'TRANSPILED_ESM_CONFIG',
639
- message: `While loading the Rollup configuration from "${rollup.relativeId(fileName)}", Node tried to require an ES module from a CommonJS file, which is not supported. A common cause is if there is a package.json file with "type": "module" in the same folder. You can try to fix this by changing the extension of your configuration file to ".cjs" or ".mjs" depending on the content, which will prevent Rollup from trying to preprocess the file but rather hand it to Node directly.`,
640
- url: 'https://rollupjs.org/guide/en/#using-untranspiled-config-files'
641
- });
752
+ return rollup.error(rollup.errTranspiledEsmConfig(fileName));
642
753
  }
643
754
  throw err;
644
755
  }
@@ -648,11 +759,7 @@ async function getConfigList(configFileExport, commandOptions) {
648
759
  ? configFileExport(commandOptions)
649
760
  : configFileExport);
650
761
  if (Object.keys(config).length === 0) {
651
- return rollup.error({
652
- code: 'MISSING_CONFIG',
653
- message: 'Config file must export an options object, or an array of options objects',
654
- url: 'https://rollupjs.org/guide/en/#configuration-files'
655
- });
762
+ return rollup.error(rollup.errMissingConfig());
656
763
  }
657
764
  return Array.isArray(config) ? config : [config];
658
765
  }
@@ -663,7 +770,7 @@ exports.bold = bold;
663
770
  exports.cyan = cyan;
664
771
  exports.green = green;
665
772
  exports.handleError = handleError;
666
- exports.loadAndParseConfigFile = loadAndParseConfigFile;
773
+ exports.loadConfigFile = loadConfigFile;
667
774
  exports.stderr = stderr;
668
775
  exports.stdinName = stdinName;
669
776
  exports.underline = underline;
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v3.0.0-1
4
- Fri, 08 Jul 2022 11:35:32 GMT - commit 48ce34db70ebc2b4c1be38e6b8b02881be90b9f1
3
+ Rollup.js v3.0.0-3
4
+ Mon, 15 Aug 2022 04:43:13 GMT - commit 84a4a595851ef71494b6f2ab558968bfbc148bdb
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -73,6 +73,7 @@ function mergeInputOptions(config, overrides, defaultOnWarnHandler) {
73
73
  input: getOption('input') || [],
74
74
  makeAbsoluteExternalsRelative: getOption('makeAbsoluteExternalsRelative'),
75
75
  manualChunks: getOption('manualChunks'),
76
+ maxParallelFileOps: getOption('maxParallelFileOps'),
76
77
  maxParallelFileReads: getOption('maxParallelFileReads'),
77
78
  moduleContext: getOption('moduleContext'),
78
79
  onwarn: getOnWarn(config, defaultOnWarnHandler),