rollup 4.0.0-22 → 4.0.0-24

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,9 +1,8 @@
1
1
  #!/usr/bin/env node
2
-
3
2
  /*
4
3
  @license
5
- Rollup.js v4.0.0-22
6
- Tue, 26 Sep 2023 16:16:00 GMT - commit 38be49cf19099321f935c1ad5968e76fb30e0957
4
+ Rollup.js v4.0.0-24
5
+ Tue, 03 Oct 2023 05:11:52 GMT - commit ced077f2920c473c4c2ca31a8d72b259bec91f67
7
6
 
8
7
  https://github.com/rollup/rollup
9
8
 
@@ -24,7 +23,6 @@ const node_path = require('node:path');
24
23
  const loadConfigFile_js = require('../shared/loadConfigFile.js');
25
24
  require('tty');
26
25
  require('node:perf_hooks');
27
- require('node:crypto');
28
26
  require('../native.js');
29
27
  require('node:url');
30
28
  require('../getLogFilter.js');
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v4.0.0-22
4
- Tue, 26 Sep 2023 16:16:00 GMT - commit 38be49cf19099321f935c1ad5968e76fb30e0957
3
+ Rollup.js v4.0.0-24
4
+ Tue, 03 Oct 2023 05:11:52 GMT - commit ced077f2920c473c4c2ca31a8d72b259bec91f67
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.0.0-22
4
- Tue, 26 Sep 2023 16:16:00 GMT - commit 38be49cf19099321f935c1ad5968e76fb30e0957
3
+ Rollup.js v4.0.0-24
4
+ Tue, 03 Oct 2023 05:11:52 GMT - commit ced077f2920c473c4c2ca31a8d72b259bec91f67
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -12,7 +12,6 @@ import 'node:path';
12
12
  import 'path';
13
13
  import 'node:process';
14
14
  import 'node:perf_hooks';
15
- import 'node:crypto';
16
15
  import '../native.js';
17
16
  import 'node:fs/promises';
18
17
  import 'tty';
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v4.0.0-22
4
- Tue, 26 Sep 2023 16:16:00 GMT - commit 38be49cf19099321f935c1ad5968e76fb30e0957
3
+ Rollup.js v4.0.0-24
4
+ Tue, 03 Oct 2023 05:11:52 GMT - commit ced077f2920c473c4c2ca31a8d72b259bec91f67
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -11,12 +11,11 @@ import { resolve, basename, extname, dirname, relative as relative$1 } from 'nod
11
11
  import require$$0$1, { win32, posix, isAbsolute as isAbsolute$1, resolve as resolve$1 } from 'path';
12
12
  import process$1, { env as env$1 } from 'node:process';
13
13
  import { performance } from 'node:perf_hooks';
14
- import { createHash as createHash$1 } from 'node:crypto';
15
- import native from '../../native.js';
14
+ import { xxhashBase64Url, parse as parse$2 } from '../../native.js';
16
15
  import { lstat, realpath, readdir, readFile, mkdir, writeFile } from 'node:fs/promises';
17
16
  import * as tty from 'tty';
18
17
 
19
- var version = "4.0.0-22";
18
+ var version = "4.0.0-24";
20
19
 
21
20
  const comma = ','.charCodeAt(0);
22
21
  const semicolon = ';'.charCodeAt(0);
@@ -2271,6 +2270,8 @@ const URL_OUTPUT_SOURCEMAPBASEURL = 'configuration-options/#output-sourcemapbase
2271
2270
  const URL_OUTPUT_SOURCEMAPFILE = 'configuration-options/#output-sourcemapfile';
2272
2271
  const URL_PRESERVEENTRYSIGNATURES = 'configuration-options/#preserveentrysignatures';
2273
2272
  const URL_TREESHAKE = 'configuration-options/#treeshake';
2273
+ const URL_TREESHAKE_PURE = 'configuration-options/#pure';
2274
+ const URL_TREESHAKE_NOSIDEEFFECTS = 'configuration-options/#no-side-effects';
2274
2275
  const URL_TREESHAKE_MODULESIDEEFFECTS = 'configuration-options/#treeshake-modulesideeffects';
2275
2276
  const URL_WATCH = 'configuration-options/#watch';
2276
2277
 
@@ -2302,7 +2303,7 @@ function augmentCodeLocation(properties, pos, source, id) {
2302
2303
  }
2303
2304
  // Error codes should be sorted alphabetically while errors should be sorted by
2304
2305
  // error code below
2305
- const ADDON_ERROR = 'ADDON_ERROR', ALREADY_CLOSED = 'ALREADY_CLOSED', AMBIGUOUS_EXTERNAL_NAMESPACES = 'AMBIGUOUS_EXTERNAL_NAMESPACES', ANONYMOUS_PLUGIN_CACHE = 'ANONYMOUS_PLUGIN_CACHE', ASSET_NOT_FINALISED = 'ASSET_NOT_FINALISED', ASSET_NOT_FOUND = 'ASSET_NOT_FOUND', ASSET_SOURCE_ALREADY_SET = 'ASSET_SOURCE_ALREADY_SET', ASSET_SOURCE_MISSING = 'ASSET_SOURCE_MISSING', BAD_LOADER = 'BAD_LOADER', CANNOT_CALL_NAMESPACE = 'CANNOT_CALL_NAMESPACE', CANNOT_EMIT_FROM_OPTIONS_HOOK = 'CANNOT_EMIT_FROM_OPTIONS_HOOK', CHUNK_NOT_GENERATED = 'CHUNK_NOT_GENERATED', CHUNK_INVALID = 'CHUNK_INVALID', CIRCULAR_DEPENDENCY = 'CIRCULAR_DEPENDENCY', CIRCULAR_REEXPORT = 'CIRCULAR_REEXPORT', CYCLIC_CROSS_CHUNK_REEXPORT = 'CYCLIC_CROSS_CHUNK_REEXPORT', DEPRECATED_FEATURE = 'DEPRECATED_FEATURE', DUPLICATE_PLUGIN_NAME = 'DUPLICATE_PLUGIN_NAME', EMPTY_BUNDLE = 'EMPTY_BUNDLE', EVAL = 'EVAL', EXTERNAL_MODULES_CANNOT_BE_INCLUDED_IN_MANUAL_CHUNKS = 'EXTERNAL_MODULES_CANNOT_BE_INCLUDED_IN_MANUAL_CHUNKS', EXTERNAL_MODULES_CANNOT_BE_TRANSFORMED_TO_MODULES = 'EXTERNAL_MODULES_CANNOT_BE_TRANSFORMED_TO_MODULES', EXTERNAL_SYNTHETIC_EXPORTS = 'EXTERNAL_SYNTHETIC_EXPORTS', FILE_NAME_CONFLICT = 'FILE_NAME_CONFLICT', FILE_NOT_FOUND = 'FILE_NOT_FOUND', FIRST_SIDE_EFFECT = 'FIRST_SIDE_EFFECT', ILLEGAL_IDENTIFIER_AS_NAME = 'ILLEGAL_IDENTIFIER_AS_NAME', ILLEGAL_REASSIGNMENT = 'ILLEGAL_REASSIGNMENT', INCONSISTENT_IMPORT_ATTRIBUTES = 'INCONSISTENT_IMPORT_ATTRIBUTES', INPUT_HOOK_IN_OUTPUT_PLUGIN = 'INPUT_HOOK_IN_OUTPUT_PLUGIN', INVALID_CHUNK = 'INVALID_CHUNK', INVALID_EXPORT_OPTION = 'INVALID_EXPORT_OPTION', INVALID_EXTERNAL_ID = 'INVALID_EXTERNAL_ID', INVALID_IMPORT_ATTRIBUTE = 'INVALID_IMPORT_ATTRIBUTE', INVALID_LOG_POSITION = 'INVALID_LOG_POSITION', INVALID_OPTION = 'INVALID_OPTION', INVALID_PLUGIN_HOOK = 'INVALID_PLUGIN_HOOK', INVALID_ROLLUP_PHASE = 'INVALID_ROLLUP_PHASE', INVALID_SETASSETSOURCE = 'INVALID_SETASSETSOURCE', INVALID_TLA_FORMAT = 'INVALID_TLA_FORMAT', MISSING_EXPORT = 'MISSING_EXPORT', MISSING_GLOBAL_NAME = 'MISSING_GLOBAL_NAME', MISSING_IMPLICIT_DEPENDANT = 'MISSING_IMPLICIT_DEPENDANT', MISSING_NAME_OPTION_FOR_IIFE_EXPORT = 'MISSING_NAME_OPTION_FOR_IIFE_EXPORT', MISSING_NODE_BUILTINS = 'MISSING_NODE_BUILTINS', MISSING_OPTION = 'MISSING_OPTION', MIXED_EXPORTS = 'MIXED_EXPORTS', MODULE_LEVEL_DIRECTIVE = 'MODULE_LEVEL_DIRECTIVE', NAMESPACE_CONFLICT = 'NAMESPACE_CONFLICT', NO_TRANSFORM_MAP_OR_AST_WITHOUT_CODE = 'NO_TRANSFORM_MAP_OR_AST_WITHOUT_CODE', OPTIMIZE_CHUNK_STATUS = 'OPTIMIZE_CHUNK_STATUS', PARSE_ERROR = 'PARSE_ERROR', PLUGIN_ERROR = 'PLUGIN_ERROR', SHIMMED_EXPORT = 'SHIMMED_EXPORT', SOURCEMAP_BROKEN = 'SOURCEMAP_BROKEN', SOURCEMAP_ERROR = 'SOURCEMAP_ERROR', SYNTHETIC_NAMED_EXPORTS_NEED_NAMESPACE_EXPORT = 'SYNTHETIC_NAMED_EXPORTS_NEED_NAMESPACE_EXPORT', THIS_IS_UNDEFINED = 'THIS_IS_UNDEFINED', UNEXPECTED_NAMED_IMPORT = 'UNEXPECTED_NAMED_IMPORT', UNKNOWN_OPTION = 'UNKNOWN_OPTION', UNRESOLVED_ENTRY = 'UNRESOLVED_ENTRY', UNRESOLVED_IMPORT = 'UNRESOLVED_IMPORT', UNUSED_EXTERNAL_IMPORT = 'UNUSED_EXTERNAL_IMPORT', VALIDATION_ERROR = 'VALIDATION_ERROR';
2306
+ const ADDON_ERROR = 'ADDON_ERROR', ALREADY_CLOSED = 'ALREADY_CLOSED', AMBIGUOUS_EXTERNAL_NAMESPACES = 'AMBIGUOUS_EXTERNAL_NAMESPACES', ANONYMOUS_PLUGIN_CACHE = 'ANONYMOUS_PLUGIN_CACHE', ASSET_NOT_FINALISED = 'ASSET_NOT_FINALISED', ASSET_NOT_FOUND = 'ASSET_NOT_FOUND', ASSET_SOURCE_ALREADY_SET = 'ASSET_SOURCE_ALREADY_SET', ASSET_SOURCE_MISSING = 'ASSET_SOURCE_MISSING', BAD_LOADER = 'BAD_LOADER', CANNOT_CALL_NAMESPACE = 'CANNOT_CALL_NAMESPACE', CANNOT_EMIT_FROM_OPTIONS_HOOK = 'CANNOT_EMIT_FROM_OPTIONS_HOOK', CHUNK_NOT_GENERATED = 'CHUNK_NOT_GENERATED', CHUNK_INVALID = 'CHUNK_INVALID', CIRCULAR_DEPENDENCY = 'CIRCULAR_DEPENDENCY', CIRCULAR_REEXPORT = 'CIRCULAR_REEXPORT', CYCLIC_CROSS_CHUNK_REEXPORT = 'CYCLIC_CROSS_CHUNK_REEXPORT', DEPRECATED_FEATURE = 'DEPRECATED_FEATURE', DUPLICATE_PLUGIN_NAME = 'DUPLICATE_PLUGIN_NAME', EMPTY_BUNDLE = 'EMPTY_BUNDLE', EVAL = 'EVAL', EXTERNAL_MODULES_CANNOT_BE_INCLUDED_IN_MANUAL_CHUNKS = 'EXTERNAL_MODULES_CANNOT_BE_INCLUDED_IN_MANUAL_CHUNKS', EXTERNAL_MODULES_CANNOT_BE_TRANSFORMED_TO_MODULES = 'EXTERNAL_MODULES_CANNOT_BE_TRANSFORMED_TO_MODULES', EXTERNAL_SYNTHETIC_EXPORTS = 'EXTERNAL_SYNTHETIC_EXPORTS', FILE_NAME_CONFLICT = 'FILE_NAME_CONFLICT', FILE_NOT_FOUND = 'FILE_NOT_FOUND', FIRST_SIDE_EFFECT = 'FIRST_SIDE_EFFECT', ILLEGAL_IDENTIFIER_AS_NAME = 'ILLEGAL_IDENTIFIER_AS_NAME', ILLEGAL_REASSIGNMENT = 'ILLEGAL_REASSIGNMENT', INCONSISTENT_IMPORT_ATTRIBUTES = 'INCONSISTENT_IMPORT_ATTRIBUTES', INVALID_ANNOTATION = 'INVALID_ANNOTATION', INPUT_HOOK_IN_OUTPUT_PLUGIN = 'INPUT_HOOK_IN_OUTPUT_PLUGIN', INVALID_CHUNK = 'INVALID_CHUNK', INVALID_EXPORT_OPTION = 'INVALID_EXPORT_OPTION', INVALID_EXTERNAL_ID = 'INVALID_EXTERNAL_ID', INVALID_IMPORT_ATTRIBUTE = 'INVALID_IMPORT_ATTRIBUTE', INVALID_LOG_POSITION = 'INVALID_LOG_POSITION', INVALID_OPTION = 'INVALID_OPTION', INVALID_PLUGIN_HOOK = 'INVALID_PLUGIN_HOOK', INVALID_ROLLUP_PHASE = 'INVALID_ROLLUP_PHASE', INVALID_SETASSETSOURCE = 'INVALID_SETASSETSOURCE', INVALID_TLA_FORMAT = 'INVALID_TLA_FORMAT', MISSING_EXPORT = 'MISSING_EXPORT', MISSING_GLOBAL_NAME = 'MISSING_GLOBAL_NAME', MISSING_IMPLICIT_DEPENDANT = 'MISSING_IMPLICIT_DEPENDANT', MISSING_NAME_OPTION_FOR_IIFE_EXPORT = 'MISSING_NAME_OPTION_FOR_IIFE_EXPORT', MISSING_NODE_BUILTINS = 'MISSING_NODE_BUILTINS', MISSING_OPTION = 'MISSING_OPTION', MIXED_EXPORTS = 'MIXED_EXPORTS', MODULE_LEVEL_DIRECTIVE = 'MODULE_LEVEL_DIRECTIVE', NAMESPACE_CONFLICT = 'NAMESPACE_CONFLICT', NO_TRANSFORM_MAP_OR_AST_WITHOUT_CODE = 'NO_TRANSFORM_MAP_OR_AST_WITHOUT_CODE', OPTIMIZE_CHUNK_STATUS = 'OPTIMIZE_CHUNK_STATUS', PARSE_ERROR = 'PARSE_ERROR', PLUGIN_ERROR = 'PLUGIN_ERROR', SHIMMED_EXPORT = 'SHIMMED_EXPORT', SOURCEMAP_BROKEN = 'SOURCEMAP_BROKEN', SOURCEMAP_ERROR = 'SOURCEMAP_ERROR', SYNTHETIC_NAMED_EXPORTS_NEED_NAMESPACE_EXPORT = 'SYNTHETIC_NAMED_EXPORTS_NEED_NAMESPACE_EXPORT', THIS_IS_UNDEFINED = 'THIS_IS_UNDEFINED', UNEXPECTED_NAMED_IMPORT = 'UNEXPECTED_NAMED_IMPORT', UNKNOWN_OPTION = 'UNKNOWN_OPTION', UNRESOLVED_ENTRY = 'UNRESOLVED_ENTRY', UNRESOLVED_IMPORT = 'UNRESOLVED_IMPORT', UNUSED_EXTERNAL_IMPORT = 'UNUSED_EXTERNAL_IMPORT', VALIDATION_ERROR = 'VALIDATION_ERROR';
2306
2307
  function logAddonNotGenerated(message, hook, plugin) {
2307
2308
  return {
2308
2309
  code: ADDON_ERROR,
@@ -2489,6 +2490,14 @@ const formatAttributes = (attributes) => {
2489
2490
  return 'no';
2490
2491
  return entries.map(([key, value]) => `"${key}": "${value}"`).join(', ');
2491
2492
  };
2493
+ function logInvalidAnnotation(comment, id, type) {
2494
+ return {
2495
+ code: INVALID_ANNOTATION,
2496
+ id,
2497
+ message: `A comment\n\n"${comment}"\n\nin "${relativeId(id)}" contains an annotation that Rollup cannot interpret due to the position of the comment. The comment will be removed to avoid issues.`,
2498
+ url: getRollupUrl(type === 'noSideEffects' ? URL_TREESHAKE_NOSIDEEFFECTS : URL_TREESHAKE_PURE)
2499
+ };
2500
+ }
2492
2501
  function logInputHookInOutputPlugin(pluginName, hookName) {
2493
2502
  return {
2494
2503
  code: INPUT_HOOK_IN_OUTPUT_PLUGIN,
@@ -6736,8 +6745,12 @@ class NodeBase extends ExpressionEntity {
6736
6745
  }
6737
6746
  }
6738
6747
  else if (key === INVALID_ANNOTATION_KEY) {
6739
- for (const { start, end } of value)
6748
+ for (const { start, end, type } of value) {
6740
6749
  this.context.magicString.remove(start, end);
6750
+ if (type === 'pure' || type === 'noSideEffects') {
6751
+ this.context.log(LOGLEVEL_WARN, logInvalidAnnotation(this.context.code.slice(start, end), this.context.module.id, type), start);
6752
+ }
6753
+ }
6741
6754
  }
6742
6755
  }
6743
6756
  else if (typeof value !== 'object' || value === null) {
@@ -9588,8 +9601,13 @@ class FunctionBase extends NodeBase {
9588
9601
  this.getObjectEntity().deoptimizePath(path);
9589
9602
  if (path.length === 1 && path[0] === UnknownKey) {
9590
9603
  // A reassignment of UNKNOWN_PATH is considered equivalent to having lost track
9591
- // which means the return expression needs to be reassigned
9604
+ // which means the return expression and parameters need to be reassigned
9592
9605
  this.scope.getReturnExpression().deoptimizePath(UNKNOWN_PATH);
9606
+ for (const parameterList of this.scope.parameters) {
9607
+ for (const parameter of parameterList) {
9608
+ parameter.deoptimizePath(UNKNOWN_PATH);
9609
+ }
9610
+ }
9593
9611
  }
9594
9612
  }
9595
9613
  getLiteralValueAtPath(path, recursionTracker, origin) {
@@ -13689,6 +13707,7 @@ class VariableDeclaration extends NodeBase {
13689
13707
  for (const { node, start, separator, contentEnd, end } of separatedNodes) {
13690
13708
  if (!node.included) {
13691
13709
  code.remove(start, end);
13710
+ node.removeAnnotations(code);
13692
13711
  continue;
13693
13712
  }
13694
13713
  node.render(code, options);
@@ -14833,6 +14852,14 @@ class Module {
14833
14852
  return { source, usesTopLevelAwait };
14834
14853
  }
14835
14854
  setSource({ ast, code, customTransformCache, originalCode, originalSourcemap, resolvedIds, sourcemapChain, transformDependencies, transformFiles, ...moduleOptions }) {
14855
+ if (code.startsWith('#!')) {
14856
+ const shebangEndPosition = code.indexOf('\n');
14857
+ this.shebang = code.slice(2, shebangEndPosition);
14858
+ }
14859
+ /* eslint-disable-next-line unicorn/number-literal-case */
14860
+ if (code.charCodeAt(0) === 65279) {
14861
+ code = code.slice(1);
14862
+ }
14836
14863
  timeStart('generate ast', 3);
