rollup 4.9.6 → 4.10.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/bin/rollup CHANGED
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
  /*
3
3
  @license
4
- Rollup.js v4.9.6
5
- Sun, 21 Jan 2024 05:51:51 GMT - commit ecb6b0a430098052781aa6ee04ec92ee70960321
4
+ Rollup.js v4.10.0
5
+ Sat, 10 Feb 2024 05:58:12 GMT - commit 762420860765e8e46e24d48b38f5b98ca31735fa
6
6
 
7
7
  https://github.com/rollup/rollup
8
8
 
@@ -28,7 +28,7 @@ require('../native.js');
28
28
  require('node:url');
29
29
  require('../getLogFilter.js');
30
30
 
31
- const help = "rollup version __VERSION__\n=====================================\n\nUsage: rollup [options] <entry file>\n\nBasic options:\n\n-c, --config <filename> Use this config file (if argument is used but value\n is unspecified, defaults to rollup.config.js)\n-d, --dir <dirname> Directory for chunks (if absent, prints to stdout)\n-e, --external <ids> Comma-separate list of module IDs to exclude\n-f, --format <format> Type of output (amd, cjs, es, iife, umd, system)\n-g, --globals <pairs> Comma-separate list of `moduleID:Global` pairs\n-h, --help Show this help message\n-i, --input <filename> Input (alternative to <entry file>)\n-m, --sourcemap Generate sourcemap (`-m inline` for inline map)\n-n, --name <name> Name for UMD export\n-o, --file <output> Single output file (if absent, prints to stdout)\n-p, --plugin <plugin> Use the plugin specified (may be repeated)\n-v, --version Show version number\n-w, --watch Watch files in bundle and rebuild on changes\n--amd.autoId Generate the AMD ID based off the chunk name\n--amd.basePath <prefix> Path to prepend to auto generated AMD ID\n--amd.define <name> Function to use in place of `define`\n--amd.forceJsExtensionForImports Use `.js` extension in AMD imports\n--amd.id <id> ID for AMD module (default is anonymous)\n--assetFileNames <pattern> Name pattern for emitted assets\n--banner <text> Code to insert at top of bundle (outside wrapper)\n--chunkFileNames <pattern> Name pattern for emitted secondary chunks\n--compact Minify wrapper code\n--context <variable> Specify top-level `this` value\n--no-dynamicImportInCjs Write external dynamic CommonJS imports as require\n--entryFileNames <pattern> Name pattern for emitted entry chunks\n--environment <values> Settings passed to config file (see example)\n--no-esModule Do not add __esModule property\n--exports <mode> Specify export mode (auto, default, named, none)\n--extend Extend global variable defined by --name\n--no-externalImportAttributes Omit import attributes in \"es\" output\n--no-externalLiveBindings Do not generate code to support live bindings\n--failAfterWarnings Exit with an error if the build produced warnings\n--filterLogs <filter> Filter log messages\n--footer <text> Code to insert at end of bundle (outside wrapper)\n--forceExit Force exit the process when done\n--no-freeze Do not freeze namespace objects\n--generatedCode <preset> Which code features to use (es5/es2015)\n--generatedCode.arrowFunctions Use arrow functions in generated code\n--generatedCode.constBindings Use \"const\" in generated code\n--generatedCode.objectShorthand Use shorthand properties in generated code\n--no-generatedCode.reservedNamesAsProps Always quote reserved names as props\n--generatedCode.symbols Use symbols in generated code\n--no-hoistTransitiveImports Do not hoist transitive imports into entry chunks\n--no-indent Don't indent result\n--inlineDynamicImports Create single bundle when using dynamic imports\n--no-interop Do not include interop block\n--intro <text> Code to insert at top of bundle (inside wrapper)\n--logLevel <level> Which kind of logs to display\n--no-makeAbsoluteExternalsRelative Prevent normalization of external imports\n--maxParallelFileOps <value> How many files to read in parallel\n--minifyInternalExports Force or disable minification of internal exports\n--noConflict Generate a noConflict method for UMD globals\n--outro <text> Code to insert at end of bundle (inside wrapper)\n--perf Display performance timings\n--no-preserveEntrySignatures Avoid facade chunks for entry points\n--preserveModules Preserve module structure\n--preserveModulesRoot Put preserved modules under this path at root level\n--preserveSymlinks Do not follow symlinks when resolving files\n--no-sanitizeFileName Do not replace invalid characters in file names\n--shimMissingExports Create shim variables for missing exports\n--silent Don't print warnings\n--sourcemapBaseUrl <url> Emit absolute sourcemap URLs with given base\n--sourcemapExcludeSources Do not include source code in source maps\n--sourcemapFile <file> Specify bundle position for source maps\n--sourcemapFileNames <pattern> Name pattern for emitted sourcemaps\n--stdin=ext Specify file extension used for stdin input\n--no-stdin Do not read \"-\" from stdin\n--no-strict Don't emit `\"use strict\";` in the generated modules\n--strictDeprecations Throw errors for deprecated features\n--no-systemNullSetters Do not replace empty SystemJS setters with `null`\n--no-treeshake Disable tree-shaking optimisations\n--no-treeshake.annotations Ignore pure call annotations\n--treeshake.correctVarValueBeforeDeclaration Deoptimize variables until declared\n--treeshake.manualPureFunctions <names> Manually declare functions as pure\n--no-treeshake.moduleSideEffects Assume modules have no side effects\n--no-treeshake.propertyReadSideEffects Ignore property access side effects\n--no-treeshake.tryCatchDeoptimization Do not turn off try-catch-tree-shaking\n--no-treeshake.unknownGlobalSideEffects Assume unknown globals do not throw\n--validate Validate output\n--waitForBundleInput Wait for bundle input files\n--watch.buildDelay <number> Throttle watch rebuilds\n--no-watch.clearScreen Do not clear the screen when rebuilding\n--watch.exclude <files> Exclude files from being watched\n--watch.include <files> Limit watching to specified files\n--watch.onBundleEnd <cmd> Shell command to run on `\"BUNDLE_END\"` event\n--watch.onBundleStart <cmd> Shell command to run on `\"BUNDLE_START\"` event\n--watch.onEnd <cmd> Shell command to run on `\"END\"` event\n--watch.onError <cmd> Shell command to run on `\"ERROR\"` event\n--watch.onStart <cmd> Shell command to run on `\"START\"` event\n--watch.skipWrite Do not write files to disk when watching\n\nExamples:\n\n# use settings in config file\nrollup -c\n\n# in config file, process.env.INCLUDE_DEPS === 'true'\n# and process.env.BUILD === 'production'\nrollup -c --environment INCLUDE_DEPS,BUILD:production\n\n# create CommonJS bundle.js from src/main.js\nrollup --format=cjs --file=bundle.js -- src/main.js\n\n# create self-executing IIFE using `window.jQuery`\n# and `window._` as external globals\nrollup -f iife --globals jquery:jQuery,lodash:_ \\\n -i src/app.js -o build/app.js -m build/app.js.map\n\nNotes:\n\n* When piping to stdout, only inline sourcemaps are permitted\n\nFor more information visit https://rollupjs.org\n";
31
+ const help = "rollup version __VERSION__\n=====================================\n\nUsage: rollup [options] <entry file>\n\nBasic options:\n\n-c, --config <filename> Use this config file (if argument is used but value\n is unspecified, defaults to rollup.config.js)\n-d, --dir <dirname> Directory for chunks (if absent, prints to stdout)\n-e, --external <ids> Comma-separate list of module IDs to exclude\n-f, --format <format> Type of output (amd, cjs, es, iife, umd, system)\n-g, --globals <pairs> Comma-separate list of `moduleID:Global` pairs\n-h, --help Show this help message\n-i, --input <filename> Input (alternative to <entry file>)\n-m, --sourcemap Generate sourcemap (`-m inline` for inline map)\n-n, --name <name> Name for UMD export\n-o, --file <output> Single output file (if absent, prints to stdout)\n-p, --plugin <plugin> Use the plugin specified (may be repeated)\n-v, --version Show version number\n-w, --watch Watch files in bundle and rebuild on changes\n--amd.autoId Generate the AMD ID based off the chunk name\n--amd.basePath <prefix> Path to prepend to auto generated AMD ID\n--amd.define <name> Function to use in place of `define`\n--amd.forceJsExtensionForImports Use `.js` extension in AMD imports\n--amd.id <id> ID for AMD module (default is anonymous)\n--assetFileNames <pattern> Name pattern for emitted assets\n--banner <text> Code to insert at top of bundle (outside wrapper)\n--chunkFileNames <pattern> Name pattern for emitted secondary chunks\n--compact Minify wrapper code\n--context <variable> Specify top-level `this` value\n--no-dynamicImportInCjs Write external dynamic CommonJS imports as require\n--entryFileNames <pattern> Name pattern for emitted entry chunks\n--environment <values> Settings passed to config file (see example)\n--no-esModule Do not add __esModule property\n--exports <mode> Specify export mode (auto, default, named, none)\n--extend Extend global variable defined by --name\n--no-externalImportAttributes Omit import attributes in \"es\" output\n--no-externalLiveBindings Do not generate code to support live bindings\n--failAfterWarnings Exit with an error if the build produced warnings\n--filterLogs <filter> Filter log messages\n--footer <text> Code to insert at end of bundle (outside wrapper)\n--forceExit Force exit the process when done\n--no-freeze Do not freeze namespace objects\n--generatedCode <preset> Which code features to use (es5/es2015)\n--generatedCode.arrowFunctions Use arrow functions in generated code\n--generatedCode.constBindings Use \"const\" in generated code\n--generatedCode.objectShorthand Use shorthand properties in generated code\n--no-generatedCode.reservedNamesAsProps Always quote reserved names as props\n--generatedCode.symbols Use symbols in generated code\n--hashCharacters <name> Use the specified character set for file hashes\n--no-hoistTransitiveImports Do not hoist transitive imports into entry chunks\n--no-indent Don't indent result\n--inlineDynamicImports Create single bundle when using dynamic imports\n--no-interop Do not include interop block\n--intro <text> Code to insert at top of bundle (inside wrapper)\n--logLevel <level> Which kind of logs to display\n--no-makeAbsoluteExternalsRelative Prevent normalization of external imports\n--maxParallelFileOps <value> How many files to read in parallel\n--minifyInternalExports Force or disable minification of internal exports\n--noConflict Generate a noConflict method for UMD globals\n--outro <text> Code to insert at end of bundle (inside wrapper)\n--perf Display performance timings\n--no-preserveEntrySignatures Avoid facade chunks for entry points\n--preserveModules Preserve module structure\n--preserveModulesRoot Put preserved modules under this path at root level\n--preserveSymlinks Do not follow symlinks when resolving files\n--no-sanitizeFileName Do not replace invalid characters in file names\n--shimMissingExports Create shim variables for missing exports\n--silent Don't print warnings\n--sourcemapBaseUrl <url> Emit absolute sourcemap URLs with given base\n--sourcemapExcludeSources Do not include source code in source maps\n--sourcemapFile <file> Specify bundle position for source maps\n--sourcemapFileNames <pattern> Name pattern for emitted sourcemaps\n--stdin=ext Specify file extension used for stdin input\n--no-stdin Do not read \"-\" from stdin\n--no-strict Don't emit `\"use strict\";` in the generated modules\n--strictDeprecations Throw errors for deprecated features\n--no-systemNullSetters Do not replace empty SystemJS setters with `null`\n--no-treeshake Disable tree-shaking optimisations\n--no-treeshake.annotations Ignore pure call annotations\n--treeshake.correctVarValueBeforeDeclaration Deoptimize variables until declared\n--treeshake.manualPureFunctions <names> Manually declare functions as pure\n--no-treeshake.moduleSideEffects Assume modules have no side effects\n--no-treeshake.propertyReadSideEffects Ignore property access side effects\n--no-treeshake.tryCatchDeoptimization Do not turn off try-catch-tree-shaking\n--no-treeshake.unknownGlobalSideEffects Assume unknown globals do not throw\n--validate Validate output\n--waitForBundleInput Wait for bundle input files\n--watch.buildDelay <number> Throttle watch rebuilds\n--no-watch.clearScreen Do not clear the screen when rebuilding\n--watch.exclude <files> Exclude files from being watched\n--watch.include <files> Limit watching to specified files\n--watch.onBundleEnd <cmd> Shell command to run on `\"BUNDLE_END\"` event\n--watch.onBundleStart <cmd> Shell command to run on `\"BUNDLE_START\"` event\n--watch.onEnd <cmd> Shell command to run on `\"END\"` event\n--watch.onError <cmd> Shell command to run on `\"ERROR\"` event\n--watch.onStart <cmd> Shell command to run on `\"START\"` event\n--watch.skipWrite Do not write files to disk when watching\n\nExamples:\n\n# use settings in config file\nrollup -c\n\n# in config file, process.env.INCLUDE_DEPS === 'true'\n# and process.env.BUILD === 'production'\nrollup -c --environment INCLUDE_DEPS,BUILD:production\n\n# create CommonJS bundle.js from src/main.js\nrollup --format=cjs --file=bundle.js -- src/main.js\n\n# create self-executing IIFE using `window.jQuery`\n# and `window._` as external globals\nrollup -f iife --globals jquery:jQuery,lodash:_ \\\n -i src/app.js -o build/app.js -m build/app.js.map\n\nNotes:\n\n* When piping to stdout, only inline sourcemaps are permitted\n\nFor more information visit https://rollupjs.org\n";
32
32
 
33
33
  /**
34
34
  * @license
@@ -1248,33 +1248,66 @@ yargsParser.decamelize = decamelize;
1248
1248
  yargsParser.looksLikeNumber = looksLikeNumber;
1249
1249
  const argParser = yargsParser;
1250
1250
 
1251
- function parseMilliseconds(milliseconds) {
1252
- if (typeof milliseconds !== 'number') {
1253
- throw new TypeError('Expected a number');
1254
- }
1251
+ const toZeroIfInfinity = value => Number.isFinite(value) ? value : 0;
1255
1252
 
1256
- const roundTowardsZero = milliseconds > 0 ? Math.floor : Math.ceil;
1253
+ function parseNumber(milliseconds) {
1254
+ return {
1255
+ days: Math.trunc(milliseconds / 86_400_000),
1256
+ hours: Math.trunc(milliseconds / 3_600_000 % 24),
1257
+ minutes: Math.trunc(milliseconds / 60_000 % 60),
1258
+ seconds: Math.trunc(milliseconds / 1000 % 60),
1259
+ milliseconds: Math.trunc(milliseconds % 1000),
1260
+ microseconds: Math.trunc(toZeroIfInfinity(milliseconds * 1000) % 1000),
1261
+ nanoseconds: Math.trunc(toZeroIfInfinity(milliseconds * 1e6) % 1000),
1262
+ };
1263
+ }
1257
1264
 
1265
+ function parseBigint(milliseconds) {
1258
1266
  return {
1259
- days: roundTowardsZero(milliseconds / 86400000),
1260
- hours: roundTowardsZero(milliseconds / 3600000) % 24,
1261
- minutes: roundTowardsZero(milliseconds / 60000) % 60,
1262
- seconds: roundTowardsZero(milliseconds / 1000) % 60,
1263
- milliseconds: roundTowardsZero(milliseconds) % 1000,
1264
- microseconds: roundTowardsZero(milliseconds * 1000) % 1000,
1265
- nanoseconds: roundTowardsZero(milliseconds * 1e6) % 1000
1267
+ days: milliseconds / 86_400_000n,
1268
+ hours: milliseconds / 3_600_000n % 24n,
1269
+ minutes: milliseconds / 60_000n % 60n,
1270
+ seconds: milliseconds / 1000n % 60n,
1271
+ milliseconds: milliseconds % 1000n,
1272
+ microseconds: 0n,
1273
+ nanoseconds: 0n,
1266
1274
  };
1267
1275
  }
1268
1276
 
1269
- const pluralize = (word, count) => count === 1 ? word : `${word}s`;
1277
+ function parseMilliseconds(milliseconds) {
1278
+ switch (typeof milliseconds) {
1279
+ case 'number': {
1280
+ if (Number.isFinite(milliseconds)) {
1281
+ return parseNumber(milliseconds);
1282
+ }
1283
+
1284
+ break;
1285
+ }
1286
+
1287
+ case 'bigint': {
1288
+ return parseBigint(milliseconds);
1289
+ }
1290
+
1291
+ // No default
1292
+ }
1293
+
1294
+ throw new TypeError('Expected a finite number or bigint');
1295
+ }
1296
+
1297
+ const isZero = value => value === 0 || value === 0n;
1298
+ const pluralize = (word, count) => (count === 1 || count === 1n) ? word : `${word}s`;
1270
1299
 
1271
1300
  const SECOND_ROUNDING_EPSILON = 0.000_000_1;
1301
+ const ONE_DAY_IN_MILLISECONDS = 24n * 60n * 60n * 1000n;
1272
1302
 
1273
- function prettyMilliseconds(milliseconds, options = {}) {
1274
- if (!Number.isFinite(milliseconds)) {
1275
- throw new TypeError('Expected a finite number');
1303
+ function prettyMilliseconds(milliseconds, options) {
1304
+ const isBigInt = typeof milliseconds === 'bigint';
1305
+ if (!isBigInt && !Number.isFinite(milliseconds)) {
1306
+ throw new TypeError('Expected a finite number or bigint');
1276
1307
  }
1277
1308
 
1309
+ options = {...options};
1310
+
1278
1311
  if (options.colonNotation) {
1279
1312
  options.compact = false;
1280
1313
  options.formatSubMilliseconds = false;
@@ -1283,11 +1316,12 @@ function prettyMilliseconds(milliseconds, options = {}) {
1283
1316
  }
1284
1317
 
1285
1318
  if (options.compact) {
1319
+ options.unitCount = 1;
1286
1320
  options.secondsDecimalDigits = 0;
1287
1321
  options.millisecondsDecimalDigits = 0;
1288
1322
  }
1289
1323
 
1290
- const result = [];
1324
+ let result = [];
1291
1325
 
1292
1326
  const floorDecimals = (value, decimalDigits) => {
1293
1327
  const flooredInterimValue = Math.floor((value * (10 ** decimalDigits)) + SECOND_ROUNDING_EPSILON);
@@ -1296,62 +1330,67 @@ function prettyMilliseconds(milliseconds, options = {}) {
1296
1330
  };
1297
1331
 
1298
1332
  const add = (value, long, short, valueString) => {
1299
- if ((result.length === 0 || !options.colonNotation) && value === 0 && !(options.colonNotation && short === 'm')) {
1333
+ if (
1334
+ (result.length === 0 || !options.colonNotation)
1335
+ && isZero(value)
1336
+ && !(options.colonNotation && short === 'm')) {
1300
1337
  return;
1301
1338
  }
1302
1339
 
1303
- valueString = (valueString || value || '0').toString();
1304
- let prefix;
1305
- let suffix;
1340
+ valueString = valueString ?? String(value);
1306
1341
  if (options.colonNotation) {
1307
- prefix = result.length > 0 ? ':' : '';
1308
- suffix = '';
1309
1342
  const wholeDigits = valueString.includes('.') ? valueString.split('.')[0].length : valueString.length;
1310
1343
  const minLength = result.length > 0 ? 2 : 1;
1311
1344
  valueString = '0'.repeat(Math.max(0, minLength - wholeDigits)) + valueString;
1312
1345
  } else {
1313
- prefix = '';
1314
- suffix = options.verbose ? ' ' + pluralize(long, value) : short;
1346
+ valueString += options.verbose ? ' ' + pluralize(long, value) : short;
1315
1347
  }
1316
1348
 
1317
- result.push(prefix + valueString + suffix);
1349
+ result.push(valueString);
1318
1350
  };
1319
1351
 
1320
1352
  const parsed = parseMilliseconds(milliseconds);
1353
+ const days = BigInt(parsed.days);
1321
1354
 
1322
- add(Math.trunc(parsed.days / 365), 'year', 'y');
1323
- add(parsed.days % 365, 'day', 'd');
1324
- add(parsed.hours, 'hour', 'h');
1325
- add(parsed.minutes, 'minute', 'm');
1355
+ add(days / 365n, 'year', 'y');
1356
+ add(days % 365n, 'day', 'd');
1357
+ add(Number(parsed.hours), 'hour', 'h');
1358
+ add(Number(parsed.minutes), 'minute', 'm');
1326
1359
 
1327
1360
  if (
1328
1361
  options.separateMilliseconds
1329
1362
  || options.formatSubMilliseconds
1330
1363
  || (!options.colonNotation && milliseconds < 1000)
1331
1364
  ) {
1332
- add(parsed.seconds, 'second', 's');
1365
+ const seconds = Number(parsed.seconds);
1366
+ const milliseconds = Number(parsed.milliseconds);
1367
+ const microseconds = Number(parsed.microseconds);
1368
+ const nanoseconds = Number(parsed.nanoseconds);
1369
+
1370
+ add(seconds, 'second', 's');
1371
+
1333
1372
  if (options.formatSubMilliseconds) {
1334
- add(parsed.milliseconds, 'millisecond', 'ms');
1335
- add(parsed.microseconds, 'microsecond', 'µs');
1336
- add(parsed.nanoseconds, 'nanosecond', 'ns');
1373
+ add(milliseconds, 'millisecond', 'ms');
1374
+ add(microseconds, 'microsecond', 'µs');
1375
+ add(nanoseconds, 'nanosecond', 'ns');
1337
1376
  } else {
1338
1377
  const millisecondsAndBelow
1339
- = parsed.milliseconds
1340
- + (parsed.microseconds / 1000)
1341
- + (parsed.nanoseconds / 1e6);
1378
+ = milliseconds
1379
+ + (microseconds / 1000)
1380
+ + (nanoseconds / 1e6);
1342
1381
 
1343
1382
  const millisecondsDecimalDigits
1344
1383
  = typeof options.millisecondsDecimalDigits === 'number'
1345
1384
  ? options.millisecondsDecimalDigits
1346
1385
  : 0;
1347
1386
 
1348
- const roundedMiliseconds = millisecondsAndBelow >= 1
1387
+ const roundedMilliseconds = millisecondsAndBelow >= 1
1349
1388
  ? Math.round(millisecondsAndBelow)
1350
1389
  : Math.ceil(millisecondsAndBelow);
1351
1390
 
1352
1391
  const millisecondsString = millisecondsDecimalDigits
1353
1392
  ? millisecondsAndBelow.toFixed(millisecondsDecimalDigits)
1354
- : roundedMiliseconds;
1393
+ : roundedMilliseconds;
1355
1394
 
1356
1395
  add(
1357
1396
  Number.parseFloat(millisecondsString),
@@ -1361,7 +1400,10 @@ function prettyMilliseconds(milliseconds, options = {}) {
1361
1400
  );
1362
1401
  }
1363
1402
  } else {
1364
- const seconds = (milliseconds / 1000) % 60;
1403
+ const seconds = (
1404
+ (isBigInt ? Number(milliseconds % ONE_DAY_IN_MILLISECONDS) : milliseconds)
1405
+ / 1000
1406
+ ) % 60;
1365
1407
  const secondsDecimalDigits
1366
1408
  = typeof options.secondsDecimalDigits === 'number'
1367
1409
  ? options.secondsDecimalDigits
@@ -1377,16 +1419,12 @@ function prettyMilliseconds(milliseconds, options = {}) {
1377
1419
  return '0' + (options.verbose ? ' milliseconds' : 'ms');
1378
1420
  }
1379
1421
 
1380
- if (options.compact) {
1381
- return result[0];
1382
- }
1383
-
1422
+ const separator = options.colonNotation ? ':' : ' ';
1384
1423
  if (typeof options.unitCount === 'number') {
1385
- const separator = options.colonNotation ? '' : ' ';
1386
- return result.slice(0, Math.max(options.unitCount, 1)).join(separator);
1424
+ result = result.slice(0, Math.max(options.unitCount, 1));
1387
1425
  }
1388
1426
 
1389
- return options.colonNotation ? result.join('') : result.join(' ');
1427
+ return result.join(separator);
1390
1428
  }
1391
1429
 
1392
1430
  const BYTE_UNITS = [
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v4.9.6
4
- Sun, 21 Jan 2024 05:51:51 GMT - commit ecb6b0a430098052781aa6ee04ec92ee70960321
3
+ Rollup.js v4.10.0
4
+ Sat, 10 Feb 2024 05:58:12 GMT - commit 762420860765e8e46e24d48b38f5b98ca31735fa
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v4.9.6
4
- Sun, 21 Jan 2024 05:51:51 GMT - commit ecb6b0a430098052781aa6ee04ec92ee70960321
3
+ Rollup.js v4.10.0
4
+ Sat, 10 Feb 2024 05:58:12 GMT - commit 762420860765e8e46e24d48b38f5b98ca31735fa
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
package/dist/es/rollup.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v4.9.6
4
- Sun, 21 Jan 2024 05:51:51 GMT - commit ecb6b0a430098052781aa6ee04ec92ee70960321
3
+ Rollup.js v4.10.0
4
+ Sat, 10 Feb 2024 05:58:12 GMT - commit 762420860765e8e46e24d48b38f5b98ca31735fa
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v4.9.6
4
- Sun, 21 Jan 2024 05:51:51 GMT - commit ecb6b0a430098052781aa6ee04ec92ee70960321
3
+ Rollup.js v4.10.0
4
+ Sat, 10 Feb 2024 05:58:12 GMT - commit 762420860765e8e46e24d48b38f5b98ca31735fa
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -12,11 +12,11 @@ import { relative, dirname, basename, extname, resolve as resolve$1 } from 'node
12
12
  import require$$0$1, { win32, posix, isAbsolute, resolve } from 'path';
13
13
  import process$1, { env as env$1 } from 'node:process';
14
14
  import { performance } from 'node:perf_hooks';
15
- import { xxhashBase64Url } from '../../native.js';
15
+ import { xxhashBase64Url, xxhashBase36, xxhashBase16 } from '../../native.js';
16
16
  import { lstat, realpath, readdir, readFile, mkdir, writeFile } from 'node:fs/promises';
17
17
  import * as tty from 'tty';
18
18
 
19
- var version = "4.9.6";
19
+ var version = "4.10.0";
20
20
 
21
21
  const comma = ','.charCodeAt(0);
22
22
  const semicolon = ';'.charCodeAt(0);
@@ -274,6 +274,16 @@ let Chunk$1 = class Chunk {
274
274
  this.intro = content + this.intro;
275
275
  }
276
276
 
277
+ reset() {
278
+ this.intro = '';
279
+ this.outro = '';
280
+ if (this.edited) {
281
+ this.content = this.original;
282
+ this.storeName = false;
283
+ this.edited = false;
284
+ }
285
+ }
286
+
277
287
  split(index) {
278
288
  const sliceIndex = index - this.start;
279
289
 
@@ -364,8 +374,8 @@ let Chunk$1 = class Chunk {
364
374
  };
365
375
 
366
376
  function getBtoa() {
367
- if (typeof window !== 'undefined' && typeof window.btoa === 'function') {
368
- return (str) => window.btoa(unescape(encodeURIComponent(str)));
377
+ if (typeof globalThis !== 'undefined' && typeof globalThis.btoa === 'function') {
378
+ return (str) => globalThis.btoa(unescape(encodeURIComponent(str)));
369
379
  } else if (typeof Buffer === 'function') {
370
380
  return (str) => Buffer.from(str, 'utf-8').toString('base64');
371
381
  } else {
@@ -1042,6 +1052,28 @@ class MagicString {
1042
1052
  return this;
1043
1053
  }
1044
1054
 
1055
+ reset(start, end) {
1056
+ while (start < 0) start += this.original.length;
1057
+ while (end < 0) end += this.original.length;
1058
+
1059
+ if (start === end) return this;
1060
+
1061
+ if (start < 0 || end > this.original.length) throw new Error('Character is out of bounds');
1062
+ if (start > end) throw new Error('end must be greater than start');
1063
+
1064
+ this._split(start);
1065
+ this._split(end);
1066
+
1067
+ let chunk = this.byStart[start];
1068
+
1069
+ while (chunk) {
1070
+ chunk.reset();
1071
+
1072
+ chunk = end > chunk.end ? this.byStart[chunk.end] : null;
1073
+ }
1074
+ return this;
1075
+ }
1076
+
1045
1077
  lastChar() {
1046
1078
  if (this.outro.length) return this.outro[this.outro.length - 1];
1047
1079
  let chunk = this.lastChunk;
@@ -12777,7 +12809,7 @@ class Module {
12777
12809
  this.ast.bind();
12778
12810
  }
12779
12811
  error(properties, pos) {
12780
- this.addLocationToLogProps(properties, pos);
12812
+ pos !== undefined && this.addLocationToLogProps(properties, pos);
12781
12813
  return error(properties);
12782
12814
  }
12783
12815
  // sum up the length of all ast nodes that are included
@@ -14680,13 +14712,13 @@ const hashPlaceholderLeft = '!~{';
14680
14712
  const hashPlaceholderRight = '}~';
14681
14713
  const hashPlaceholderOverhead = hashPlaceholderLeft.length + hashPlaceholderRight.length;
14682
14714
  // This is the size of a 128-bits xxhash with base64url encoding
14683
- const maxHashSize = 22;
14684
- const defaultHashSize = 8;
14715
+ const MAX_HASH_SIZE = 22;
14716
+ const DEFAULT_HASH_SIZE = 8;
14685
14717
  const getHashPlaceholderGenerator = () => {
14686
14718
  let nextIndex = 0;
14687
- return (optionName, hashSize = defaultHashSize) => {
14688
- if (hashSize > maxHashSize) {
14689
- return error(logFailedValidation(`Hashes cannot be longer than ${maxHashSize} characters, received ${hashSize}. Check the "${optionName}" option.`));
14719
+ return (optionName, hashSize) => {
14720
+ if (hashSize > MAX_HASH_SIZE) {
14721
+ return error(logFailedValidation(`Hashes cannot be longer than ${MAX_HASH_SIZE} characters, received ${hashSize}. Check the "${optionName}" option.`));
14690
14722
  }
14691
14723
  const placeholder = `${hashPlaceholderLeft}${toBase64(++nextIndex).padStart(hashSize - hashPlaceholderOverhead, '0')}${hashPlaceholderRight}`;
14692
14724
  if (placeholder.length > hashSize) {
@@ -14695,7 +14727,7 @@ const getHashPlaceholderGenerator = () => {
14695
14727
  return placeholder;
14696
14728
  };
14697
14729
  };
14698
- const REPLACER_REGEX = new RegExp(`${hashPlaceholderLeft}[0-9a-zA-Z_$]{1,${maxHashSize - hashPlaceholderOverhead}}${hashPlaceholderRight}`, 'g');
14730
+ const REPLACER_REGEX = new RegExp(`${hashPlaceholderLeft}[0-9a-zA-Z_$]{1,${MAX_HASH_SIZE - hashPlaceholderOverhead}}${hashPlaceholderRight}`, 'g');
14699
14731
  const replacePlaceholders = (code, hashesByPlaceholder) => code.replace(REPLACER_REGEX, placeholder => hashesByPlaceholder.get(placeholder) || placeholder);
14700
14732
  const replaceSinglePlaceholder = (code, placeholder, value) => code.replace(REPLACER_REGEX, match => (match === placeholder ? value : match));
14701
14733
  const replacePlaceholdersWithDefaultAndGetContainedPlaceholders = (code, placeholders) => {
@@ -15059,7 +15091,8 @@ class Chunk {
15059
15091
  : [chunkFileNames, 'output.chunkFileNames'];
15060
15092
  fileName = renderNamePattern(typeof pattern === 'function' ? pattern(this.getPreRenderedChunkInfo()) : pattern, patternName, {
15061
15093
  format: () => format,
15062
- hash: size => hashPlaceholder || (hashPlaceholder = this.getPlaceholder(patternName, size)),
15094
+ hash: size => hashPlaceholder ||
15095
+ (hashPlaceholder = this.getPlaceholder(patternName, size || DEFAULT_HASH_SIZE)),
15063
15096
  name: () => this.getChunkName()
15064
15097
  });
15065
15098
  if (!hashPlaceholder) {
@@ -15087,7 +15120,8 @@ class Chunk {
15087
15120
  sourcemapFileName = renderNamePattern(typeof pattern === 'function' ? pattern(this.getPreRenderedChunkInfo()) : pattern, patternName, {
15088
15121
  chunkhash: () => this.getPreliminaryFileName().hashPlaceholder || '',
15089
15122
  format: () => format,
15090
- hash: size => hashPlaceholder || (hashPlaceholder = this.getPlaceholder(patternName, size)),
15123
+ hash: size => hashPlaceholder ||
15124
+ (hashPlaceholder = this.getPlaceholder(patternName, size || DEFAULT_HASH_SIZE)),
15091
15125
  name: () => this.getChunkName()
15092
15126
  });
15093
15127
  if (!hashPlaceholder) {
@@ -16786,21 +16820,23 @@ function collapseSourcemap(id, originalCode, originalSourcemap, sourcemapChain,
16786
16820
  }
16787
16821
 
16788
16822
  let textEncoder;
16789
- function getXxhash(input) {
16790
- let buffer;
16823
+ const getHash64 = input => xxhashBase64Url(ensureBuffer(input));
16824
+ const getHash36 = input => xxhashBase36(ensureBuffer(input));
16825
+ const getHash16 = input => xxhashBase16(ensureBuffer(input));
16826
+ const hasherByType = {
16827
+ base36: getHash36,
16828
+ base64: getHash64,
16829
+ hex: getHash16
16830
+ };
16831
+ function ensureBuffer(input) {
16791
16832
  if (typeof input === 'string') {
16792
16833
  if (typeof Buffer === 'undefined') {
16793
16834
  textEncoder ??= new TextEncoder();
16794
- buffer = textEncoder.encode(input);
16835
+ return textEncoder.encode(input);
16795
16836
  }
16796
- else {
16797
- buffer = Buffer.from(input);
16798
- }
16799
- }
16800
- else {
16801
- buffer = input;
16837
+ return Buffer.from(input);
16802
16838
  }
16803
- return xxhashBase64Url(buffer);
16839
+ return input;
16804
16840
  }
16805
16841
 
16806
16842
  // this looks ridiculous, but it prevents sourcemap tooling from mistaking
@@ -16814,9 +16850,10 @@ async function renderChunks(chunks, bundle, pluginDriver, outputOptions, log) {
16814
16850
  const renderedChunks = await Promise.all(chunks.map(chunk => chunk.render()));
16815
16851
  timeEnd('render chunks', 2);
16816
16852
  timeStart('transform chunks', 2);
16853
+ const getHash = hasherByType[outputOptions.hashCharacters];
16817
16854
  const chunkGraph = getChunkGraph(chunks);
16818
- const { initialHashesByPlaceholder, nonHashedChunksWithPlaceholders, renderedChunksByPlaceholder, hashDependenciesByPlaceholder } = await transformChunksAndGenerateContentHashes(renderedChunks, chunkGraph, outputOptions, pluginDriver, log);
16819
- const hashesByPlaceholder = generateFinalHashes(renderedChunksByPlaceholder, hashDependenciesByPlaceholder, initialHashesByPlaceholder, bundle);
16855
+ const { initialHashesByPlaceholder, nonHashedChunksWithPlaceholders, renderedChunksByPlaceholder, hashDependenciesByPlaceholder } = await transformChunksAndGenerateContentHashes(renderedChunks, chunkGraph, outputOptions, pluginDriver, getHash, log);
16856
+ const hashesByPlaceholder = generateFinalHashes(renderedChunksByPlaceholder, hashDependenciesByPlaceholder, initialHashesByPlaceholder, bundle, getHash);
16820
16857
  addChunksToBundle(renderedChunksByPlaceholder, hashesByPlaceholder, bundle, nonHashedChunksWithPlaceholders, pluginDriver, outputOptions);
16821
16858
  timeEnd('transform chunks', 2);
16822
16859
  }
@@ -16896,7 +16933,7 @@ async function transformChunk(magicString, fileName, usedModules, chunkGraph, op
16896
16933
  map
16897
16934
  };
16898
16935
  }
16899
- async function transformChunksAndGenerateContentHashes(renderedChunks, chunkGraph, outputOptions, pluginDriver, log) {
16936
+ async function transformChunksAndGenerateContentHashes(renderedChunks, chunkGraph, outputOptions, pluginDriver, getHash, log) {
16900
16937
  const nonHashedChunksWithPlaceholders = [];
16901
16938
  const renderedChunksByPlaceholder = new Map();
16902
16939
  const hashDependenciesByPlaceholder = new Map();
@@ -16931,7 +16968,7 @@ async function transformChunksAndGenerateContentHashes(renderedChunks, chunkGrap
16931
16968
  renderedChunksByPlaceholder.set(hashPlaceholder, transformedChunk);
16932
16969
  hashDependenciesByPlaceholder.set(hashPlaceholder, {
16933
16970
  containedPlaceholders,
16934
- contentHash: getXxhash(contentToHash)
16971
+ contentHash: getHash(contentToHash)
16935
16972
  });
16936
16973
  }
16937
16974
  else {
@@ -16939,7 +16976,7 @@ async function transformChunksAndGenerateContentHashes(renderedChunks, chunkGrap
16939
16976
  }
16940
16977
  const sourcemapHashPlaceholder = preliminarySourcemapFileName?.hashPlaceholder;
16941
16978
  if (map && sourcemapHashPlaceholder) {
16942
- initialHashesByPlaceholder.set(preliminarySourcemapFileName.hashPlaceholder, getXxhash(map.toString()).slice(0, preliminarySourcemapFileName.hashPlaceholder.length));
16979
+ initialHashesByPlaceholder.set(preliminarySourcemapFileName.hashPlaceholder, getHash(map.toString()).slice(0, preliminarySourcemapFileName.hashPlaceholder.length));
16943
16980
  }
16944
16981
  }));
16945
16982
  return {
@@ -16949,7 +16986,7 @@ async function transformChunksAndGenerateContentHashes(renderedChunks, chunkGrap
16949
16986
  renderedChunksByPlaceholder
16950
16987
  };
16951
16988
  }
16952
- function generateFinalHashes(renderedChunksByPlaceholder, hashDependenciesByPlaceholder, initialHashesByPlaceholder, bundle) {
16989
+ function generateFinalHashes(renderedChunksByPlaceholder, hashDependenciesByPlaceholder, initialHashesByPlaceholder, bundle, getHash) {
16953
16990
  const hashesByPlaceholder = new Map(initialHashesByPlaceholder);
16954
16991
  for (const [placeholder, { fileName }] of renderedChunksByPlaceholder) {
16955
16992
  let contentToHash = '';
@@ -16969,7 +17006,7 @@ function generateFinalHashes(renderedChunksByPlaceholder, hashDependenciesByPlac
16969
17006
  if (finalHash) {
16970
17007
  contentToHash = finalHash;
16971
17008
  }
16972
- finalHash = getXxhash(contentToHash).slice(0, placeholder.length);
17009
+ finalHash = getHash(contentToHash).slice(0, placeholder.length);
16973
17010
  finalFileName = replaceSinglePlaceholder(fileName, placeholder, finalHash);
16974
17011
  } while (bundle[lowercaseBundleKeys].has(finalFileName.toLowerCase()));
16975
17012
  bundle[finalFileName] = FILE_PLACEHOLDER;
@@ -18136,7 +18173,7 @@ function generateAssetFileName(name, source, sourceHash, outputOptions, bundle)
18136
18173
  : outputOptions.assetFileNames, 'output.assetFileNames', {
18137
18174
  ext: () => extname(emittedName).slice(1),
18138
18175
  extname: () => extname(emittedName),
18139
- hash: size => sourceHash.slice(0, Math.max(0, size || defaultHashSize)),
18176
+ hash: size => sourceHash.slice(0, Math.max(0, size || DEFAULT_HASH_SIZE)),
18140
18177
  name: () => emittedName.slice(0, Math.max(0, emittedName.length - extname(emittedName).length))
18141
18178
  }), bundle);
18142
18179
  }
@@ -18245,9 +18282,11 @@ class FileEmitter {
18245
18282
  this.facadeChunkByModule = facadeChunkByModule;
18246
18283
  };
18247
18284
  this.setOutputBundle = (bundle, outputOptions) => {
18285
+ const getHash = hasherByType[outputOptions.hashCharacters];
18248
18286
  const output = (this.output = {
18249
18287
  bundle,
18250
18288
  fileNamesBySource: new Map(),
18289
+ getHash,
18251
18290
  outputOptions
18252
18291
  });
18253
18292
  for (const emittedFile of this.filesByReferenceId.values()) {
@@ -18262,7 +18301,7 @@ class FileEmitter {
18262
18301
  this.finalizeAdditionalAsset(consumedFile, consumedFile.source, output);
18263
18302
  }
18264
18303
  else {
18265
- const sourceHash = getXxhash(consumedFile.source);
18304
+ const sourceHash = getHash(consumedFile.source);
18266
18305
  getOrCreate(consumedAssetsByHash, sourceHash, () => []).push(consumedFile);
18267
18306
  }
18268
18307
  }
@@ -18285,7 +18324,7 @@ class FileEmitter {
18285
18324
  assignReferenceId(file, idBase) {
18286
18325
  let referenceId = idBase;
18287
18326
  do {
18288
- referenceId = getXxhash(referenceId).slice(0, 8).replaceAll('-', '$');
18327
+ referenceId = getHash64(referenceId).slice(0, 8).replaceAll('-', '$');
18289
18328
  } while (this.filesByReferenceId.has(referenceId) ||
18290
18329
  this.outputFileEmitters.some(({ filesByReferenceId }) => filesByReferenceId.has(referenceId)));
18291
18330
  file.referenceId = referenceId;
@@ -18396,11 +18435,11 @@ class FileEmitter {
18396
18435
  }
18397
18436
  return referenceId;
18398
18437
  }
18399
- finalizeAdditionalAsset(consumedFile, source, { bundle, fileNamesBySource, outputOptions }) {
18438
+ finalizeAdditionalAsset(consumedFile, source, { bundle, fileNamesBySource, getHash, outputOptions }) {
18400
18439
  let { fileName, needsCodeReference, referenceId } = consumedFile;
18401
18440
  // Deduplicate assets if an explicit fileName is not provided
18402
18441
  if (!fileName) {
18403
- const sourceHash = getXxhash(source);
18442
+ const sourceHash = getHash(source);
18404
18443
  fileName = fileNamesBySource.get(sourceHash);
18405
18444
  if (!fileName) {
18406
18445
  fileName = generateAssetFileName(consumedFile.name, source, sourceHash, outputOptions, bundle);
@@ -19258,6 +19297,7 @@ async function normalizeOutputOptions(config, inputOptions, unsetInputOptions) {
19258
19297
  freeze: config.freeze ?? true,
19259
19298
  generatedCode,
19260
19299
  globals: config.globals || {},
19300
+ hashCharacters: config.hashCharacters ?? 'base64',
19261
19301
  hoistTransitiveImports: config.hoistTransitiveImports ?? true,
19262
19302
  indent: getIndent(config, compact),
19263
19303
  inlineDynamicImports,
@@ -19958,6 +19998,7 @@ async function mergeOutputOptions(config, overrides, log) {
19958
19998
  freeze: getOption('freeze'),
19959
19999
  generatedCode: getObjectOption(config, overrides, 'generatedCode', objectifyOptionWithPresets(generatedCodePresets, 'output.generatedCode', URL_OUTPUT_GENERATEDCODE, '')),
19960
20000
  globals: getOption('globals'),
20001
+ hashCharacters: getOption('hashCharacters'),
19961
20002
  hoistTransitiveImports: getOption('hoistTransitiveImports'),
19962
20003
  indent: getOption('indent'),
19963
20004
  inlineDynamicImports: getOption('inlineDynamicImports'),
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v4.9.6
4
- Sun, 21 Jan 2024 05:51:51 GMT - commit ecb6b0a430098052781aa6ee04ec92ee70960321
3
+ Rollup.js v4.10.0
4
+ Sat, 10 Feb 2024 05:58:12 GMT - commit 762420860765e8e46e24d48b38f5b98ca31735fa
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -971,6 +971,10 @@ const nodeConverters = [
971
971
  const message = convertString(position, buffer, readString);
972
972
  error(logParseError(message, pos));
973
973
  },
974
+ function panicError(position, buffer, readString) {
975
+ const message = convertString(position, buffer, readString);
976
+ error(logParseError(message));
977
+ },
974
978
  function arrayExpression(position, buffer, readString) {
975
979
  const start = buffer[position++];
976
980
  const end = buffer[position++];
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v4.9.6
4
- Sun, 21 Jan 2024 05:51:51 GMT - commit ecb6b0a430098052781aa6ee04ec92ee70960321
3
+ Rollup.js v4.10.0
4
+ Sat, 10 Feb 2024 05:58:12 GMT - commit 762420860765e8e46e24d48b38f5b98ca31735fa
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -2387,6 +2387,7 @@ var constants = {};
2387
2387
  exports.FSEVENT_MOVED = 'moved';
2388
2388
  exports.FSEVENT_CLONED = 'cloned';
2389
2389
  exports.FSEVENT_UNKNOWN = 'unknown';
2390
+ exports.FSEVENT_FLAG_MUST_SCAN_SUBDIRS = 1;
2390
2391
  exports.FSEVENT_TYPE_FILE = 'file';
2391
2392
  exports.FSEVENT_TYPE_DIRECTORY = 'directory';
2392
2393
  exports.FSEVENT_TYPE_SYMLINK = 'symlink';
@@ -3112,6 +3113,7 @@ const {
3112
3113
  FSEVENT_MOVED,
3113
3114
  // FSEVENT_CLONED,
3114
3115
  FSEVENT_UNKNOWN,
3116
+ FSEVENT_FLAG_MUST_SCAN_SUBDIRS,
3115
3117
  FSEVENT_TYPE_FILE,
3116
3118
  FSEVENT_TYPE_DIRECTORY,
3117
3119
  FSEVENT_TYPE_SYMLINK,
@@ -3223,6 +3225,7 @@ function setFSEventsListener(path, realPath, listener, rawEmitter) {
3223
3225
  rawEmitter,
3224
3226
  watcher: createFSEventsInstance(watchPath, (fullPath, flags) => {
3225
3227
  if (!cont.listeners.size) return;
3228
+ if (flags & FSEVENT_FLAG_MUST_SCAN_SUBDIRS) return;
3226
3229
  const info = fsevents.getInfo(fullPath, flags);
3227
3230
  cont.listeners.forEach(list => {
3228
3231
  list(fullPath, flags, info);
@@ -4041,7 +4044,7 @@ add(paths_, _origAdd, _internal) {
4041
4044
 
4042
4045
  if (this.options.useFsEvents && this._fsEventsHandler) {
4043
4046
  if (!this._readyCount) this._readyCount = paths.length;
4044
- if (this.options.persistent) this._readyCount *= 2;
4047
+ if (this.options.persistent) this._readyCount += paths.length;
4045
4048
  paths.forEach((path) => this._fsEventsHandler._addToFsEvents(path));
4046
4049
  } else {
4047
4050
  if (!this._readyCount) this._readyCount = 0;