@rollup/wasm-node 4.9.5 → 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.
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v4.9.5
4
- Fri, 12 Jan 2024 06:15:44 GMT - commit 7fa474cc5ed91c96a4ff80e286aa8534bc15834f
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.5";
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;
@@ -4822,8 +4854,15 @@ class Method extends ExpressionEntity {
4822
4854
  this.description = description;
4823
4855
  }
4824
4856
  deoptimizeArgumentsOnInteractionAtPath({ args, type }, path) {
4825
- if (type === INTERACTION_CALLED && path.length === 0 && this.description.mutatesSelfAsArray) {
4826
- args[0]?.deoptimizePath(UNKNOWN_INTEGER_PATH);
4857
+ if (type === INTERACTION_CALLED && path.length === 0) {
4858
+ if (this.description.mutatesSelfAsArray) {
4859
+ args[0]?.deoptimizePath(UNKNOWN_INTEGER_PATH);
4860
+ }
4861
+ if (this.description.mutatesArgs) {
4862
+ for (let index = 1; index < args.length; index++) {
4863
+ args[index].deoptimizePath(UNKNOWN_PATH);
4864
+ }
4865
+ }
4827
4866
  }
4828
4867
  }
4829
4868
  getReturnExpressionWhenCalledAtPath(path, { args }) {
@@ -4863,6 +4902,7 @@ class Method extends ExpressionEntity {
4863
4902
  const METHOD_RETURNS_BOOLEAN = [
4864
4903
  new Method({
4865
4904
  callsArgs: null,
4905
+ mutatesArgs: false,
4866
4906
  mutatesSelfAsArray: false,
4867
4907
  returns: null,
4868
4908
  returnsPrimitive: UNKNOWN_LITERAL_BOOLEAN
@@ -4871,6 +4911,7 @@ const METHOD_RETURNS_BOOLEAN = [
4871
4911
  const METHOD_RETURNS_STRING = [
4872
4912
  new Method({
4873
4913
  callsArgs: null,
4914
+ mutatesArgs: false,
4874
4915
  mutatesSelfAsArray: false,
4875
4916
  returns: null,
4876
4917
  returnsPrimitive: UNKNOWN_LITERAL_STRING
@@ -4879,6 +4920,7 @@ const METHOD_RETURNS_STRING = [
4879
4920
  const METHOD_RETURNS_NUMBER = [
4880
4921
  new Method({
4881
4922
  callsArgs: null,
4923
+ mutatesArgs: false,
4882
4924
  mutatesSelfAsArray: false,
4883
4925
  returns: null,
4884
4926
  returnsPrimitive: UNKNOWN_LITERAL_NUMBER
@@ -4887,6 +4929,7 @@ const METHOD_RETURNS_NUMBER = [
4887
4929
  const METHOD_RETURNS_UNKNOWN = [
4888
4930
  new Method({
4889
4931
  callsArgs: null,
4932
+ mutatesArgs: false,
4890
4933
  mutatesSelfAsArray: false,
4891
4934
  returns: null,
4892
4935
  returnsPrimitive: UNKNOWN_EXPRESSION
@@ -5301,6 +5344,7 @@ const NEW_ARRAY_PROPERTIES = [
5301
5344
  const METHOD_CALLS_ARG_DEOPTS_SELF_RETURNS_BOOLEAN = [
5302
5345
  new Method({
5303
5346
  callsArgs: [0],
5347
+ mutatesArgs: false,
5304
5348
  mutatesSelfAsArray: 'deopt-only',
5305
5349
  returns: null,
5306
5350
  returnsPrimitive: UNKNOWN_LITERAL_BOOLEAN
@@ -5309,6 +5353,7 @@ const METHOD_CALLS_ARG_DEOPTS_SELF_RETURNS_BOOLEAN = [
5309
5353
  const METHOD_CALLS_ARG_DEOPTS_SELF_RETURNS_NUMBER = [
5310
5354
  new Method({
5311
5355
  callsArgs: [0],
5356
+ mutatesArgs: false,
5312
5357
  mutatesSelfAsArray: 'deopt-only',
5313
5358
  returns: null,
5314
5359
  returnsPrimitive: UNKNOWN_LITERAL_NUMBER
@@ -5317,6 +5362,7 @@ const METHOD_CALLS_ARG_DEOPTS_SELF_RETURNS_NUMBER = [
5317
5362
  const METHOD_MUTATES_SELF_RETURNS_NEW_ARRAY = [
5318
5363
  new Method({
5319
5364
  callsArgs: null,
5365
+ mutatesArgs: false,
5320
5366
  mutatesSelfAsArray: true,
5321
5367
  returns: () => new ObjectEntity(NEW_ARRAY_PROPERTIES, ARRAY_PROTOTYPE),
5322
5368
  returnsPrimitive: null
@@ -5325,6 +5371,7 @@ const METHOD_MUTATES_SELF_RETURNS_NEW_ARRAY = [
5325
5371
  const METHOD_DEOPTS_SELF_RETURNS_NEW_ARRAY = [
5326
5372
  new Method({
5327
5373
  callsArgs: null,
5374
+ mutatesArgs: false,
5328
5375
  mutatesSelfAsArray: 'deopt-only',
5329
5376
  returns: () => new ObjectEntity(NEW_ARRAY_PROPERTIES, ARRAY_PROTOTYPE),
5330
5377
  returnsPrimitive: null
@@ -5333,14 +5380,16 @@ const METHOD_DEOPTS_SELF_RETURNS_NEW_ARRAY = [
5333
5380
  const METHOD_CALLS_ARG_DEOPTS_SELF_RETURNS_NEW_ARRAY = [
5334
5381
  new Method({
5335
5382
  callsArgs: [0],
5383
+ mutatesArgs: false,
5336
5384
  mutatesSelfAsArray: 'deopt-only',
5337
5385
  returns: () => new ObjectEntity(NEW_ARRAY_PROPERTIES, ARRAY_PROTOTYPE),
5338
5386
  returnsPrimitive: null
5339
5387
  })
5340
5388
  ];
5341
- const METHOD_MUTATES_SELF_RETURNS_NUMBER = [
5389
+ const METHOD_MUTATES_SELF_AND_ARGS_RETURNS_NUMBER = [
5342
5390
  new Method({
5343
5391
  callsArgs: null,
5392
+ mutatesArgs: true,
5344
5393
  mutatesSelfAsArray: true,
5345
5394
  returns: null,
5346
5395
  returnsPrimitive: UNKNOWN_LITERAL_NUMBER
@@ -5349,6 +5398,7 @@ const METHOD_MUTATES_SELF_RETURNS_NUMBER = [
5349
5398
  const METHOD_MUTATES_SELF_RETURNS_UNKNOWN = [
5350
5399
  new Method({
5351
5400
  callsArgs: null,
5401
+ mutatesArgs: false,
5352
5402
  mutatesSelfAsArray: true,
5353
5403
  returns: null,
5354
5404
  returnsPrimitive: UNKNOWN_EXPRESSION
@@ -5357,6 +5407,7 @@ const METHOD_MUTATES_SELF_RETURNS_UNKNOWN = [
5357
5407
  const METHOD_DEOPTS_SELF_RETURNS_UNKNOWN = [
5358
5408
  new Method({
5359
5409
  callsArgs: null,
5410
+ mutatesArgs: false,
5360
5411
  mutatesSelfAsArray: 'deopt-only',
5361
5412
  returns: null,
5362
5413
  returnsPrimitive: UNKNOWN_EXPRESSION
@@ -5365,6 +5416,7 @@ const METHOD_DEOPTS_SELF_RETURNS_UNKNOWN = [
5365
5416
  const METHOD_CALLS_ARG_DEOPTS_SELF_RETURNS_UNKNOWN = [
5366
5417
  new Method({
5367
5418
  callsArgs: [0],
5419
+ mutatesArgs: false,
5368
5420
  mutatesSelfAsArray: 'deopt-only',
5369
5421
  returns: null,
5370
5422
  returnsPrimitive: UNKNOWN_EXPRESSION
@@ -5373,6 +5425,7 @@ const METHOD_CALLS_ARG_DEOPTS_SELF_RETURNS_UNKNOWN = [
5373
5425
  const METHOD_MUTATES_SELF_RETURNS_SELF = [
5374
5426
  new Method({
5375
5427
  callsArgs: null,
5428
+ mutatesArgs: false,
5376
5429
  mutatesSelfAsArray: true,
5377
5430
  returns: 'self',
5378
5431
  returnsPrimitive: null
@@ -5381,6 +5434,7 @@ const METHOD_MUTATES_SELF_RETURNS_SELF = [
5381
5434
  const METHOD_CALLS_ARG_MUTATES_SELF_RETURNS_SELF = [
5382
5435
  new Method({
5383
5436
  callsArgs: [0],
5437
+ mutatesArgs: false,
5384
5438
  mutatesSelfAsArray: true,
5385
5439
  returns: 'self',
5386
5440
  returnsPrimitive: null
@@ -5410,7 +5464,7 @@ const ARRAY_PROTOTYPE = new ObjectEntity({
5410
5464
  lastIndexOf: METHOD_RETURNS_NUMBER,
5411
5465
  map: METHOD_CALLS_ARG_DEOPTS_SELF_RETURNS_NEW_ARRAY,
5412
5466
  pop: METHOD_MUTATES_SELF_RETURNS_UNKNOWN,
5413
- push: METHOD_MUTATES_SELF_RETURNS_NUMBER,
5467
+ push: METHOD_MUTATES_SELF_AND_ARGS_RETURNS_NUMBER,
5414
5468
  reduce: METHOD_CALLS_ARG_DEOPTS_SELF_RETURNS_UNKNOWN,
5415
5469
  reduceRight: METHOD_CALLS_ARG_DEOPTS_SELF_RETURNS_UNKNOWN,
5416
5470
  reverse: METHOD_MUTATES_SELF_RETURNS_SELF,
@@ -5421,7 +5475,7 @@ const ARRAY_PROTOTYPE = new ObjectEntity({
5421
5475
  splice: METHOD_MUTATES_SELF_RETURNS_NEW_ARRAY,
5422
5476
  toLocaleString: METHOD_RETURNS_STRING,
5423
5477
  toString: METHOD_RETURNS_STRING,
5424
- unshift: METHOD_MUTATES_SELF_RETURNS_NUMBER,
5478
+ unshift: METHOD_MUTATES_SELF_AND_ARGS_RETURNS_NUMBER,
5425
5479
  values: METHOD_DEOPTS_SELF_RETURNS_UNKNOWN
5426
5480
  }, OBJECT_PROTOTYPE, true);
5427
5481
 
@@ -12755,7 +12809,7 @@ class Module {
12755
12809
  this.ast.bind();
12756
12810
  }
12757
12811
  error(properties, pos) {
12758
- this.addLocationToLogProps(properties, pos);
12812
+ pos !== undefined && this.addLocationToLogProps(properties, pos);
12759
12813
  return error(properties);
12760
12814
  }
12761
12815
  // sum up the length of all ast nodes that are included
@@ -14658,13 +14712,13 @@ const hashPlaceholderLeft = '!~{';
14658
14712
  const hashPlaceholderRight = '}~';
14659
14713
  const hashPlaceholderOverhead = hashPlaceholderLeft.length + hashPlaceholderRight.length;
14660
14714
  // This is the size of a 128-bits xxhash with base64url encoding
14661
- const maxHashSize = 22;
14662
- const defaultHashSize = 8;
14715
+ const MAX_HASH_SIZE = 22;
14716
+ const DEFAULT_HASH_SIZE = 8;
14663
14717
  const getHashPlaceholderGenerator = () => {
14664
14718
  let nextIndex = 0;
14665
- return (optionName, hashSize = defaultHashSize) => {
14666
- if (hashSize > maxHashSize) {
14667
- 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.`));
14668
14722
  }
14669
14723
  const placeholder = `${hashPlaceholderLeft}${toBase64(++nextIndex).padStart(hashSize - hashPlaceholderOverhead, '0')}${hashPlaceholderRight}`;
14670
14724
  if (placeholder.length > hashSize) {
@@ -14673,7 +14727,7 @@ const getHashPlaceholderGenerator = () => {
14673
14727
  return placeholder;
14674
14728
  };
14675
14729
  };
14676
- 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');
14677
14731
  const replacePlaceholders = (code, hashesByPlaceholder) => code.replace(REPLACER_REGEX, placeholder => hashesByPlaceholder.get(placeholder) || placeholder);
14678
14732
  const replaceSinglePlaceholder = (code, placeholder, value) => code.replace(REPLACER_REGEX, match => (match === placeholder ? value : match));
14679
14733
  const replacePlaceholdersWithDefaultAndGetContainedPlaceholders = (code, placeholders) => {
@@ -15037,7 +15091,8 @@ class Chunk {
15037
15091
  : [chunkFileNames, 'output.chunkFileNames'];
15038
15092
  fileName = renderNamePattern(typeof pattern === 'function' ? pattern(this.getPreRenderedChunkInfo()) : pattern, patternName, {
15039
15093
  format: () => format,
15040
- hash: size => hashPlaceholder || (hashPlaceholder = this.getPlaceholder(patternName, size)),
15094
+ hash: size => hashPlaceholder ||
15095
+ (hashPlaceholder = this.getPlaceholder(patternName, size || DEFAULT_HASH_SIZE)),
15041
15096
  name: () => this.getChunkName()
15042
15097
  });
15043
15098
  if (!hashPlaceholder) {
@@ -15065,7 +15120,8 @@ class Chunk {
15065
15120
  sourcemapFileName = renderNamePattern(typeof pattern === 'function' ? pattern(this.getPreRenderedChunkInfo()) : pattern, patternName, {
15066
15121
  chunkhash: () => this.getPreliminaryFileName().hashPlaceholder || '',
15067
15122
  format: () => format,
15068
- hash: size => hashPlaceholder || (hashPlaceholder = this.getPlaceholder(patternName, size)),
15123
+ hash: size => hashPlaceholder ||
15124
+ (hashPlaceholder = this.getPlaceholder(patternName, size || DEFAULT_HASH_SIZE)),
15069
15125
  name: () => this.getChunkName()
15070
15126
  });
15071
15127
  if (!hashPlaceholder) {
@@ -16764,21 +16820,23 @@ function collapseSourcemap(id, originalCode, originalSourcemap, sourcemapChain,
16764
16820
  }
16765
16821
 
16766
16822
  let textEncoder;
16767
- function getXxhash(input) {
16768
- 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) {
16769
16832
  if (typeof input === 'string') {
16770
16833
  if (typeof Buffer === 'undefined') {
16771
16834
  textEncoder ??= new TextEncoder();
16772
- buffer = textEncoder.encode(input);
16835
+ return textEncoder.encode(input);
16773
16836
  }
16774
- else {
16775
- buffer = Buffer.from(input);
16776
- }
16777
- }
16778
- else {
16779
- buffer = input;
16837
+ return Buffer.from(input);
16780
16838
  }
16781
- return xxhashBase64Url(buffer);
16839
+ return input;
16782
16840
  }
16783
16841
 
16784
16842
  // this looks ridiculous, but it prevents sourcemap tooling from mistaking
@@ -16792,9 +16850,10 @@ async function renderChunks(chunks, bundle, pluginDriver, outputOptions, log) {
16792
16850
  const renderedChunks = await Promise.all(chunks.map(chunk => chunk.render()));
16793
16851
  timeEnd('render chunks', 2);
16794
16852
  timeStart('transform chunks', 2);
16853
+ const getHash = hasherByType[outputOptions.hashCharacters];
16795
16854
  const chunkGraph = getChunkGraph(chunks);
16796
- const { initialHashesByPlaceholder, nonHashedChunksWithPlaceholders, renderedChunksByPlaceholder, hashDependenciesByPlaceholder } = await transformChunksAndGenerateContentHashes(renderedChunks, chunkGraph, outputOptions, pluginDriver, log);
16797
- 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);
16798
16857
  addChunksToBundle(renderedChunksByPlaceholder, hashesByPlaceholder, bundle, nonHashedChunksWithPlaceholders, pluginDriver, outputOptions);
16799
16858
  timeEnd('transform chunks', 2);
16800
16859
  }
@@ -16874,7 +16933,7 @@ async function transformChunk(magicString, fileName, usedModules, chunkGraph, op
16874
16933
  map
16875
16934
  };
16876
16935
  }
16877
- async function transformChunksAndGenerateContentHashes(renderedChunks, chunkGraph, outputOptions, pluginDriver, log) {
16936
+ async function transformChunksAndGenerateContentHashes(renderedChunks, chunkGraph, outputOptions, pluginDriver, getHash, log) {
16878
16937
  const nonHashedChunksWithPlaceholders = [];
16879
16938
  const renderedChunksByPlaceholder = new Map();
16880
16939
  const hashDependenciesByPlaceholder = new Map();
@@ -16909,7 +16968,7 @@ async function transformChunksAndGenerateContentHashes(renderedChunks, chunkGrap
16909
16968
  renderedChunksByPlaceholder.set(hashPlaceholder, transformedChunk);
16910
16969
  hashDependenciesByPlaceholder.set(hashPlaceholder, {
16911
16970
  containedPlaceholders,
16912
- contentHash: getXxhash(contentToHash)
16971
+ contentHash: getHash(contentToHash)
16913
16972
  });
16914
16973
  }
16915
16974
  else {
@@ -16917,7 +16976,7 @@ async function transformChunksAndGenerateContentHashes(renderedChunks, chunkGrap
16917
16976
  }
16918
16977
  const sourcemapHashPlaceholder = preliminarySourcemapFileName?.hashPlaceholder;
16919
16978
  if (map && sourcemapHashPlaceholder) {
16920
- 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));
16921
16980
  }
16922
16981
  }));
16923
16982
  return {
@@ -16927,7 +16986,7 @@ async function transformChunksAndGenerateContentHashes(renderedChunks, chunkGrap
16927
16986
  renderedChunksByPlaceholder
16928
16987
  };
16929
16988
  }
16930
- function generateFinalHashes(renderedChunksByPlaceholder, hashDependenciesByPlaceholder, initialHashesByPlaceholder, bundle) {
16989
+ function generateFinalHashes(renderedChunksByPlaceholder, hashDependenciesByPlaceholder, initialHashesByPlaceholder, bundle, getHash) {
16931
16990
  const hashesByPlaceholder = new Map(initialHashesByPlaceholder);
16932
16991
  for (const [placeholder, { fileName }] of renderedChunksByPlaceholder) {
16933
16992
  let contentToHash = '';
@@ -16947,7 +17006,7 @@ function generateFinalHashes(renderedChunksByPlaceholder, hashDependenciesByPlac
16947
17006
  if (finalHash) {
16948
17007
  contentToHash = finalHash;
16949
17008
  }
16950
- finalHash = getXxhash(contentToHash).slice(0, placeholder.length);
17009
+ finalHash = getHash(contentToHash).slice(0, placeholder.length);
16951
17010
  finalFileName = replaceSinglePlaceholder(fileName, placeholder, finalHash);
16952
17011
  } while (bundle[lowercaseBundleKeys].has(finalFileName.toLowerCase()));
16953
17012
  bundle[finalFileName] = FILE_PLACEHOLDER;
@@ -18114,7 +18173,7 @@ function generateAssetFileName(name, source, sourceHash, outputOptions, bundle)
18114
18173
  : outputOptions.assetFileNames, 'output.assetFileNames', {
18115
18174
  ext: () => extname(emittedName).slice(1),
18116
18175
  extname: () => extname(emittedName),
18117
- hash: size => sourceHash.slice(0, Math.max(0, size || defaultHashSize)),
18176
+ hash: size => sourceHash.slice(0, Math.max(0, size || DEFAULT_HASH_SIZE)),
18118
18177
  name: () => emittedName.slice(0, Math.max(0, emittedName.length - extname(emittedName).length))
18119
18178
  }), bundle);
18120
18179
  }
@@ -18223,9 +18282,11 @@ class FileEmitter {
18223
18282
  this.facadeChunkByModule = facadeChunkByModule;
18224
18283
  };
18225
18284
  this.setOutputBundle = (bundle, outputOptions) => {
18285
+ const getHash = hasherByType[outputOptions.hashCharacters];
18226
18286
  const output = (this.output = {
18227
18287
  bundle,
18228
18288
  fileNamesBySource: new Map(),
18289
+ getHash,
18229
18290
  outputOptions
18230
18291
  });
18231
18292
  for (const emittedFile of this.filesByReferenceId.values()) {
@@ -18240,7 +18301,7 @@ class FileEmitter {
18240
18301
  this.finalizeAdditionalAsset(consumedFile, consumedFile.source, output);
18241
18302
  }
18242
18303
  else {
18243
- const sourceHash = getXxhash(consumedFile.source);
18304
+ const sourceHash = getHash(consumedFile.source);
18244
18305
  getOrCreate(consumedAssetsByHash, sourceHash, () => []).push(consumedFile);
18245
18306
  }
18246
18307
  }
@@ -18263,7 +18324,7 @@ class FileEmitter {
18263
18324
  assignReferenceId(file, idBase) {
18264
18325
  let referenceId = idBase;
18265
18326
  do {
18266
- referenceId = getXxhash(referenceId).slice(0, 8).replaceAll('-', '$');
18327
+ referenceId = getHash64(referenceId).slice(0, 8).replaceAll('-', '$');
18267
18328
  } while (this.filesByReferenceId.has(referenceId) ||
18268
18329
  this.outputFileEmitters.some(({ filesByReferenceId }) => filesByReferenceId.has(referenceId)));
18269
18330
  file.referenceId = referenceId;
@@ -18374,11 +18435,11 @@ class FileEmitter {
18374
18435
  }
18375
18436
  return referenceId;
18376
18437
  }
18377
- finalizeAdditionalAsset(consumedFile, source, { bundle, fileNamesBySource, outputOptions }) {
18438
+ finalizeAdditionalAsset(consumedFile, source, { bundle, fileNamesBySource, getHash, outputOptions }) {
18378
18439
  let { fileName, needsCodeReference, referenceId } = consumedFile;
18379
18440
  // Deduplicate assets if an explicit fileName is not provided
18380
18441
  if (!fileName) {
18381
- const sourceHash = getXxhash(source);
18442
+ const sourceHash = getHash(source);
18382
18443
  fileName = fileNamesBySource.get(sourceHash);
18383
18444
  if (!fileName) {
18384
18445
  fileName = generateAssetFileName(consumedFile.name, source, sourceHash, outputOptions, bundle);
@@ -19236,6 +19297,7 @@ async function normalizeOutputOptions(config, inputOptions, unsetInputOptions) {
19236
19297
  freeze: config.freeze ?? true,
19237
19298
  generatedCode,
19238
19299
  globals: config.globals || {},
19300
+ hashCharacters: config.hashCharacters ?? 'base64',
19239
19301
  hoistTransitiveImports: config.hoistTransitiveImports ?? true,
19240
19302
  indent: getIndent(config, compact),
19241
19303
  inlineDynamicImports,
@@ -19936,6 +19998,7 @@ async function mergeOutputOptions(config, overrides, log) {
19936
19998
  freeze: getOption('freeze'),
19937
19999
  generatedCode: getObjectOption(config, overrides, 'generatedCode', objectifyOptionWithPresets(generatedCodePresets, 'output.generatedCode', URL_OUTPUT_GENERATEDCODE, '')),
19938
20000
  globals: getOption('globals'),
20001
+ hashCharacters: getOption('hashCharacters'),
19939
20002
  hoistTransitiveImports: getOption('hoistTransitiveImports'),
19940
20003
  indent: getOption('indent'),
19941
20004
  inlineDynamicImports: getOption('inlineDynamicImports'),