14837
14864
  this.info.code = code;
14838
14865
  this.originalCode = originalCode;
@@ -16359,8 +16386,8 @@ function addStaticDependencies(module, staticDependencies, handledModules, chunk
16359
16386
  const hashPlaceholderLeft = '!~{';
16360
16387
  const hashPlaceholderRight = '}~';
16361
16388
  const hashPlaceholderOverhead = hashPlaceholderLeft.length + hashPlaceholderRight.length;
16362
- // This is the size of a sha256
16363
- const maxHashSize = 64;
16389
+ // This is the size of a 128-bits xxhash with base64url encoding
16390
+ const maxHashSize = 22;
16364
16391
  const defaultHashSize = 8;
16365
16392
  const getHashPlaceholderGenerator = () => {
16366
16393
  let nextIndex = 0;
@@ -16869,6 +16896,10 @@ class Chunk {
16869
16896
  }, outputOptions);
16870
16897
  if (banner)
16871
16898
  magicString.prepend(banner);
16899
+ if (format === 'es' || format === 'cjs') {
16900
+ const shebang = facadeModule !== null && facadeModule.info.isEntry && facadeModule.shebang;
16901
+ shebang && magicString.prepend(`#!${shebang}\n`);
16902
+ }
16872
16903
  if (footer)
16873
16904
  magicString.append(footer);
16874
16905
  return {
@@ -18447,7 +18478,23 @@ function collapseSourcemap(id, originalCode, originalSourcemap, sourcemapChain,
18447
18478
  return decodedSourcemap({ version: 3, ...map });
18448
18479
  }
18449
18480
 
18450
- const createHash = () => createHash$1('sha256');
18481
+ let textEncoder;
18482
+ function getXxhash(input) {
18483
+ let buffer;
18484
+ if (typeof input === 'string') {
18485
+ if (typeof Buffer === 'undefined') {
18486
+ textEncoder ??= new TextEncoder();
18487
+ buffer = textEncoder.encode(input);
18488
+ }
18489
+ else {
18490
+ buffer = Buffer.from(input);
18491
+ }
18492
+ }
18493
+ else {
18494
+ buffer = input;
18495
+ }
18496
+ return xxhashBase64Url(buffer);
18497
+ }
18451
18498
 
18452
18499
  // this looks ridiculous, but it prevents sourcemap tooling from mistaking
18453
18500
  // this for an actual sourceMappingURL
@@ -18564,7 +18611,7 @@ async function transformChunksAndGenerateContentHashes(renderedChunks, chunkGrap
18564
18611
  // To create a reproducible content-only hash, all placeholders are
18565
18612
  // replaced with the same value before hashing
18566
18613
  const { containedPlaceholders, transformedCode } = replacePlaceholdersWithDefaultAndGetContainedPlaceholders(code, placeholders);
18567
- const hash = createHash().update(transformedCode);
18614
+ let contentToHash = transformedCode;
18568
18615
  const hashAugmentation = pluginDriver.hookReduceValueSync('augmentChunkHash', '', [chunk.getRenderedChunkInfo()], (augmentation, pluginHash) => {
18569
18616
  if (pluginHash) {
18570
18617
  augmentation += pluginHash;
@@ -18572,12 +18619,12 @@ async function transformChunksAndGenerateContentHashes(renderedChunks, chunkGrap
18572
18619
  return augmentation;
18573
18620
  });
18574
18621
  if (hashAugmentation) {
18575
- hash.update(hashAugmentation);
18622
+ contentToHash += hashAugmentation;
18576
18623
  }
18577
18624
  renderedChunksByPlaceholder.set(hashPlaceholder, transformedChunk);
18578
18625
  hashDependenciesByPlaceholder.set(hashPlaceholder, {
18579
18626
  containedPlaceholders,
18580
- contentHash: hash.digest('hex')
18627
+ contentHash: getXxhash(contentToHash)
18581
18628
  });
18582
18629
  }
18583
18630
  else {
@@ -18585,10 +18632,7 @@ async function transformChunksAndGenerateContentHashes(renderedChunks, chunkGrap
18585
18632
  }
18586
18633
  const sourcemapHashPlaceholder = preliminarySourcemapFileName?.hashPlaceholder;
18587
18634
  if (map && sourcemapHashPlaceholder) {
18588
- initialHashesByPlaceholder.set(preliminarySourcemapFileName.hashPlaceholder, createHash()
18589
- .update(map.toString())
18590
- .digest('hex')
18591
- .slice(0, preliminarySourcemapFileName.hashPlaceholder.length));
18635
+ initialHashesByPlaceholder.set(preliminarySourcemapFileName.hashPlaceholder, getXxhash(map.toString()).slice(0, preliminarySourcemapFileName.hashPlaceholder.length));
18592
18636
  }
18593
18637
  }));
18594
18638
  return {
@@ -18601,11 +18645,11 @@ async function transformChunksAndGenerateContentHashes(renderedChunks, chunkGrap
18601
18645
  function generateFinalHashes(renderedChunksByPlaceholder, hashDependenciesByPlaceholder, initialHashesByPlaceholder, bundle) {
18602
18646
  const hashesByPlaceholder = new Map(initialHashesByPlaceholder);
18603
18647
  for (const [placeholder, { fileName }] of renderedChunksByPlaceholder) {
18604
- let hash = createHash();
18648
+ let contentToHash = '';
18605
18649
  const hashDependencyPlaceholders = new Set([placeholder]);
18606
18650
  for (const dependencyPlaceholder of hashDependencyPlaceholders) {
18607
18651
  const { containedPlaceholders, contentHash } = hashDependenciesByPlaceholder.get(dependencyPlaceholder);
18608
- hash.update(contentHash);
18652
+ contentToHash += contentHash;
18609
18653
  for (const containedPlaceholder of containedPlaceholders) {
18610
18654
  // When looping over a map, setting an entry only causes a new iteration if the key is new
18611
18655
  hashDependencyPlaceholders.add(containedPlaceholder);
@@ -18616,9 +18660,9 @@ function generateFinalHashes(renderedChunksByPlaceholder, hashDependenciesByPlac
18616
18660
  do {
18617
18661
  // In case of a hash collision, create a hash of the hash
18618
18662
  if (finalHash) {
18619
- hash = createHash().update(finalHash);
18663
+ contentToHash = finalHash;
18620
18664
  }
18621
- finalHash = hash.digest('hex').slice(0, placeholder.length);
18665
+ finalHash = getXxhash(contentToHash).slice(0, placeholder.length);
18622
18666
  finalFileName = replaceSinglePlaceholder(fileName, placeholder, finalHash);
18623
18667
  } while (bundle[lowercaseBundleKeys].has(finalFileName.toLowerCase()));
18624
18668
  bundle[finalFileName] = FILE_PLACEHOLDER;
@@ -19765,9 +19809,6 @@ class GlobalScope extends Scope {
19765
19809
  }
19766
19810
  }
19767
19811
 
19768
- function getSourceHash(source) {
19769
- return createHash().update(source).digest('hex');
19770
- }
19771
19812
  function generateAssetFileName(name, source, sourceHash, outputOptions, bundle) {
19772
19813
  const emittedName = outputOptions.sanitizeFileName(name || 'asset');
19773
19814
  return makeUnique(renderNamePattern(typeof outputOptions.assetFileNames === 'function'
@@ -19901,7 +19942,7 @@ class FileEmitter {
19901
19942
  this.finalizeAdditionalAsset(consumedFile, consumedFile.source, output);
19902
19943
  }
19903
19944
  else {
19904
- const sourceHash = getSourceHash(consumedFile.source);
19945
+ const sourceHash = getXxhash(consumedFile.source);
19905
19946
  getOrCreate(consumedAssetsByHash, sourceHash, () => []).push(consumedFile);
19906
19947
  }
19907
19948
  }
@@ -19924,7 +19965,7 @@ class FileEmitter {
19924
19965
  assignReferenceId(file, idBase) {
19925
19966
  let referenceId = idBase;
19926
19967
  do {
19927
- referenceId = createHash().update(referenceId).digest('hex').slice(0, 8);
19968
+ referenceId = getXxhash(referenceId).slice(0, 8).replaceAll('-', '$');
19928
19969
  } while (this.filesByReferenceId.has(referenceId) ||
19929
19970
  this.outputFileEmitters.some(({ filesByReferenceId }) => filesByReferenceId.has(referenceId)));
19930
19971
  file.referenceId = referenceId;
@@ -20039,7 +20080,7 @@ class FileEmitter {
20039
20080
  let { fileName, needsCodeReference, referenceId } = consumedFile;
20040
20081
  // Deduplicate assets if an explicit fileName is not provided
20041
20082
  if (!fileName) {
20042
- const sourceHash = getSourceHash(source);
20083
+ const sourceHash = getXxhash(source);
20043
20084
  fileName = fileNamesBySource.get(sourceHash);
20044
20085
  if (!fileName) {
20045
20086
  fileName = generateAssetFileName(consumedFile.name, source, sourceHash, outputOptions, bundle);
@@ -20545,7 +20586,7 @@ class Graph {
20545
20586
  this.phase = BuildPhase.GENERATE;
20546
20587
  }
20547
20588
  contextParse(code, { allowReturnOutsideFunction = false } = {}) {
20548
- const astBuffer = native.parse(code, allowReturnOutsideFunction);
20589
+ const astBuffer = parse$2(code, allowReturnOutsideFunction);
20549
20590
  const readString = getReadStringFunction(astBuffer);
20550
20591
  return convertProgram(astBuffer.buffer, readString);
20551
20592
  }
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v4.0.0-22
4
- Tue, 26 Sep 2023 16:16:00 GMT - commit 38be49cf19099321f935c1ad5968e76fb30e0957
3
+ Rollup.js v4.0.0-24
4
+ Tue, 03 Oct 2023 05:11:52 GMT - commit ced077f2920c473c4c2ca31a8d72b259bec91f67
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -18,7 +18,6 @@ import require$$0$2 from 'path';
18
18
  import require$$2$1 from 'os';
19
19
  import require$$0$3 from 'events';
20
20
  import 'node:perf_hooks';
21
- import 'node:crypto';
22
21
  import '../../native.js';
23
22
  import 'node:fs/promises';
24
23
  import 'tty';
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v4.0.0-22
4
- Tue, 26 Sep 2023 16:16:00 GMT - commit 38be49cf19099321f935c1ad5968e76fb30e0957
3
+ Rollup.js v4.0.0-24
4
+ Tue, 03 Oct 2023 05:11:52 GMT - commit ced077f2920c473c4c2ca31a8d72b259bec91f67
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v4.0.0-22
4
- Tue, 26 Sep 2023 16:16:00 GMT - commit 38be49cf19099321f935c1ad5968e76fb30e0957
3
+ Rollup.js v4.0.0-24
4
+ Tue, 03 Oct 2023 05:11:52 GMT - commit ced077f2920c473c4c2ca31a8d72b259bec91f67
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -20,7 +20,6 @@ const loadConfigFile_js = require('./shared/loadConfigFile.js');
20
20
  require('tty');
21
21
  require('path');
22
22
  require('node:perf_hooks');
23
- require('node:crypto');
24
23
  require('./native.js');
25
24
  require('./getLogFilter.js');
26
25
 
package/dist/native.js CHANGED
@@ -252,6 +252,7 @@ if (!nativeBinding) {
252
252
  throw new Error(`Failed to load native binding`)
253
253
  }
254
254
 
255
- const { parse } = nativeBinding
255
+ const { parse, xxhashBase64Url } = nativeBinding
256
256
 
257
257
  module.exports.parse = parse
258
+ module.exports.xxhashBase64Url = xxhashBase64Url
package/dist/rollup.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v4.0.0-22
4
- Tue, 26 Sep 2023 16:16:00 GMT - commit 38be49cf19099321f935c1ad5968e76fb30e0957
3
+ Rollup.js v4.0.0-24
4
+ Tue, 03 Oct 2023 05:11:52 GMT - commit ced077f2920c473c4c2ca31a8d72b259bec91f67
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -18,7 +18,6 @@ require('tty');
18
18
  require('node:path');
19
19
  require('path');
20
20
  require('node:perf_hooks');
21
- require('node:crypto');
22
21
  require('./native.js');
23
22
  require('node:fs/promises');
24
23
  require('./shared/fsevents-importer.js');
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v4.0.0-22
4
- Tue, 26 Sep 2023 16:16:00 GMT - commit 38be49cf19099321f935c1ad5968e76fb30e0957
3
+ Rollup.js v4.0.0-24
4
+ Tue, 03 Oct 2023 05:11:52 GMT - commit ced077f2920c473c4c2ca31a8d72b259bec91f67
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v4.0.0-22
4
- Tue, 26 Sep 2023 16:16:00 GMT - commit 38be49cf19099321f935c1ad5968e76fb30e0957
3
+ Rollup.js v4.0.0-24
4
+ Tue, 03 Oct 2023 05:11:52 GMT - commit ced077f2920c473c4c2ca31a8d72b259bec91f67
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v4.0.0-22
4
- Tue, 26 Sep 2023 16:16:00 GMT - commit 38be49cf19099321f935c1ad5968e76fb30e0957
3
+ Rollup.js v4.0.0-24
4
+ Tue, 03 Oct 2023 05:11:52 GMT - commit ced077f2920c473c4c2ca31a8d72b259bec91f67
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v4.0.0-22
4
- Tue, 26 Sep 2023 16:16:00 GMT - commit 38be49cf19099321f935c1ad5968e76fb30e0957
3
+ Rollup.js v4.0.0-24
4
+ Tue, 03 Oct 2023 05:11:52 GMT - commit ced077f2920c473c4c2ca31a8d72b259bec91f67
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -14,8 +14,7 @@ const tty = require('tty');
14
14
  const node_path = require('node:path');
15
15
  const require$$0$1 = require('path');
16
16
  const node_perf_hooks = require('node:perf_hooks');
17
- const node_crypto = require('node:crypto');
18
- const native = require('../native.js');
17
+ const native_js = require('../native.js');
19
18
  const promises = require('node:fs/promises');
20
19
 
21
20
  function _interopNamespaceDefault(e) {
@@ -31,7 +30,7 @@ function _interopNamespaceDefault(e) {
31
30
 
32
31
  const tty__namespace = /*#__PURE__*/_interopNamespaceDefault(tty);
33
32
 
34
- var version = "4.0.0-22";
33
+ var version = "4.0.0-24";
35
34
 
36
35
  function ensureArray$1(items) {
37
36
  if (Array.isArray(items)) {
@@ -50,7 +49,23 @@ var BuildPhase;
50
49
  BuildPhase[BuildPhase["GENERATE"] = 2] = "GENERATE";
51
50
  })(BuildPhase || (BuildPhase = {}));
52
51
 
53
- const createHash = () => node_crypto.createHash('sha256');
52
+ let textEncoder;
53
+ function getXxhash(input) {
54
+ let buffer;
55
+ if (typeof input === 'string') {
56
+ if (typeof Buffer === 'undefined') {
57
+ textEncoder ??= new TextEncoder();
58
+ buffer = textEncoder.encode(input);
59
+ }
60
+ else {
61
+ buffer = Buffer.from(input);
62
+ }
63
+ }
64
+ else {
65
+ buffer = input;
66
+ }
67
+ return native_js.xxhashBase64Url(buffer);
68
+ }
54
69
 
55
70
  function getOrCreate(map, key, init) {
56
71
  const existing = map.get(key);
@@ -334,6 +349,8 @@ const URL_OUTPUT_SOURCEMAPBASEURL = 'configuration-options/#output-sourcemapbase
334
349
  const URL_OUTPUT_SOURCEMAPFILE = 'configuration-options/#output-sourcemapfile';
335
350
  const URL_PRESERVEENTRYSIGNATURES = 'configuration-options/#preserveentrysignatures';
336
351
  const URL_TREESHAKE = 'configuration-options/#treeshake';
352
+ const URL_TREESHAKE_PURE = 'configuration-options/#pure';
353
+ const URL_TREESHAKE_NOSIDEEFFECTS = 'configuration-options/#no-side-effects';
337
354
  const URL_TREESHAKE_MODULESIDEEFFECTS = 'configuration-options/#treeshake-modulesideeffects';
338
355
  const URL_WATCH = 'configuration-options/#watch';
339
356
  // command-line-interface
@@ -368,7 +385,7 @@ function augmentCodeLocation(properties, pos, source, id) {
368
385
  }
369
386
  // Error codes should be sorted alphabetically while errors should be sorted by
370
387
  // error code below
371
- const ADDON_ERROR = 'ADDON_ERROR', ALREADY_CLOSED = 'ALREADY_CLOSED', AMBIGUOUS_EXTERNAL_NAMESPACES = 'AMBIGUOUS_EXTERNAL_NAMESPACES', ANONYMOUS_PLUGIN_CACHE = 'ANONYMOUS_PLUGIN_CACHE', ASSET_NOT_FINALISED = 'ASSET_NOT_FINALISED', ASSET_NOT_FOUND = 'ASSET_NOT_FOUND', ASSET_SOURCE_ALREADY_SET = 'ASSET_SOURCE_ALREADY_SET', ASSET_SOURCE_MISSING = 'ASSET_SOURCE_MISSING', BAD_LOADER = 'BAD_LOADER', CANNOT_CALL_NAMESPACE = 'CANNOT_CALL_NAMESPACE', CANNOT_EMIT_FROM_OPTIONS_HOOK = 'CANNOT_EMIT_FROM_OPTIONS_HOOK', CHUNK_NOT_GENERATED = 'CHUNK_NOT_GENERATED', CHUNK_INVALID = 'CHUNK_INVALID', CIRCULAR_DEPENDENCY = 'CIRCULAR_DEPENDENCY', CIRCULAR_REEXPORT = 'CIRCULAR_REEXPORT', CYCLIC_CROSS_CHUNK_REEXPORT = 'CYCLIC_CROSS_CHUNK_REEXPORT', DEPRECATED_FEATURE = 'DEPRECATED_FEATURE', DUPLICATE_IMPORT_OPTIONS = 'DUPLICATE_IMPORT_OPTIONS', DUPLICATE_PLUGIN_NAME = 'DUPLICATE_PLUGIN_NAME', EMPTY_BUNDLE = 'EMPTY_BUNDLE', EVAL = 'EVAL', EXTERNAL_MODULES_CANNOT_BE_INCLUDED_IN_MANUAL_CHUNKS = 'EXTERNAL_MODULES_CANNOT_BE_INCLUDED_IN_MANUAL_CHUNKS', EXTERNAL_MODULES_CANNOT_BE_TRANSFORMED_TO_MODULES = 'EXTERNAL_MODULES_CANNOT_BE_TRANSFORMED_TO_MODULES', EXTERNAL_SYNTHETIC_EXPORTS = 'EXTERNAL_SYNTHETIC_EXPORTS', FAIL_AFTER_WARNINGS = 'FAIL_AFTER_WARNINGS', FILE_NAME_CONFLICT = 'FILE_NAME_CONFLICT', FILE_NOT_FOUND = 'FILE_NOT_FOUND', FIRST_SIDE_EFFECT = 'FIRST_SIDE_EFFECT', ILLEGAL_IDENTIFIER_AS_NAME = 'ILLEGAL_IDENTIFIER_AS_NAME', ILLEGAL_REASSIGNMENT = 'ILLEGAL_REASSIGNMENT', INCONSISTENT_IMPORT_ATTRIBUTES = 'INCONSISTENT_IMPORT_ATTRIBUTES', INPUT_HOOK_IN_OUTPUT_PLUGIN = 'INPUT_HOOK_IN_OUTPUT_PLUGIN', INVALID_CHUNK = 'INVALID_CHUNK', INVALID_CONFIG_MODULE_FORMAT = 'INVALID_CONFIG_MODULE_FORMAT', INVALID_EXPORT_OPTION = 'INVALID_EXPORT_OPTION', INVALID_EXTERNAL_ID = 'INVALID_EXTERNAL_ID', INVALID_IMPORT_ATTRIBUTE = 'INVALID_IMPORT_ATTRIBUTE', INVALID_LOG_POSITION = 'INVALID_LOG_POSITION', INVALID_OPTION = 'INVALID_OPTION', INVALID_PLUGIN_HOOK = 'INVALID_PLUGIN_HOOK', INVALID_ROLLUP_PHASE = 'INVALID_ROLLUP_PHASE', INVALID_SETASSETSOURCE = 'INVALID_SETASSETSOURCE', INVALID_TLA_FORMAT = 'INVALID_TLA_FORMAT', MISSING_CONFIG = 'MISSING_CONFIG', MISSING_EXPORT = 'MISSING_EXPORT', MISSING_EXTERNAL_CONFIG = 'MISSING_EXTERNAL_CONFIG', MISSING_GLOBAL_NAME = 'MISSING_GLOBAL_NAME', MISSING_IMPLICIT_DEPENDANT = 'MISSING_IMPLICIT_DEPENDANT', MISSING_NAME_OPTION_FOR_IIFE_EXPORT = 'MISSING_NAME_OPTION_FOR_IIFE_EXPORT', MISSING_NODE_BUILTINS = 'MISSING_NODE_BUILTINS', MISSING_OPTION = 'MISSING_OPTION', MIXED_EXPORTS = 'MIXED_EXPORTS', MODULE_LEVEL_DIRECTIVE = 'MODULE_LEVEL_DIRECTIVE', NAMESPACE_CONFLICT = 'NAMESPACE_CONFLICT', NO_TRANSFORM_MAP_OR_AST_WITHOUT_CODE = 'NO_TRANSFORM_MAP_OR_AST_WITHOUT_CODE', ONLY_INLINE_SOURCEMAPS = 'ONLY_INLINE_SOURCEMAPS', OPTIMIZE_CHUNK_STATUS = 'OPTIMIZE_CHUNK_STATUS', PARSE_ERROR = 'PARSE_ERROR', PLUGIN_ERROR = 'PLUGIN_ERROR', SHIMMED_EXPORT = 'SHIMMED_EXPORT', SOURCEMAP_BROKEN = 'SOURCEMAP_BROKEN', SOURCEMAP_ERROR = 'SOURCEMAP_ERROR', SYNTHETIC_NAMED_EXPORTS_NEED_NAMESPACE_EXPORT = 'SYNTHETIC_NAMED_EXPORTS_NEED_NAMESPACE_EXPORT', THIS_IS_UNDEFINED = 'THIS_IS_UNDEFINED', UNEXPECTED_NAMED_IMPORT = 'UNEXPECTED_NAMED_IMPORT', UNKNOWN_OPTION = 'UNKNOWN_OPTION', UNRESOLVED_ENTRY = 'UNRESOLVED_ENTRY', UNRESOLVED_IMPORT = 'UNRESOLVED_IMPORT', UNUSED_EXTERNAL_IMPORT = 'UNUSED_EXTERNAL_IMPORT', VALIDATION_ERROR = 'VALIDATION_ERROR';
388
+ const ADDON_ERROR = 'ADDON_ERROR', ALREADY_CLOSED = 'ALREADY_CLOSED', AMBIGUOUS_EXTERNAL_NAMESPACES = 'AMBIGUOUS_EXTERNAL_NAMESPACES', ANONYMOUS_PLUGIN_CACHE = 'ANONYMOUS_PLUGIN_CACHE', ASSET_NOT_FINALISED = 'ASSET_NOT_FINALISED', ASSET_NOT_FOUND = 'ASSET_NOT_FOUND', ASSET_SOURCE_ALREADY_SET = 'ASSET_SOURCE_ALREADY_SET', ASSET_SOURCE_MISSING = 'ASSET_SOURCE_MISSING', BAD_LOADER = 'BAD_LOADER', CANNOT_CALL_NAMESPACE = 'CANNOT_CALL_NAMESPACE', CANNOT_EMIT_FROM_OPTIONS_HOOK = 'CANNOT_EMIT_FROM_OPTIONS_HOOK', CHUNK_NOT_GENERATED = 'CHUNK_NOT_GENERATED', CHUNK_INVALID = 'CHUNK_INVALID', CIRCULAR_DEPENDENCY = 'CIRCULAR_DEPENDENCY', CIRCULAR_REEXPORT = 'CIRCULAR_REEXPORT', CYCLIC_CROSS_CHUNK_REEXPORT = 'CYCLIC_CROSS_CHUNK_REEXPORT', DEPRECATED_FEATURE = 'DEPRECATED_FEATURE', DUPLICATE_IMPORT_OPTIONS = 'DUPLICATE_IMPORT_OPTIONS', DUPLICATE_PLUGIN_NAME = 'DUPLICATE_PLUGIN_NAME', EMPTY_BUNDLE = 'EMPTY_BUNDLE', EVAL = 'EVAL', EXTERNAL_MODULES_CANNOT_BE_INCLUDED_IN_MANUAL_CHUNKS = 'EXTERNAL_MODULES_CANNOT_BE_INCLUDED_IN_MANUAL_CHUNKS', EXTERNAL_MODULES_CANNOT_BE_TRANSFORMED_TO_MODULES = 'EXTERNAL_MODULES_CANNOT_BE_TRANSFORMED_TO_MODULES', EXTERNAL_SYNTHETIC_EXPORTS = 'EXTERNAL_SYNTHETIC_EXPORTS', FAIL_AFTER_WARNINGS = 'FAIL_AFTER_WARNINGS', FILE_NAME_CONFLICT = 'FILE_NAME_CONFLICT', FILE_NOT_FOUND = 'FILE_NOT_FOUND', FIRST_SIDE_EFFECT = 'FIRST_SIDE_EFFECT', ILLEGAL_IDENTIFIER_AS_NAME = 'ILLEGAL_IDENTIFIER_AS_NAME', ILLEGAL_REASSIGNMENT = 'ILLEGAL_REASSIGNMENT', INCONSISTENT_IMPORT_ATTRIBUTES = 'INCONSISTENT_IMPORT_ATTRIBUTES', INVALID_ANNOTATION = 'INVALID_ANNOTATION', INPUT_HOOK_IN_OUTPUT_PLUGIN = 'INPUT_HOOK_IN_OUTPUT_PLUGIN', INVALID_CHUNK = 'INVALID_CHUNK', INVALID_CONFIG_MODULE_FORMAT = 'INVALID_CONFIG_MODULE_FORMAT', INVALID_EXPORT_OPTION = 'INVALID_EXPORT_OPTION', INVALID_EXTERNAL_ID = 'INVALID_EXTERNAL_ID', INVALID_IMPORT_ATTRIBUTE = 'INVALID_IMPORT_ATTRIBUTE', INVALID_LOG_POSITION = 'INVALID_LOG_POSITION', INVALID_OPTION = 'INVALID_OPTION', INVALID_PLUGIN_HOOK = 'INVALID_PLUGIN_HOOK', INVALID_ROLLUP_PHASE = 'INVALID_ROLLUP_PHASE', INVALID_SETASSETSOURCE = 'INVALID_SETASSETSOURCE', INVALID_TLA_FORMAT = 'INVALID_TLA_FORMAT', MISSING_CONFIG = 'MISSING_CONFIG', MISSING_EXPORT = 'MISSING_EXPORT', MISSING_EXTERNAL_CONFIG = 'MISSING_EXTERNAL_CONFIG', MISSING_GLOBAL_NAME = 'MISSING_GLOBAL_NAME', MISSING_IMPLICIT_DEPENDANT = 'MISSING_IMPLICIT_DEPENDANT', MISSING_NAME_OPTION_FOR_IIFE_EXPORT = 'MISSING_NAME_OPTION_FOR_IIFE_EXPORT', MISSING_NODE_BUILTINS = 'MISSING_NODE_BUILTINS', MISSING_OPTION = 'MISSING_OPTION', MIXED_EXPORTS = 'MIXED_EXPORTS', MODULE_LEVEL_DIRECTIVE = 'MODULE_LEVEL_DIRECTIVE', NAMESPACE_CONFLICT = 'NAMESPACE_CONFLICT', NO_TRANSFORM_MAP_OR_AST_WITHOUT_CODE = 'NO_TRANSFORM_MAP_OR_AST_WITHOUT_CODE', ONLY_INLINE_SOURCEMAPS = 'ONLY_INLINE_SOURCEMAPS', OPTIMIZE_CHUNK_STATUS = 'OPTIMIZE_CHUNK_STATUS', PARSE_ERROR = 'PARSE_ERROR', PLUGIN_ERROR = 'PLUGIN_ERROR', SHIMMED_EXPORT = 'SHIMMED_EXPORT', SOURCEMAP_BROKEN = 'SOURCEMAP_BROKEN', SOURCEMAP_ERROR = 'SOURCEMAP_ERROR', SYNTHETIC_NAMED_EXPORTS_NEED_NAMESPACE_EXPORT = 'SYNTHETIC_NAMED_EXPORTS_NEED_NAMESPACE_EXPORT', THIS_IS_UNDEFINED = 'THIS_IS_UNDEFINED', UNEXPECTED_NAMED_IMPORT = 'UNEXPECTED_NAMED_IMPORT', UNKNOWN_OPTION = 'UNKNOWN_OPTION', UNRESOLVED_ENTRY = 'UNRESOLVED_ENTRY', UNRESOLVED_IMPORT = 'UNRESOLVED_IMPORT', UNUSED_EXTERNAL_IMPORT = 'UNUSED_EXTERNAL_IMPORT', VALIDATION_ERROR = 'VALIDATION_ERROR';
372
389
  function logAddonNotGenerated(message, hook, plugin) {
373
390
  return {
374
391
  code: ADDON_ERROR,
@@ -567,6 +584,14 @@ const formatAttributes$1 = (attributes) => {
567
584
  return 'no';
568
585
  return entries.map(([key, value]) => `"${key}": "${value}"`).join(', ');
569
586
  };
587
+ function logInvalidAnnotation(comment, id, type) {
588
+ return {
589
+ code: INVALID_ANNOTATION,
590
+ id,
591
+ message: `A comment\n\n"${comment}"\n\nin "${relativeId(id)}" contains an annotation that Rollup cannot interpret due to the position of the comment. The comment will be removed to avoid issues.`,
592
+ url: getRollupUrl(type === 'noSideEffects' ? URL_TREESHAKE_NOSIDEEFFECTS : URL_TREESHAKE_PURE)
593
+ };
594
+ }
570
595
  function logInputHookInOutputPlugin(pluginName, hookName) {
571
596
  return {
572
597
  code: INPUT_HOOK_IN_OUTPUT_PLUGIN,
@@ -1004,8 +1029,8 @@ function warnDeprecationWithOptions(deprecation, urlSnippet, activeDeprecation,
1004
1029
  const hashPlaceholderLeft = '!~{';
1005
1030
  const hashPlaceholderRight = '}~';
1006
1031
  const hashPlaceholderOverhead = hashPlaceholderLeft.length + hashPlaceholderRight.length;
1007
- // This is the size of a sha256
1008
- const maxHashSize = 64;
1032
+ // This is the size of a 128-bits xxhash with base64url encoding
1033
+ const maxHashSize = 22;
1009
1034
  const defaultHashSize = 8;
1010
1035
  const getHashPlaceholderGenerator = () => {
1011
1036
  let nextIndex = 0;
@@ -1104,9 +1129,6 @@ function makeUnique(name, { [lowercaseBundleKeys]: reservedLowercaseBundleKeys }
1104
1129
  return uniqueName;
1105
1130
  }
1106
1131
 
1107
- function getSourceHash(source) {
1108
- return createHash().update(source).digest('hex');
1109
- }
1110
1132
  function generateAssetFileName(name, source, sourceHash, outputOptions, bundle) {
1111
1133
  const emittedName = outputOptions.sanitizeFileName(name || 'asset');
1112
1134
  return makeUnique(renderNamePattern(typeof outputOptions.assetFileNames === 'function'
@@ -1240,7 +1262,7 @@ class FileEmitter {
1240
1262
  this.finalizeAdditionalAsset(consumedFile, consumedFile.source, output);
1241
1263
  }
1242
1264
  else {
1243
- const sourceHash = getSourceHash(consumedFile.source);
1265
+ const sourceHash = getXxhash(consumedFile.source);
1244
1266
  getOrCreate(consumedAssetsByHash, sourceHash, () => []).push(consumedFile);
1245
1267
  }
1246
1268
  }
@@ -1263,7 +1285,7 @@ class FileEmitter {
1263
1285
  assignReferenceId(file, idBase) {
1264
1286
  let referenceId = idBase;
1265
1287
  do {
1266
- referenceId = createHash().update(referenceId).digest('hex').slice(0, 8);
1288
+ referenceId = getXxhash(referenceId).slice(0, 8).replaceAll('-', '$');
1267
1289
  } while (this.filesByReferenceId.has(referenceId) ||
1268
1290
  this.outputFileEmitters.some(({ filesByReferenceId }) => filesByReferenceId.has(referenceId)));
1269
1291
  file.referenceId = referenceId;
@@ -1378,7 +1400,7 @@ class FileEmitter {
1378
1400
  let { fileName, needsCodeReference, referenceId } = consumedFile;
1379
1401
  // Deduplicate assets if an explicit fileName is not provided
1380
1402
  if (!fileName) {
1381
- const sourceHash = getSourceHash(source);
1403
+ const sourceHash = getXxhash(source);
1382
1404
  fileName = fileNamesBySource.get(sourceHash);
1383
1405
  if (!fileName) {
1384
1406
  fileName = generateAssetFileName(consumedFile.name, source, sourceHash, outputOptions, bundle);
@@ -8232,8 +8254,12 @@ class NodeBase extends ExpressionEntity {
8232
8254
  }
8233
8255
  }
8234
8256
  else if (key === INVALID_ANNOTATION_KEY) {
8235
- for (const { start, end } of value)
8257
+ for (const { start, end, type } of value) {
8236
8258
  this.context.magicString.remove(start, end);
8259
+ if (type === 'pure' || type === 'noSideEffects') {
8260
+ this.context.log(LOGLEVEL_WARN, logInvalidAnnotation(this.context.code.slice(start, end), this.context.module.id, type), start);
8261
+ }
8262
+ }
8237
8263
  }
8238
8264
  }
8239
8265
  else if (typeof value !== 'object' || value === null) {
@@ -11070,8 +11096,13 @@ class FunctionBase extends NodeBase {
11070
11096
  this.getObjectEntity().deoptimizePath(path);
11071
11097
  if (path.length === 1 && path[0] === UnknownKey) {
11072
11098
  // A reassignment of UNKNOWN_PATH is considered equivalent to having lost track
11073
- // which means the return expression needs to be reassigned
11099
+ // which means the return expression and parameters need to be reassigned
11074
11100
  this.scope.getReturnExpression().deoptimizePath(UNKNOWN_PATH);
11101
+ for (const parameterList of this.scope.parameters) {
11102
+ for (const parameter of parameterList) {
11103
+ parameter.deoptimizePath(UNKNOWN_PATH);
11104
+ }
11105
+ }
11075
11106
  }
11076
11107
  }
11077
11108
  getLiteralValueAtPath(path, recursionTracker, origin) {
@@ -15171,6 +15202,7 @@ class VariableDeclaration extends NodeBase {
15171
15202
  for (const { node, start, separator, contentEnd, end } of separatedNodes) {
15172
15203
  if (!node.included) {
15173
15204
  code.remove(start, end);
15205
+ node.removeAnnotations(code);
15174
15206
  continue;
15175
15207
  }
15176
15208
  node.render(code, options);
@@ -16308,6 +16340,14 @@ class Module {
16308
16340
  return { source, usesTopLevelAwait };
16309
16341
  }
16310
16342
  setSource({ ast, code, customTransformCache, originalCode, originalSourcemap, resolvedIds, sourcemapChain, transformDependencies, transformFiles, ...moduleOptions }) {
16343
+ if (code.startsWith('#!')) {
16344
+ const shebangEndPosition = code.indexOf('\n');
16345
+ this.shebang = code.slice(2, shebangEndPosition);
16346
+ }
16347
+ /* eslint-disable-next-line unicorn/number-literal-case */
16348
+ if (code.charCodeAt(0) === 65279) {
16349
+ code = code.slice(1);
16350
+ }
16311
16351
  timeStart('generate ast', 3);
16312
16352
  this.info.code = code;
16313
16353
  this.originalCode = originalCode;
@@ -18239,6 +18279,10 @@ class Chunk {
18239
18279
  }, outputOptions);
18240
18280
  if (banner)
18241
18281
  magicString.prepend(banner);
18282
+ if (format === 'es' || format === 'cjs') {
18283
+ const shebang = facadeModule !== null && facadeModule.info.isEntry && facadeModule.shebang;
18284
+ shebang && magicString.prepend(`#!${shebang}\n`);
18285
+ }
18242
18286
  if (footer)
18243
18287
  magicString.append(footer);
18244
18288
  return {
@@ -19932,7 +19976,7 @@ async function transformChunksAndGenerateContentHashes(renderedChunks, chunkGrap
19932
19976
  // To create a reproducible content-only hash, all placeholders are
19933
19977
  // replaced with the same value before hashing
19934
19978
  const { containedPlaceholders, transformedCode } = replacePlaceholdersWithDefaultAndGetContainedPlaceholders(code, placeholders);
19935
- const hash = createHash().update(transformedCode);
19979
+ let contentToHash = transformedCode;
19936
19980
  const hashAugmentation = pluginDriver.hookReduceValueSync('augmentChunkHash', '', [chunk.getRenderedChunkInfo()], (augmentation, pluginHash) => {
19937
19981
  if (pluginHash) {
19938
19982
  augmentation += pluginHash;
@@ -19940,12 +19984,12 @@ async function transformChunksAndGenerateContentHashes(renderedChunks, chunkGrap
19940
19984
  return augmentation;
19941
19985
  });
19942
19986
  if (hashAugmentation) {
19943
- hash.update(hashAugmentation);
19987
+ contentToHash += hashAugmentation;
19944
19988
  }
19945
19989
  renderedChunksByPlaceholder.set(hashPlaceholder, transformedChunk);
19946
19990
  hashDependenciesByPlaceholder.set(hashPlaceholder, {
19947
19991
  containedPlaceholders,
19948
- contentHash: hash.digest('hex')
19992
+ contentHash: getXxhash(contentToHash)
19949
19993
  });
19950
19994
  }
19951
19995
  else {
@@ -19953,10 +19997,7 @@ async function transformChunksAndGenerateContentHashes(renderedChunks, chunkGrap
19953
19997
  }
19954
19998
  const sourcemapHashPlaceholder = preliminarySourcemapFileName?.hashPlaceholder;
19955
19999
  if (map && sourcemapHashPlaceholder) {
19956
- initialHashesByPlaceholder.set(preliminarySourcemapFileName.hashPlaceholder, createHash()
19957
- .update(map.toString())
19958
- .digest('hex')
19959
- .slice(0, preliminarySourcemapFileName.hashPlaceholder.length));
20000
+ initialHashesByPlaceholder.set(preliminarySourcemapFileName.hashPlaceholder, getXxhash(map.toString()).slice(0, preliminarySourcemapFileName.hashPlaceholder.length));
19960
20001
  }
19961
20002
  }));
19962
20003
  return {
@@ -19969,11 +20010,11 @@ async function transformChunksAndGenerateContentHashes(renderedChunks, chunkGrap
19969
20010
  function generateFinalHashes(renderedChunksByPlaceholder, hashDependenciesByPlaceholder, initialHashesByPlaceholder, bundle) {
19970
20011
  const hashesByPlaceholder = new Map(initialHashesByPlaceholder);
19971
20012
  for (const [placeholder, { fileName }] of renderedChunksByPlaceholder) {
19972
- let hash = createHash();
20013
+ let contentToHash = '';
19973
20014
  const hashDependencyPlaceholders = new Set([placeholder]);
19974
20015
  for (const dependencyPlaceholder of hashDependencyPlaceholders) {
19975
20016
  const { containedPlaceholders, contentHash } = hashDependenciesByPlaceholder.get(dependencyPlaceholder);
19976
- hash.update(contentHash);
20017
+ contentToHash += contentHash;
19977
20018
  for (const containedPlaceholder of containedPlaceholders) {
19978
20019
  // When looping over a map, setting an entry only causes a new iteration if the key is new
19979
20020
  hashDependencyPlaceholders.add(containedPlaceholder);
@@ -19984,9 +20025,9 @@ function generateFinalHashes(renderedChunksByPlaceholder, hashDependenciesByPlac
19984
20025
  do {
19985
20026
  // In case of a hash collision, create a hash of the hash
19986
20027
  if (finalHash) {
19987
- hash = createHash().update(finalHash);
20028
+ contentToHash = finalHash;
19988
20029
  }
19989
- finalHash = hash.digest('hex').slice(0, placeholder.length);
20030
+ finalHash = getXxhash(contentToHash).slice(0, placeholder.length);
19990
20031
  finalFileName = replaceSinglePlaceholder(fileName, placeholder, finalHash);
19991
20032
  } while (bundle[lowercaseBundleKeys].has(finalFileName.toLowerCase()));
19992
20033
  bundle[finalFileName] = FILE_PLACEHOLDER;
@@ -21027,7 +21068,7 @@ class Graph {
21027
21068
  this.phase = BuildPhase.GENERATE;
21028
21069
  }
21029
21070
  contextParse(code, { allowReturnOutsideFunction = false } = {}) {
21030
- const astBuffer = native.parse(code, allowReturnOutsideFunction);
21071
+ const astBuffer = native_js.parse(code, allowReturnOutsideFunction);
21031
21072
  const readString = getReadStringFunction(astBuffer);
21032
21073
  return convertProgram(astBuffer.buffer, readString);
21033
21074
  }
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v4.0.0-22
4
- Tue, 26 Sep 2023 16:16:00 GMT - commit 38be49cf19099321f935c1ad5968e76fb30e0957
3
+ Rollup.js v4.0.0-24
4
+ Tue, 03 Oct 2023 05:11:52 GMT - commit ced077f2920c473c4c2ca31a8d72b259bec91f67
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -29,7 +29,6 @@ require('events');
29
29
  require('node:path');
30
30
  require('tty');
31
31
  require('node:perf_hooks');
32
- require('node:crypto');
33
32
  require('../native.js');
34
33
  require('node:url');
35
34
  require('../getLogFilter.js');
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v4.0.0-22
4
- Tue, 26 Sep 2023 16:16:00 GMT - commit 38be49cf19099321f935c1ad5968e76fb30e0957
3
+ Rollup.js v4.0.0-24
4
+ Tue, 03 Oct 2023 05:11:52 GMT - commit ced077f2920c473c4c2ca31a8d72b259bec91f67
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v4.0.0-22
4
- Tue, 26 Sep 2023 16:16:00 GMT - commit 38be49cf19099321f935c1ad5968e76fb30e0957
3
+ Rollup.js v4.0.0-24
4
+ Tue, 03 Oct 2023 05:11:52 GMT - commit ced077f2920c473c4c2ca31a8d72b259bec91f67
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -19,7 +19,6 @@ const index = require('./index.js');
19
19
  require('tty');
20
20
  require('path');
21
21
  require('node:perf_hooks');
22
- require('node:crypto');
23
22
  require('../native.js');
24
23
  require('node:fs/promises');
25
24
  require('fs');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rollup",
3
- "version": "4.0.0-22",
3
+ "version": "4.0.0-24",
4
4
  "description": "Next-generation ES module bundler",
5
5
  "main": "dist/rollup.js",
6
6
  "module": "dist/es/rollup.js",
@@ -98,17 +98,17 @@
98
98
  "homepage": "https://rollupjs.org/",
99
99
  "optionalDependencies": {
100
100
  "fsevents": "~2.3.2",
101
- "@rollup/rollup-darwin-arm64": "4.0.0-22",
102
- "@rollup/rollup-android-arm64": "4.0.0-22",
103
- "@rollup/rollup-win32-arm64-msvc": "4.0.0-22",
104
- "@rollup/rollup-linux-arm64-gnu": "4.0.0-22",
105
- "@rollup/rollup-android-arm-eabi": "4.0.0-22",
106
- "@rollup/rollup-linux-arm-gnueabihf": "4.0.0-22",
107
- "@rollup/rollup-win32-ia32-msvc": "4.0.0-22",
108
- "@rollup/rollup-darwin-x64": "4.0.0-22",
109
- "@rollup/rollup-win32-x64-msvc": "4.0.0-22",
110
- "@rollup/rollup-linux-x64-gnu": "4.0.0-22",
111
- "@rollup/rollup-linux-x64-musl": "4.0.0-22"
101
+ "@rollup/rollup-darwin-arm64": "4.0.0-24",
102
+ "@rollup/rollup-android-arm64": "4.0.0-24",
103
+ "@rollup/rollup-win32-arm64-msvc": "4.0.0-24",
104
+ "@rollup/rollup-linux-arm64-gnu": "4.0.0-24",
105
+ "@rollup/rollup-android-arm-eabi": "4.0.0-24",
106
+ "@rollup/rollup-linux-arm-gnueabihf": "4.0.0-24",
107
+ "@rollup/rollup-win32-ia32-msvc": "4.0.0-24",
108
+ "@rollup/rollup-darwin-x64": "4.0.0-24",
109
+ "@rollup/rollup-win32-x64-msvc": "4.0.0-24",
110
+ "@rollup/rollup-linux-x64-gnu": "4.0.0-24",
111
+ "@rollup/rollup-linux-x64-musl": "4.0.0-24"
112
112
  },
113
113
  "devDependenciesComments": {
114
114
  "@rollup/plugin-typescript": "It appears that 11.1.3 breaks sourcemaps"
@@ -116,10 +116,10 @@
116
116
  "devDependencies": {
117
117
  "@codemirror/commands": "^6.2.5",
118
118
  "@codemirror/lang-javascript": "^6.2.1",
119
- "@codemirror/language": "^6.9.0",
120
- "@codemirror/search": "^6.5.3",
119
+ "@codemirror/language": "^6.9.1",
120
+ "@codemirror/search": "^6.5.4",
121
121
  "@codemirror/state": "^6.2.1",
122
- "@codemirror/view": "^6.19.0",
122
+ "@codemirror/view": "^6.20.2",
123
123
  "@jridgewell/sourcemap-codec": "^1.4.15",
124
124
  "@mermaid-js/mermaid-cli": "^10.4.0",
125
125
  "@napi-rs/cli": "^2.16.2",
@@ -132,12 +132,12 @@
132
132
  "@rollup/plugin-terser": "^0.4.3",
133
133
  "@rollup/plugin-typescript": "11.1.2",
134
134
  "@rollup/pluginutils": "^5.0.4",
135
- "@types/estree": "1.0.1",
135
+ "@types/estree": "1.0.2",
136
136
  "@types/mocha": "^10.0.1",
137
137
  "@types/node": "18.0.0",
138
- "@types/yargs-parser": "^21.0.0",
139
- "@typescript-eslint/eslint-plugin": "^6.7.2",
140
- "@typescript-eslint/parser": "^6.7.2",
138
+ "@types/yargs-parser": "^21.0.1",
139
+ "@typescript-eslint/eslint-plugin": "^6.7.3",
140
+ "@typescript-eslint/parser": "^6.7.3",
141
141
  "@vue/eslint-config-prettier": "^8.0.0",
142
142
  "@vue/eslint-config-typescript": "^12.0.0",
143
143
  "acorn": "^8.10.0",
@@ -151,7 +151,7 @@
151
151
  "date-time": "^4.0.0",
152
152
  "es5-shim": "^4.6.7",
153
153
  "es6-shim": "^0.35.8",
154
- "eslint": "^8.49.0",
154
+ "eslint": "^8.50.0",
155
155
  "eslint-config-prettier": "^9.0.0",
156
156
  "eslint-plugin-import": "^2.28.1",
157
157
  "eslint-plugin-prettier": "^5.0.0",
@@ -175,7 +175,7 @@
175
175
  "pretty-bytes": "^6.1.1",
176
176
  "pretty-ms": "^8.0.0",
177
177
  "requirejs": "^2.3.6",
178
- "rollup": "^3.29.2",
178
+ "rollup": "^3.29.3",
179
179
  "rollup-plugin-license": "^3.1.0",
180
180
  "rollup-plugin-string": "^3.0.0",
181
181
  "rollup-plugin-thatworks": "^1.0.4",
@@ -185,11 +185,11 @@
185
185
  "source-map": "^0.7.4",
186
186
  "source-map-support": "^0.5.21",
187
187
  "systemjs": "^6.14.2",
188
- "terser": "^5.19.4",
188
+ "terser": "^5.20.0",
189
189
  "tslib": "^2.6.2",
190
190
  "typescript": "^5.2.2",
191
191
  "vite": "^4.4.9",
192
- "vitepress": "^1.0.0-rc.14",
192
+ "vitepress": "^1.0.0-rc.20",
193
193
  "vue": "^3.3.4",
194
194
  "wasm-pack": "^0.12.1",
195
195
  "weak-napi": "^2.0.2",