rollup 3.27.2 → 3.28.1

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
@@ -2,8 +2,8 @@
2
2
 
3
3
  /*
4
4
  @license
5
- Rollup.js v3.27.2
6
- Fri, 04 Aug 2023 11:31:37 GMT - commit ffd2239d550a22988f864316d294fcaab3b4bdae
5
+ Rollup.js v3.28.1
6
+ Tue, 22 Aug 2023 05:30:38 GMT - commit 1b557cd77cce8560cf073875cf6bc289bbe5f09c
7
7
 
8
8
  https://github.com/rollup/rollup
9
9
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v3.27.2
4
- Fri, 04 Aug 2023 11:31:37 GMT - commit ffd2239d550a22988f864316d294fcaab3b4bdae
3
+ Rollup.js v3.28.1
4
+ Tue, 22 Aug 2023 05:30:38 GMT - commit 1b557cd77cce8560cf073875cf6bc289bbe5f09c
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 v3.27.2
4
- Fri, 04 Aug 2023 11:31:37 GMT - commit ffd2239d550a22988f864316d294fcaab3b4bdae
3
+ Rollup.js v3.28.1
4
+ Tue, 22 Aug 2023 05:30:38 GMT - commit 1b557cd77cce8560cf073875cf6bc289bbe5f09c
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v3.27.2
4
- Fri, 04 Aug 2023 11:31:37 GMT - commit ffd2239d550a22988f864316d294fcaab3b4bdae
3
+ Rollup.js v3.28.1
4
+ Tue, 22 Aug 2023 05:30:38 GMT - commit 1b557cd77cce8560cf073875cf6bc289bbe5f09c
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -15,7 +15,7 @@ import { createHash as createHash$1 } from 'node:crypto';
15
15
  import { lstat, realpath, readdir, readFile, mkdir, writeFile } from 'node:fs/promises';
16
16
  import * as tty from 'tty';
17
17
 
18
- var version$1 = "3.27.2";
18
+ var version$1 = "3.28.1";
19
19
 
20
20
  const comma = ','.charCodeAt(0);
21
21
  const semicolon = ';'.charCodeAt(0);
@@ -288,6 +288,13 @@ let Chunk$1 = class Chunk {
288
288
  this.end = index;
289
289
 
290
290
  if (this.edited) {
291
+ // after split we should save the edit content record into the correct chunk
292
+ // to make sure sourcemap correct
293
+ // For example:
294
+ // ' test'.trim()
295
+ // split -> ' ' + 'test'
296
+ // ✔️ edit -> '' + 'test'
297
+ // ✖️ edit -> 'test' + ''
291
298
  // TODO is this block necessary?...
292
299
  newChunk.edit('', false);
293
300
  this.content = '';
@@ -316,6 +323,10 @@ let Chunk$1 = class Chunk {
316
323
  if (trimmed.length) {
317
324
  if (trimmed !== this.content) {
318
325
  this.split(this.start + trimmed.length).edit('', undefined, true);
326
+ if (this.edited) {
327
+ // save the change, if it has been edited
328
+ this.edit(trimmed, this.storeName, true);
329
+ }
319
330
  }
320
331
  return true;
321
332
  } else {
@@ -334,7 +345,11 @@ let Chunk$1 = class Chunk {
334
345
 
335
346
  if (trimmed.length) {
336
347
  if (trimmed !== this.content) {
337
- this.split(this.end - trimmed.length);
348
+ const newChunk = this.split(this.end - trimmed.length);
349
+ if (this.edited) {
350
+ // save the change, if it has been edited
351
+ newChunk.edit(trimmed, this.storeName, true);
352
+ }
338
353
  this.edit('', undefined, true);
339
354
  }
340
355
  return true;
@@ -347,7 +362,7 @@ let Chunk$1 = class Chunk {
347
362
  }
348
363
  };
349
364
 
350
- function getBtoa () {
365
+ function getBtoa() {
351
366
  if (typeof window !== 'undefined' && typeof window.btoa === 'function') {
352
367
  return (str) => window.btoa(unescape(encodeURIComponent(str)));
353
368
  } else if (typeof Buffer === 'function') {
@@ -460,6 +475,8 @@ function getLocator$1(source) {
460
475
  };
461
476
  }
462
477
 
478
+ const wordRegex = /\w/;
479
+
463
480
  class Mappings {
464
481
  constructor(hires) {
465
482
  this.hires = hires;
@@ -488,10 +505,29 @@ class Mappings {
488
505
  addUneditedChunk(sourceIndex, chunk, original, loc, sourcemapLocations) {
489
506
  let originalCharIndex = chunk.start;
490
507
  let first = true;
508
+ // when iterating each char, check if it's in a word boundary
509
+ let charInHiresBoundary = false;
491
510
 
492
511
  while (originalCharIndex < chunk.end) {
493
512
  if (this.hires || first || sourcemapLocations.has(originalCharIndex)) {
494
- this.rawSegments.push([this.generatedCodeColumn, sourceIndex, loc.line, loc.column]);
513
+ const segment = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column];
514
+
515
+ if (this.hires === 'boundary') {
516
+ // in hires "boundary", group segments per word boundary than per char
517
+ if (wordRegex.test(original[originalCharIndex])) {
518
+ // for first char in the boundary found, start the boundary by pushing a segment
519
+ if (!charInHiresBoundary) {
520
+ this.rawSegments.push(segment);
521
+ charInHiresBoundary = true;
522
+ }
523
+ } else {
524
+ // for non-word char, end the boundary by pushing a segment
525
+ this.rawSegments.push(segment);
526
+ charInHiresBoundary = false;
527
+ }
528
+ } else {
529
+ this.rawSegments.push(segment);
530
+ }
495
531
  }
496
532
 
497
533
  if (original[originalCharIndex] === '\n') {
@@ -664,7 +700,7 @@ class MagicString {
664
700
  sourceIndex,
665
701
  chunk.content,
666
702
  loc,
667
- chunk.storeName ? names.indexOf(chunk.original) : -1
703
+ chunk.storeName ? names.indexOf(chunk.original) : -1,
668
704
  );
669
705
  } else {
670
706
  mappings.addUneditedChunk(sourceIndex, chunk, this.original, loc, this.sourcemapLocations);
@@ -675,11 +711,13 @@ class MagicString {
675
711
 
676
712
  return {
677
713
  file: options.file ? options.file.split(/[/\\]/).pop() : undefined,
678
- sources: [options.source ? getRelativePath(options.file || '', options.source) : (options.file || '')],
714
+ sources: [
715
+ options.source ? getRelativePath(options.file || '', options.source) : options.file || '',
716
+ ],
679
717
  sourcesContent: options.includeContent ? [this.original] : undefined,
680
718
  names,
681
719
  mappings: mappings.raw,
682
- x_google_ignoreList: this.ignoreList ? [sourceIndex] : undefined
720
+ x_google_ignoreList: this.ignoreList ? [sourceIndex] : undefined,
683
721
  };
684
722
  }
685
723
 
@@ -793,14 +831,14 @@ class MagicString {
793
831
 
794
832
  insert() {
795
833
  throw new Error(
796
- 'magicString.insert(...) is deprecated. Use prependRight(...) or appendLeft(...)'
834
+ 'magicString.insert(...) is deprecated. Use prependRight(...) or appendLeft(...)',
797
835
  );
798
836
  }
799
837
 
800
838
  insertLeft(index, content) {
801
839
  if (!warned.insertLeft) {
802
840
  console.warn(
803
- 'magicString.insertLeft(...) is deprecated. Use magicString.appendLeft(...) instead'
841
+ 'magicString.insertLeft(...) is deprecated. Use magicString.appendLeft(...) instead',
804
842
  ); // eslint-disable-line no-console
805
843
  warned.insertLeft = true;
806
844
  }
@@ -811,7 +849,7 @@ class MagicString {
811
849
  insertRight(index, content) {
812
850
  if (!warned.insertRight) {
813
851
  console.warn(
814
- 'magicString.insertRight(...) is deprecated. Use magicString.prependRight(...) instead'
852
+ 'magicString.insertRight(...) is deprecated. Use magicString.prependRight(...) instead',
815
853
  ); // eslint-disable-line no-console
816
854
  warned.insertRight = true;
817
855
  }
@@ -870,7 +908,7 @@ class MagicString {
870
908
  if (end > this.original.length) throw new Error('end is out of bounds');
871
909
  if (start === end)
872
910
  throw new Error(
873
- 'Cannot overwrite a zero-length range – use appendLeft or prependRight instead'
911
+ 'Cannot overwrite a zero-length range – use appendLeft or prependRight instead',
874
912
  );
875
913
 
876
914
  this._split(start);
@@ -879,7 +917,7 @@ class MagicString {
879
917
  if (options === true) {
880
918
  if (!warned.storeName) {
881
919
  console.warn(
882
- 'The final argument to magicString.overwrite(...) should be an options object. See https://github.com/rich-harris/magic-string'
920
+ 'The final argument to magicString.overwrite(...) should be an options object. See https://github.com/rich-harris/magic-string',
883
921
  ); // eslint-disable-line no-console
884
922
  warned.storeName = true;
885
923
  }
@@ -1101,7 +1139,7 @@ class MagicString {
1101
1139
  // zero-length edited chunks are a special case (overlapping replacements)
1102
1140
  const loc = getLocator$1(this.original)(index);
1103
1141
  throw new Error(
1104
- `Cannot split a chunk that has already been edited (${loc.line}:${loc.column} – "${chunk.original}")`
1142
+ `Cannot split a chunk that has already been edited (${loc.line}:${loc.column} – "${chunk.original}")`,
1105
1143
  );
1106
1144
  }
1107
1145
 
@@ -1260,7 +1298,7 @@ class MagicString {
1260
1298
  this.overwrite(
1261
1299
  match.index,
1262
1300
  match.index + match[0].length,
1263
- getReplacement(match, this.original)
1301
+ getReplacement(match, this.original),
1264
1302
  );
1265
1303
  });
1266
1304
  } else {
@@ -1269,7 +1307,7 @@ class MagicString {
1269
1307
  this.overwrite(
1270
1308
  match.index,
1271
1309
  match.index + match[0].length,
1272
- getReplacement(match, this.original)
1310
+ getReplacement(match, this.original),
1273
1311
  );
1274
1312
  }
1275
1313
  return this;
@@ -1315,7 +1353,7 @@ class MagicString {
1315
1353
 
1316
1354
  if (!searchValue.global) {
1317
1355
  throw new TypeError(
1318
- 'MagicString.prototype.replaceAll called with a non-global RegExp argument'
1356
+ 'MagicString.prototype.replaceAll called with a non-global RegExp argument',
1319
1357
  );
1320
1358
  }
1321
1359
 
@@ -1345,7 +1383,7 @@ let Bundle$1 = class Bundle {
1345
1383
 
1346
1384
  if (!isObject$1(source) || !source.content) {
1347
1385
  throw new Error(
1348
- 'bundle.addSource() takes an object with a `content` property, which should be an instance of MagicString, and an optional `filename`'
1386
+ 'bundle.addSource() takes an object with a `content` property, which should be an instance of MagicString, and an optional `filename`',
1349
1387
  );
1350
1388
  }
1351
1389
 
@@ -1439,7 +1477,7 @@ let Bundle$1 = class Bundle {
1439
1477
  sourceIndex,
1440
1478
  chunk.content,
1441
1479
  loc,
1442
- chunk.storeName ? names.indexOf(chunk.original) : -1
1480
+ chunk.storeName ? names.indexOf(chunk.original) : -1,
1443
1481
  );
1444
1482
  } else {
1445
1483
  mappings.addUneditedChunk(
@@ -1447,7 +1485,7 @@ let Bundle$1 = class Bundle {
1447
1485
  chunk,
1448
1486
  magicString.original,
1449
1487
  loc,
1450
- magicString.sourcemapLocations
1488
+ magicString.sourcemapLocations,
1451
1489
  );
1452
1490
  }
1453
1491
  } else {
@@ -1565,7 +1603,7 @@ let Bundle$1 = class Bundle {
1565
1603
  length() {
1566
1604
  return this.sources.reduce(
1567
1605
  (length, source) => length + source.content.length(),
1568
- this.intro.length
1606
+ this.intro.length,
1569
1607
  );
1570
1608
  }
1571
1609
 
@@ -1673,6 +1711,10 @@ function isPathFragment(name) {
1673
1711
  }
1674
1712
  const UPPER_DIR_REGEX = /^(\.\.\/)*\.\.$/;
1675
1713
  function getImportPath(importerId, targetPath, stripJsExtension, ensureFileName) {
1714
+ while (targetPath.startsWith('../')) {
1715
+ targetPath = targetPath.slice(3);
1716
+ importerId = '_/' + importerId;
1717
+ }
1676
1718
  let relativePath = normalize(relative(dirname(importerId), targetPath));
1677
1719
  if (stripJsExtension && relativePath.endsWith('.js')) {
1678
1720
  relativePath = relativePath.slice(0, -3);
@@ -5056,7 +5098,7 @@ const normalizePath = function normalizePath(filename) {
5056
5098
  };
5057
5099
 
5058
5100
  function getMatcherString(id, resolutionBase) {
5059
- if (resolutionBase === false || isAbsolute$1(id) || id.startsWith('*')) {
5101
+ if (resolutionBase === false || isAbsolute$1(id) || id.startsWith('**')) {
5060
5102
  return normalizePath(id);
5061
5103
  }
5062
5104
  // resolve('') is valid and will default to process.cwd()
@@ -13217,12 +13259,82 @@ var BuildPhase;
13217
13259
  BuildPhase[BuildPhase["GENERATE"] = 2] = "GENERATE";
13218
13260
  })(BuildPhase || (BuildPhase = {}));
13219
13261
 
13262
+ const sourceMapCache = new WeakMap();
13263
+ /**
13264
+ * This clears the decoded array and falls back to the encoded string form.
13265
+ * Sourcemap mappings arrays can be very large and holding on to them for longer
13266
+ * than is necessary leads to poor heap utilization.
13267
+ */
13268
+ function resetCacheToEncoded(cache) {
13269
+ if (cache.encodedMappings === undefined && cache.decodedMappings) {
13270
+ cache.encodedMappings = encode(cache.decodedMappings);
13271
+ }
13272
+ cache.decodedMappings = undefined;
13273
+ }
13274
+ function resetSourcemapCache(map, sourcemapChain) {
13275
+ if (map) {
13276
+ const cache = sourceMapCache.get(map);
13277
+ if (cache) {
13278
+ resetCacheToEncoded(cache);
13279
+ }
13280
+ }
13281
+ if (!sourcemapChain) {
13282
+ return;
13283
+ }
13284
+ for (const map of sourcemapChain) {
13285
+ if (map.missing)
13286
+ continue;
13287
+ resetSourcemapCache(map);
13288
+ }
13289
+ }
13290
+ function decodedSourcemap(map) {
13291
+ if (!map)
13292
+ return null;
13293
+ if (typeof map === 'string') {
13294
+ map = JSON.parse(map);
13295
+ }
13296
+ if (!map.mappings) {
13297
+ return {
13298
+ mappings: [],
13299
+ names: [],
13300
+ sources: [],
13301
+ version: 3
13302
+ };
13303
+ }
13304
+ const originalMappings = map.mappings;
13305
+ const isAlreadyDecoded = Array.isArray(originalMappings);
13306
+ const cache = {
13307
+ decodedMappings: isAlreadyDecoded ? originalMappings : undefined,
13308
+ encodedMappings: isAlreadyDecoded ? undefined : originalMappings
13309
+ };
13310
+ const decodedMap = {
13311
+ ...map,
13312
+ // By moving mappings behind an accessor, we can avoid unneeded computation for cases
13313
+ // where the mappings field is never actually accessed. This appears to greatly reduce
13314
+ // the overhead of sourcemap decoding in terms of both compute time and memory usage.
13315
+ get mappings() {
13316
+ if (cache.decodedMappings) {
13317
+ return cache.decodedMappings;
13318
+ }
13319
+ // If decodedMappings doesn't exist then encodedMappings should.
13320
+ // The only scenario where cache.encodedMappings should be undefined is if the map
13321
+ // this was constructed from was already decoded, or if mappings was set to a new
13322
+ // decoded string. In either case, this line shouldn't get hit.
13323
+ cache.decodedMappings = cache.encodedMappings ? decode(cache.encodedMappings) : [];
13324
+ cache.encodedMappings = undefined;
13325
+ return cache.decodedMappings;
13326
+ }
13327
+ };
13328
+ sourceMapCache.set(decodedMap, cache);
13329
+ return decodedMap;
13330
+ }
13331
+
13220
13332
  function getId(m) {
13221
13333
  return m.id;
13222
13334
  }
13223
13335
 
13224
13336
  function getOriginalLocation(sourcemapChain, location) {
13225
- const filteredSourcemapChain = sourcemapChain.filter((sourcemap) => !!sourcemap.mappings);
13337
+ const filteredSourcemapChain = sourcemapChain.filter((sourcemap) => !sourcemap.missing);
13226
13338
  traceSourcemap: while (filteredSourcemapChain.length > 0) {
13227
13339
  const sourcemap = filteredSourcemapChain.pop();
13228
13340
  const line = sourcemap.mappings[location.line - 1];
@@ -13920,8 +14032,13 @@ class Module {
13920
14032
  timeStart('generate ast', 3);
13921
14033
  this.info.code = code;
13922
14034
  this.originalCode = originalCode;
13923
- this.originalSourcemap = originalSourcemap;
13924
- this.sourcemapChain = sourcemapChain;
14035
+ // We need to call decodedSourcemap on the input in case they were hydrated from json in the cache and don't
14036
+ // have the lazy evaluation cache configured. Right now this isn't enforced by the type system because the
14037
+ // RollupCache stores `ExistingDecodedSourcemap` instead of `ExistingRawSourcemap`
14038
+ this.originalSourcemap = decodedSourcemap(originalSourcemap);
14039
+ this.sourcemapChain = sourcemapChain.map(mapOrMissing => mapOrMissing.missing ? mapOrMissing : decodedSourcemap(mapOrMissing));
14040
+ // If coming from cache and this value is already fully decoded, we want to re-encode here to save memory.
14041
+ resetSourcemapCache(this.originalSourcemap, this.sourcemapChain);
13925
14042
  if (transformFiles) {
13926
14043
  this.transformFiles = transformFiles;
13927
14044
  }
@@ -15676,7 +15793,8 @@ class Chunk {
15676
15793
  finalizeChunk(code, map, hashesByPlaceholder) {
15677
15794
  const renderedChunkInfo = this.getRenderedChunkInfo();
15678
15795
  const finalize = (code) => replacePlaceholders(code, hashesByPlaceholder);
15679
- const fileName = (this.fileName = finalize(renderedChunkInfo.fileName));
15796
+ const preliminaryFileName = renderedChunkInfo.fileName;
15797
+ const fileName = (this.fileName = finalize(preliminaryFileName));
15680
15798
  return {
15681
15799
  ...renderedChunkInfo,
15682
15800
  code,
@@ -15689,6 +15807,7 @@ class Chunk {
15689
15807
  ])),
15690
15808
  imports: renderedChunkInfo.imports.map(finalize),
15691
15809
  map,
15810
+ preliminaryFileName,
15692
15811
  referencedFiles: renderedChunkInfo.referencedFiles.map(finalize)
15693
15812
  };
15694
15813
  }
@@ -17438,7 +17557,7 @@ class Link {
17438
17557
  }
17439
17558
  function getLinkMap(log) {
17440
17559
  return function linkMap(source, map) {
17441
- if (map.mappings) {
17560
+ if (!map.missing) {
17442
17561
  return new Link(map, [source]);
17443
17562
  }
17444
17563
  log(LOGLEVEL_WARN, logSourcemapBroken(map.plugin));
@@ -17477,6 +17596,9 @@ function collapseSourcemaps(file, map, modules, bundleSourcemapChain, excludeCon
17477
17596
  file = basename(file);
17478
17597
  }
17479
17598
  sourcesContent = (excludeContent ? null : sourcesContent);
17599
+ for (const module of modules) {
17600
+ resetSourcemapCache(module.originalSourcemap, module.sourcemapChain);
17601
+ }
17480
17602
  return new SourceMap({ file, mappings, names, sources, sourcesContent });
17481
17603
  }
17482
17604
  function collapseSourcemap(id, originalCode, originalSourcemap, sourcemapChain, log) {
@@ -17485,29 +17607,11 @@ function collapseSourcemap(id, originalCode, originalSourcemap, sourcemapChain,
17485
17607
  }
17486
17608
  const source = getCollapsedSourcemap(id, originalCode, originalSourcemap, sourcemapChain, getLinkMap(log));
17487
17609
  const map = source.traceMappings();
17488
- return { version: 3, ...map };
17610
+ return decodedSourcemap({ version: 3, ...map });
17489
17611
  }
17490
17612
 
17491
17613
  const createHash = () => createHash$1('sha256');
17492
17614
 
17493
- function decodedSourcemap(map) {
17494
- if (!map)
17495
- return null;
17496
- if (typeof map === 'string') {
17497
- map = JSON.parse(map);
17498
- }
17499
- if (map.mappings === '') {
17500
- return {
17501
- mappings: [],
17502
- names: [],
17503
- sources: [],
17504
- version: 3
17505
- };
17506
- }
17507
- const mappings = typeof map.mappings === 'string' ? decode(map.mappings) : map.mappings;
17508
- return { ...map, mappings };
17509
- }
17510
-
17511
17615
  async function renderChunks(chunks, bundle, pluginDriver, outputOptions, log) {
17512
17616
  timeStart('render chunks', 2);
17513
17617
  reserveEntryChunksInBundle(chunks);
@@ -24967,6 +25071,7 @@ class FileEmitter {
24967
25071
  moduleIds: [],
24968
25072
  modules: {},
24969
25073
  name: prebuiltChunk.fileName,
25074
+ preliminaryFileName: prebuiltChunk.fileName,
24970
25075
  referencedFiles: [],
24971
25076
  type: 'chunk'
24972
25077
  };
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v3.27.2
4
- Fri, 04 Aug 2023 11:31:37 GMT - commit ffd2239d550a22988f864316d294fcaab3b4bdae
3
+ Rollup.js v3.28.1
4
+ Tue, 22 Aug 2023 05:30:38 GMT - commit 1b557cd77cce8560cf073875cf6bc289bbe5f09c
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v3.27.2
4
- Fri, 04 Aug 2023 11:31:37 GMT - commit ffd2239d550a22988f864316d294fcaab3b4bdae
3
+ Rollup.js v3.28.1
4
+ Tue, 22 Aug 2023 05:30:38 GMT - commit 1b557cd77cce8560cf073875cf6bc289bbe5f09c
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v3.27.2
4
- Fri, 04 Aug 2023 11:31:37 GMT - commit ffd2239d550a22988f864316d294fcaab3b4bdae
3
+ Rollup.js v3.28.1
4
+ Tue, 22 Aug 2023 05:30:38 GMT - commit 1b557cd77cce8560cf073875cf6bc289bbe5f09c
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
package/dist/rollup.d.ts CHANGED
@@ -52,7 +52,7 @@ export type SourceMapSegment =
52
52
 
53
53
  export interface ExistingDecodedSourceMap {
54
54
  file?: string;
55
- mappings: SourceMapSegment[][];
55
+ readonly mappings: SourceMapSegment[][];
56
56
  names: string[];
57
57
  sourceRoot?: string;
58
58
  sources: string[];
@@ -74,11 +74,10 @@ export interface ExistingRawSourceMap {
74
74
 
75
75
  export type DecodedSourceMapOrMissing =
76
76
  | {
77
- mappings?: never;
78
77
  missing: true;
79
78
  plugin: string;
80
79
  }
81
- | ExistingDecodedSourceMap;
80
+ | (ExistingDecodedSourceMap & { missing?: false });
82
81
 
83
82
  export interface SourceMap {
84
83
  file: string;
@@ -828,7 +827,7 @@ export interface OutputAsset extends PreRenderedAsset {
828
827
  }
829
828
 
830
829
  export interface RenderedModule {
831
- code: string | null;
830
+ readonly code: string | null;
832
831
  originalLength: number;
833
832
  removedExports: string[];
834
833
  renderedExports: string[];
@@ -863,6 +862,7 @@ export interface RenderedChunk extends PreRenderedChunk {
863
862
  export interface OutputChunk extends RenderedChunk {
864
863
  code: string;
865
864
  map: SourceMap | null;
865
+ preliminaryFileName: string;
866
866
  }
867
867
 
868
868
  export interface SerializablePluginCache {
package/dist/rollup.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v3.27.2
4
- Fri, 04 Aug 2023 11:31:37 GMT - commit ffd2239d550a22988f864316d294fcaab3b4bdae
3
+ Rollup.js v3.28.1
4
+ Tue, 22 Aug 2023 05:30:38 GMT - commit 1b557cd77cce8560cf073875cf6bc289bbe5f09c
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v3.27.2
4
- Fri, 04 Aug 2023 11:31:37 GMT - commit ffd2239d550a22988f864316d294fcaab3b4bdae
3
+ Rollup.js v3.28.1
4
+ Tue, 22 Aug 2023 05:30:38 GMT - commit 1b557cd77cce8560cf073875cf6bc289bbe5f09c
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v3.27.2
4
- Fri, 04 Aug 2023 11:31:37 GMT - commit ffd2239d550a22988f864316d294fcaab3b4bdae
3
+ Rollup.js v3.28.1
4
+ Tue, 22 Aug 2023 05:30:38 GMT - commit 1b557cd77cce8560cf073875cf6bc289bbe5f09c
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v3.27.2
4
- Fri, 04 Aug 2023 11:31:37 GMT - commit ffd2239d550a22988f864316d294fcaab3b4bdae
3
+ Rollup.js v3.28.1
4
+ Tue, 22 Aug 2023 05:30:38 GMT - commit 1b557cd77cce8560cf073875cf6bc289bbe5f09c
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v3.27.2
4
- Fri, 04 Aug 2023 11:31:37 GMT - commit ffd2239d550a22988f864316d294fcaab3b4bdae
3
+ Rollup.js v3.28.1
4
+ Tue, 22 Aug 2023 05:30:38 GMT - commit 1b557cd77cce8560cf073875cf6bc289bbe5f09c
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -30,7 +30,7 @@ function _interopNamespaceDefault(e) {
30
30
 
31
31
  const tty__namespace = /*#__PURE__*/_interopNamespaceDefault(tty);
32
32
 
33
- var version$1 = "3.27.2";
33
+ var version$1 = "3.28.1";
34
34
 
35
35
  function ensureArray$1(items) {
36
36
  if (Array.isArray(items)) {
@@ -273,6 +273,10 @@ function isPathFragment(name) {
273
273
  }
274
274
  const UPPER_DIR_REGEX = /^(\.\.\/)*\.\.$/;
275
275
  function getImportPath(importerId, targetPath, stripJsExtension, ensureFileName) {
276
+ while (targetPath.startsWith('../')) {
277
+ targetPath = targetPath.slice(3);
278
+ importerId = '_/' + importerId;
279
+ }
276
280
  let relativePath = normalize(relative(node_path.dirname(importerId), targetPath));
277
281
  if (stripJsExtension && relativePath.endsWith('.js')) {
278
282
  relativePath = relativePath.slice(0, -3);
@@ -1278,6 +1282,7 @@ class FileEmitter {
1278
1282
  moduleIds: [],
1279
1283
  modules: {},
1280
1284
  name: prebuiltChunk.fileName,
1285
+ preliminaryFileName: prebuiltChunk.fileName,
1281
1286
  referencedFiles: [],
1282
1287
  type: 'chunk'
1283
1288
  };
@@ -2670,6 +2675,13 @@ let Chunk$1 = class Chunk {
2670
2675
  this.end = index;
2671
2676
 
2672
2677
  if (this.edited) {
2678
+ // after split we should save the edit content record into the correct chunk
2679
+ // to make sure sourcemap correct
2680
+ // For example:
2681
+ // ' test'.trim()
2682
+ // split -> ' ' + 'test'
2683
+ // ✔️ edit -> '' + 'test'
2684
+ // ✖️ edit -> 'test' + ''
2673
2685
  // TODO is this block necessary?...
2674
2686
  newChunk.edit('', false);
2675
2687
  this.content = '';
@@ -2698,6 +2710,10 @@ let Chunk$1 = class Chunk {
2698
2710
  if (trimmed.length) {
2699
2711
  if (trimmed !== this.content) {
2700
2712
  this.split(this.start + trimmed.length).edit('', undefined, true);
2713
+ if (this.edited) {
2714
+ // save the change, if it has been edited
2715
+ this.edit(trimmed, this.storeName, true);
2716
+ }
2701
2717
  }
2702
2718
  return true;
2703
2719
  } else {
@@ -2716,7 +2732,11 @@ let Chunk$1 = class Chunk {
2716
2732
 
2717
2733
  if (trimmed.length) {
2718
2734
  if (trimmed !== this.content) {
2719
- this.split(this.end - trimmed.length);
2735
+ const newChunk = this.split(this.end - trimmed.length);
2736
+ if (this.edited) {
2737
+ // save the change, if it has been edited
2738
+ newChunk.edit(trimmed, this.storeName, true);
2739
+ }
2720
2740
  this.edit('', undefined, true);
2721
2741
  }
2722
2742
  return true;
@@ -2729,7 +2749,7 @@ let Chunk$1 = class Chunk {
2729
2749
  }
2730
2750
  };
2731
2751
 
2732
- function getBtoa () {
2752
+ function getBtoa() {
2733
2753
  if (typeof window !== 'undefined' && typeof window.btoa === 'function') {
2734
2754
  return (str) => window.btoa(unescape(encodeURIComponent(str)));
2735
2755
  } else if (typeof Buffer === 'function') {
@@ -2842,6 +2862,8 @@ function getLocator(source) {
2842
2862
  };
2843
2863
  }
2844
2864
 
2865
+ const wordRegex = /\w/;
2866
+
2845
2867
  class Mappings {
2846
2868
  constructor(hires) {
2847
2869
  this.hires = hires;
@@ -2870,10 +2892,29 @@ class Mappings {
2870
2892
  addUneditedChunk(sourceIndex, chunk, original, loc, sourcemapLocations) {
2871
2893
  let originalCharIndex = chunk.start;
2872
2894
  let first = true;
2895
+ // when iterating each char, check if it's in a word boundary
2896
+ let charInHiresBoundary = false;
2873
2897
 
2874
2898
  while (originalCharIndex < chunk.end) {
2875
2899
  if (this.hires || first || sourcemapLocations.has(originalCharIndex)) {
2876
- this.rawSegments.push([this.generatedCodeColumn, sourceIndex, loc.line, loc.column]);
2900
+ const segment = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column];
2901
+
2902
+ if (this.hires === 'boundary') {
2903
+ // in hires "boundary", group segments per word boundary than per char
2904
+ if (wordRegex.test(original[originalCharIndex])) {
2905
+ // for first char in the boundary found, start the boundary by pushing a segment
2906
+ if (!charInHiresBoundary) {
2907
+ this.rawSegments.push(segment);
2908
+ charInHiresBoundary = true;
2909
+ }
2910
+ } else {
2911
+ // for non-word char, end the boundary by pushing a segment
2912
+ this.rawSegments.push(segment);
2913
+ charInHiresBoundary = false;
2914
+ }
2915
+ } else {
2916
+ this.rawSegments.push(segment);
2917
+ }
2877
2918
  }
2878
2919
 
2879
2920
  if (original[originalCharIndex] === '\n') {
@@ -3046,7 +3087,7 @@ class MagicString {
3046
3087
  sourceIndex,
3047
3088
  chunk.content,
3048
3089
  loc,
3049
- chunk.storeName ? names.indexOf(chunk.original) : -1
3090
+ chunk.storeName ? names.indexOf(chunk.original) : -1,
3050
3091
  );
3051
3092
  } else {
3052
3093
  mappings.addUneditedChunk(sourceIndex, chunk, this.original, loc, this.sourcemapLocations);
@@ -3057,11 +3098,13 @@ class MagicString {
3057
3098
 
3058
3099
  return {
3059
3100
  file: options.file ? options.file.split(/[/\\]/).pop() : undefined,
3060
- sources: [options.source ? getRelativePath(options.file || '', options.source) : (options.file || '')],
3101
+ sources: [
3102
+ options.source ? getRelativePath(options.file || '', options.source) : options.file || '',
3103
+ ],
3061
3104
  sourcesContent: options.includeContent ? [this.original] : undefined,
3062
3105
  names,
3063
3106
  mappings: mappings.raw,
3064
- x_google_ignoreList: this.ignoreList ? [sourceIndex] : undefined
3107
+ x_google_ignoreList: this.ignoreList ? [sourceIndex] : undefined,
3065
3108
  };
3066
3109
  }
3067
3110
 
@@ -3175,14 +3218,14 @@ class MagicString {
3175
3218
 
3176
3219
  insert() {
3177
3220
  throw new Error(
3178
- 'magicString.insert(...) is deprecated. Use prependRight(...) or appendLeft(...)'
3221
+ 'magicString.insert(...) is deprecated. Use prependRight(...) or appendLeft(...)',
3179
3222
  );
3180
3223
  }
3181
3224
 
3182
3225
  insertLeft(index, content) {
3183
3226
  if (!warned.insertLeft) {
3184
3227
  console.warn(
3185
- 'magicString.insertLeft(...) is deprecated. Use magicString.appendLeft(...) instead'
3228
+ 'magicString.insertLeft(...) is deprecated. Use magicString.appendLeft(...) instead',
3186
3229
  ); // eslint-disable-line no-console
3187
3230
  warned.insertLeft = true;
3188
3231
  }
@@ -3193,7 +3236,7 @@ class MagicString {
3193
3236
  insertRight(index, content) {
3194
3237
  if (!warned.insertRight) {
3195
3238
  console.warn(
3196
- 'magicString.insertRight(...) is deprecated. Use magicString.prependRight(...) instead'
3239
+ 'magicString.insertRight(...) is deprecated. Use magicString.prependRight(...) instead',
3197
3240
  ); // eslint-disable-line no-console
3198
3241
  warned.insertRight = true;
3199
3242
  }
@@ -3252,7 +3295,7 @@ class MagicString {
3252
3295
  if (end > this.original.length) throw new Error('end is out of bounds');
3253
3296
  if (start === end)
3254
3297
  throw new Error(
3255
- 'Cannot overwrite a zero-length range – use appendLeft or prependRight instead'
3298
+ 'Cannot overwrite a zero-length range – use appendLeft or prependRight instead',
3256
3299
  );
3257
3300
 
3258
3301
  this._split(start);
@@ -3261,7 +3304,7 @@ class MagicString {
3261
3304
  if (options === true) {
3262
3305
  if (!warned.storeName) {
3263
3306
  console.warn(
3264
- 'The final argument to magicString.overwrite(...) should be an options object. See https://github.com/rich-harris/magic-string'
3307
+ 'The final argument to magicString.overwrite(...) should be an options object. See https://github.com/rich-harris/magic-string',
3265
3308
  ); // eslint-disable-line no-console
3266
3309
  warned.storeName = true;
3267
3310
  }
@@ -3483,7 +3526,7 @@ class MagicString {
3483
3526
  // zero-length edited chunks are a special case (overlapping replacements)
3484
3527
  const loc = getLocator(this.original)(index);
3485
3528
  throw new Error(
3486
- `Cannot split a chunk that has already been edited (${loc.line}:${loc.column} – "${chunk.original}")`
3529
+ `Cannot split a chunk that has already been edited (${loc.line}:${loc.column} – "${chunk.original}")`,
3487
3530
  );
3488
3531
  }
3489
3532
 
@@ -3642,7 +3685,7 @@ class MagicString {
3642
3685
  this.overwrite(
3643
3686
  match.index,
3644
3687
  match.index + match[0].length,
3645
- getReplacement(match, this.original)
3688
+ getReplacement(match, this.original),
3646
3689
  );
3647
3690
  });
3648
3691
  } else {
@@ -3651,7 +3694,7 @@ class MagicString {
3651
3694
  this.overwrite(
3652
3695
  match.index,
3653
3696
  match.index + match[0].length,
3654
- getReplacement(match, this.original)
3697
+ getReplacement(match, this.original),
3655
3698
  );
3656
3699
  }
3657
3700
  return this;
@@ -3697,7 +3740,7 @@ class MagicString {
3697
3740
 
3698
3741
  if (!searchValue.global) {
3699
3742
  throw new TypeError(
3700
- 'MagicString.prototype.replaceAll called with a non-global RegExp argument'
3743
+ 'MagicString.prototype.replaceAll called with a non-global RegExp argument',
3701
3744
  );
3702
3745
  }
3703
3746
 
@@ -3727,7 +3770,7 @@ let Bundle$1 = class Bundle {
3727
3770
 
3728
3771
  if (!isObject$1(source) || !source.content) {
3729
3772
  throw new Error(
3730
- 'bundle.addSource() takes an object with a `content` property, which should be an instance of MagicString, and an optional `filename`'
3773
+ 'bundle.addSource() takes an object with a `content` property, which should be an instance of MagicString, and an optional `filename`',
3731
3774
  );
3732
3775
  }
3733
3776
 
@@ -3821,7 +3864,7 @@ let Bundle$1 = class Bundle {
3821
3864
  sourceIndex,
3822
3865
  chunk.content,
3823
3866
  loc,
3824
- chunk.storeName ? names.indexOf(chunk.original) : -1
3867
+ chunk.storeName ? names.indexOf(chunk.original) : -1,
3825
3868
  );
3826
3869
  } else {
3827
3870
  mappings.addUneditedChunk(
@@ -3829,7 +3872,7 @@ let Bundle$1 = class Bundle {
3829
3872
  chunk,
3830
3873
  magicString.original,
3831
3874
  loc,
3832
- magicString.sourcemapLocations
3875
+ magicString.sourcemapLocations,
3833
3876
  );
3834
3877
  }
3835
3878
  } else {
@@ -3947,7 +3990,7 @@ let Bundle$1 = class Bundle {
3947
3990
  length() {
3948
3991
  return this.sources.reduce(
3949
3992
  (length, source) => length + source.content.length(),
3950
- this.intro.length
3993
+ this.intro.length,
3951
3994
  );
3952
3995
  }
3953
3996
 
@@ -6566,7 +6609,7 @@ const normalizePath = function normalizePath(filename) {
6566
6609
  };
6567
6610
 
6568
6611
  function getMatcherString(id, resolutionBase) {
6569
- if (resolutionBase === false || require$$0$1.isAbsolute(id) || id.startsWith('*')) {
6612
+ if (resolutionBase === false || require$$0$1.isAbsolute(id) || id.startsWith('**')) {
6570
6613
  return normalizePath(id);
6571
6614
  }
6572
6615
  // resolve('') is valid and will default to process.cwd()
@@ -14706,12 +14749,82 @@ class SyntheticNamedExportVariable extends Variable {
14706
14749
  }
14707
14750
  }
14708
14751
 
14752
+ const sourceMapCache = new WeakMap();
14753
+ /**
14754
+ * This clears the decoded array and falls back to the encoded string form.
14755
+ * Sourcemap mappings arrays can be very large and holding on to them for longer
14756
+ * than is necessary leads to poor heap utilization.
14757
+ */
14758
+ function resetCacheToEncoded(cache) {
14759
+ if (cache.encodedMappings === undefined && cache.decodedMappings) {
14760
+ cache.encodedMappings = encode(cache.decodedMappings);
14761
+ }
14762
+ cache.decodedMappings = undefined;
14763
+ }
14764
+ function resetSourcemapCache(map, sourcemapChain) {
14765
+ if (map) {
14766
+ const cache = sourceMapCache.get(map);
14767
+ if (cache) {
14768
+ resetCacheToEncoded(cache);
14769
+ }
14770
+ }
14771
+ if (!sourcemapChain) {
14772
+ return;
14773
+ }
14774
+ for (const map of sourcemapChain) {
14775
+ if (map.missing)
14776
+ continue;
14777
+ resetSourcemapCache(map);
14778
+ }
14779
+ }
14780
+ function decodedSourcemap(map) {
14781
+ if (!map)
14782
+ return null;
14783
+ if (typeof map === 'string') {
14784
+ map = JSON.parse(map);
14785
+ }
14786
+ if (!map.mappings) {
14787
+ return {
14788
+ mappings: [],
14789
+ names: [],
14790
+ sources: [],
14791
+ version: 3
14792
+ };
14793
+ }
14794
+ const originalMappings = map.mappings;
14795
+ const isAlreadyDecoded = Array.isArray(originalMappings);
14796
+ const cache = {
14797
+ decodedMappings: isAlreadyDecoded ? originalMappings : undefined,
14798
+ encodedMappings: isAlreadyDecoded ? undefined : originalMappings
14799
+ };
14800
+ const decodedMap = {
14801
+ ...map,
14802
+ // By moving mappings behind an accessor, we can avoid unneeded computation for cases
14803
+ // where the mappings field is never actually accessed. This appears to greatly reduce
14804
+ // the overhead of sourcemap decoding in terms of both compute time and memory usage.
14805
+ get mappings() {
14806
+ if (cache.decodedMappings) {
14807
+ return cache.decodedMappings;
14808
+ }
14809
+ // If decodedMappings doesn't exist then encodedMappings should.
14810
+ // The only scenario where cache.encodedMappings should be undefined is if the map
14811
+ // this was constructed from was already decoded, or if mappings was set to a new
14812
+ // decoded string. In either case, this line shouldn't get hit.
14813
+ cache.decodedMappings = cache.encodedMappings ? decode(cache.encodedMappings) : [];
14814
+ cache.encodedMappings = undefined;
14815
+ return cache.decodedMappings;
14816
+ }
14817
+ };
14818
+ sourceMapCache.set(decodedMap, cache);
14819
+ return decodedMap;
14820
+ }
14821
+
14709
14822
  function getId(m) {
14710
14823
  return m.id;
14711
14824
  }
14712
14825
 
14713
14826
  function getOriginalLocation(sourcemapChain, location) {
14714
- const filteredSourcemapChain = sourcemapChain.filter((sourcemap) => !!sourcemap.mappings);
14827
+ const filteredSourcemapChain = sourcemapChain.filter((sourcemap) => !sourcemap.missing);
14715
14828
  traceSourcemap: while (filteredSourcemapChain.length > 0) {
14716
14829
  const sourcemap = filteredSourcemapChain.pop();
14717
14830
  const line = sourcemap.mappings[location.line - 1];
@@ -15409,8 +15522,13 @@ class Module {
15409
15522
  timeStart('generate ast', 3);
15410
15523
  this.info.code = code;
15411
15524
  this.originalCode = originalCode;
15412
- this.originalSourcemap = originalSourcemap;
15413
- this.sourcemapChain = sourcemapChain;
15525
+ // We need to call decodedSourcemap on the input in case they were hydrated from json in the cache and don't
15526
+ // have the lazy evaluation cache configured. Right now this isn't enforced by the type system because the
15527
+ // RollupCache stores `ExistingDecodedSourcemap` instead of `ExistingRawSourcemap`
15528
+ this.originalSourcemap = decodedSourcemap(originalSourcemap);
15529
+ this.sourcemapChain = sourcemapChain.map(mapOrMissing => mapOrMissing.missing ? mapOrMissing : decodedSourcemap(mapOrMissing));
15530
+ // If coming from cache and this value is already fully decoded, we want to re-encode here to save memory.
15531
+ resetSourcemapCache(this.originalSourcemap, this.sourcemapChain);
15414
15532
  if (transformFiles) {
15415
15533
  this.transformFiles = transformFiles;
15416
15534
  }
@@ -17060,7 +17178,8 @@ class Chunk {
17060
17178
  finalizeChunk(code, map, hashesByPlaceholder) {
17061
17179
  const renderedChunkInfo = this.getRenderedChunkInfo();
17062
17180
  const finalize = (code) => replacePlaceholders(code, hashesByPlaceholder);
17063
- const fileName = (this.fileName = finalize(renderedChunkInfo.fileName));
17181
+ const preliminaryFileName = renderedChunkInfo.fileName;
17182
+ const fileName = (this.fileName = finalize(preliminaryFileName));
17064
17183
  return {
17065
17184
  ...renderedChunkInfo,
17066
17185
  code,
@@ -17073,6 +17192,7 @@ class Chunk {
17073
17192
  ])),
17074
17193
  imports: renderedChunkInfo.imports.map(finalize),
17075
17194
  map,
17195
+ preliminaryFileName,
17076
17196
  referencedFiles: renderedChunkInfo.referencedFiles.map(finalize)
17077
17197
  };
17078
17198
  }
@@ -18822,7 +18942,7 @@ class Link {
18822
18942
  }
18823
18943
  function getLinkMap(log) {
18824
18944
  return function linkMap(source, map) {
18825
- if (map.mappings) {
18945
+ if (!map.missing) {
18826
18946
  return new Link(map, [source]);
18827
18947
  }
18828
18948
  log(LOGLEVEL_WARN, logSourcemapBroken(map.plugin));
@@ -18861,6 +18981,9 @@ function collapseSourcemaps(file, map, modules, bundleSourcemapChain, excludeCon
18861
18981
  file = node_path.basename(file);
18862
18982
  }
18863
18983
  sourcesContent = (excludeContent ? null : sourcesContent);
18984
+ for (const module of modules) {
18985
+ resetSourcemapCache(module.originalSourcemap, module.sourcemapChain);
18986
+ }
18864
18987
  return new SourceMap({ file, mappings, names, sources, sourcesContent });
18865
18988
  }
18866
18989
  function collapseSourcemap(id, originalCode, originalSourcemap, sourcemapChain, log) {
@@ -18869,25 +18992,7 @@ function collapseSourcemap(id, originalCode, originalSourcemap, sourcemapChain,
18869
18992
  }
18870
18993
  const source = getCollapsedSourcemap(id, originalCode, originalSourcemap, sourcemapChain, getLinkMap(log));
18871
18994
  const map = source.traceMappings();
18872
- return { version: 3, ...map };
18873
- }
18874
-
18875
- function decodedSourcemap(map) {
18876
- if (!map)
18877
- return null;
18878
- if (typeof map === 'string') {
18879
- map = JSON.parse(map);
18880
- }
18881
- if (map.mappings === '') {
18882
- return {
18883
- mappings: [],
18884
- names: [],
18885
- sources: [],
18886
- version: 3
18887
- };
18888
- }
18889
- const mappings = typeof map.mappings === 'string' ? decode(map.mappings) : map.mappings;
18890
- return { ...map, mappings };
18995
+ return decodedSourcemap({ version: 3, ...map });
18891
18996
  }
18892
18997
 
18893
18998
  async function renderChunks(chunks, bundle, pluginDriver, outputOptions, log) {
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v3.27.2
4
- Fri, 04 Aug 2023 11:31:37 GMT - commit ffd2239d550a22988f864316d294fcaab3b4bdae
3
+ Rollup.js v3.28.1
4
+ Tue, 22 Aug 2023 05:30:38 GMT - commit 1b557cd77cce8560cf073875cf6bc289bbe5f09c
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -126,7 +126,7 @@ const processOk = (process) => !!process &&
126
126
  const kExitEmitter = Symbol.for('signal-exit emitter');
127
127
  const global = globalThis;
128
128
  const ObjectDefineProperty = Object.defineProperty.bind(Object);
129
- // teeny tiny ee
129
+ // teeny special purpose ee
130
130
  class Emitter {
131
131
  emitted = {
132
132
  afterExit: false,
@@ -169,12 +169,17 @@ class Emitter {
169
169
  }
170
170
  emit(ev, code, signal) {
171
171
  if (this.emitted[ev]) {
172
- return;
172
+ return false;
173
173
  }
174
174
  this.emitted[ev] = true;
175
+ let ret = false;
175
176
  for (const fn of this.listeners[ev]) {
176
- fn(code, signal);
177
+ ret = fn(code, signal) === true || ret;
178
+ }
179
+ if (ev === 'exit') {
180
+ ret = this.emit('afterExit', code, signal) || ret;
177
181
  }
182
+ return ret;
178
183
  }
179
184
  }
180
185
  class SignalExitBase {
@@ -228,18 +233,22 @@ class SignalExit extends SignalExitBase {
228
233
  // exit v4 are not aware of each other, and each will attempt to let
229
234
  // the other handle it, so neither of them do. To correct this, we
230
235
  // detect if we're the only handler *except* for previous versions
231
- // of signal-exit.
236
+ // of signal-exit, and increment by the count of listeners it has
237
+ // created.
232
238
  /* c8 ignore start */
233
- //@ts-ignore
234
- if (typeof process.__signal_exit_emitter__ === 'object')
235
- count++;
239
+ const p = process;
240
+ if (typeof p.__signal_exit_emitter__ === 'object' &&
241
+ typeof p.__signal_exit_emitter__.count === 'number') {
242
+ count += p.__signal_exit_emitter__.count;
243
+ }
236
244
  /* c8 ignore stop */
237
245
  if (listeners.length === count) {
238
246
  this.unload();
239
- this.#emitter.emit('exit', null, sig);
240
- this.#emitter.emit('afterExit', null, sig);
247
+ const ret = this.#emitter.emit('exit', null, sig);
241
248
  /* c8 ignore start */
242
- process.kill(process.pid, sig === 'SIGHUP' ? this.#hupSig : sig);
249
+ const s = sig === 'SIGHUP' ? this.#hupSig : sig;
250
+ if (!ret)
251
+ process.kill(process.pid, s);
243
252
  /* c8 ignore stop */
244
253
  }
245
254
  };
@@ -322,7 +331,6 @@ class SignalExit extends SignalExitBase {
322
331
  this.#process.exitCode = code || 0;
323
332
  /* c8 ignore stop */
324
333
  this.#emitter.emit('exit', this.#process.exitCode, null);
325
- this.#emitter.emit('afterExit', this.#process.exitCode, null);
326
334
  return this.#originalProcessReallyExit.call(this.#process, this.#process.exitCode);
327
335
  }
328
336
  #processEmit(ev, ...args) {
@@ -336,7 +344,6 @@ class SignalExit extends SignalExitBase {
336
344
  const ret = og.call(this.#process, ev, ...args);
337
345
  /* c8 ignore start */
338
346
  this.#emitter.emit('exit', this.#process.exitCode, null);
339
- this.#emitter.emit('afterExit', this.#process.exitCode, null);
340
347
  /* c8 ignore stop */
341
348
  return ret;
342
349
  }
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v3.27.2
4
- Fri, 04 Aug 2023 11:31:37 GMT - commit ffd2239d550a22988f864316d294fcaab3b4bdae
3
+ Rollup.js v3.28.1
4
+ Tue, 22 Aug 2023 05:30:38 GMT - commit 1b557cd77cce8560cf073875cf6bc289bbe5f09c
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v3.27.2
4
- Fri, 04 Aug 2023 11:31:37 GMT - commit ffd2239d550a22988f864316d294fcaab3b4bdae
3
+ Rollup.js v3.28.1
4
+ Tue, 22 Aug 2023 05:30:38 GMT - commit 1b557cd77cce8560cf073875cf6bc289bbe5f09c
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rollup",
3
- "version": "3.27.2",
3
+ "version": "3.28.1",
4
4
  "description": "Next-generation ES module bundler",
5
5
  "main": "dist/rollup.js",
6
6
  "module": "dist/es/rollup.js",
@@ -65,27 +65,27 @@
65
65
  "devDependencies": {
66
66
  "@codemirror/commands": "^6.2.4",
67
67
  "@codemirror/lang-javascript": "^6.1.9",
68
- "@codemirror/language": "^6.8.0",
69
- "@codemirror/search": "^6.5.0",
68
+ "@codemirror/language": "^6.9.0",
69
+ "@codemirror/search": "^6.5.1",
70
70
  "@codemirror/state": "^6.2.1",
71
- "@codemirror/view": "^6.14.1",
71
+ "@codemirror/view": "^6.16.0",
72
72
  "@jridgewell/sourcemap-codec": "^1.4.15",
73
- "@mermaid-js/mermaid-cli": "^10.2.4",
73
+ "@mermaid-js/mermaid-cli": "^10.3.1",
74
74
  "@rollup/plugin-alias": "^5.0.0",
75
75
  "@rollup/plugin-buble": "^1.0.2",
76
- "@rollup/plugin-commonjs": "^25.0.3",
76
+ "@rollup/plugin-commonjs": "^25.0.4",
77
77
  "@rollup/plugin-json": "^6.0.0",
78
- "@rollup/plugin-node-resolve": "^15.1.0",
78
+ "@rollup/plugin-node-resolve": "^15.2.0",
79
79
  "@rollup/plugin-replace": "^5.0.2",
80
80
  "@rollup/plugin-terser": "^0.4.3",
81
81
  "@rollup/plugin-typescript": "^11.1.2",
82
- "@rollup/pluginutils": "^5.0.2",
82
+ "@rollup/pluginutils": "^5.0.3",
83
83
  "@types/estree": "1.0.1",
84
84
  "@types/mocha": "^10.0.1",
85
85
  "@types/node": "~14.18.54",
86
86
  "@types/yargs-parser": "^21.0.0",
87
- "@typescript-eslint/eslint-plugin": "^6.2.0",
88
- "@typescript-eslint/parser": "^6.2.0",
87
+ "@typescript-eslint/eslint-plugin": "^6.4.0",
88
+ "@typescript-eslint/parser": "^6.4.0",
89
89
  "@vue/eslint-config-prettier": "^8.0.0",
90
90
  "@vue/eslint-config-typescript": "^11.0.3",
91
91
  "acorn": "^8.10.0",
@@ -97,49 +97,49 @@
97
97
  "chokidar": "^3.5.3",
98
98
  "colorette": "^2.0.20",
99
99
  "concurrently": "^8.2.0",
100
- "core-js": "^3.31.1",
100
+ "core-js": "^3.32.1",
101
101
  "date-time": "^4.0.0",
102
102
  "es5-shim": "^4.6.7",
103
103
  "es6-shim": "^0.35.8",
104
- "eslint": "^8.45.0",
105
- "eslint-config-prettier": "^8.8.0",
106
- "eslint-plugin-import": "^2.27.5",
104
+ "eslint": "^8.47.0",
105
+ "eslint-config-prettier": "^9.0.0",
106
+ "eslint-plugin-import": "^2.28.1",
107
107
  "eslint-plugin-prettier": "^5.0.0",
108
- "eslint-plugin-unicorn": "^48.0.0",
109
- "eslint-plugin-vue": "^9.15.1",
108
+ "eslint-plugin-unicorn": "^48.0.1",
109
+ "eslint-plugin-vue": "^9.17.0",
110
110
  "fixturify": "^3.0.0",
111
111
  "flru": "^1.0.2",
112
112
  "fs-extra": "^11.1.1",
113
113
  "github-api": "^3.4.0",
114
114
  "hash.js": "^1.1.7",
115
115
  "husky": "^8.0.3",
116
- "inquirer": "^9.2.8",
116
+ "inquirer": "^9.2.10",
117
117
  "is-reference": "^3.0.1",
118
- "lint-staged": "^13.2.3",
118
+ "lint-staged": "^14.0.0",
119
119
  "locate-character": "^3.0.0",
120
- "magic-string": "^0.30.1",
120
+ "magic-string": "^0.30.2",
121
121
  "mocha": "^10.2.0",
122
122
  "nyc": "^15.1.0",
123
- "pinia": "^2.1.4",
124
- "prettier": "^3.0.0",
123
+ "pinia": "^2.1.6",
124
+ "prettier": "^3.0.2",
125
125
  "pretty-bytes": "^6.1.1",
126
126
  "pretty-ms": "^8.0.0",
127
127
  "requirejs": "^2.3.6",
128
- "rollup": "^3.26.3",
128
+ "rollup": "^3.28.0",
129
129
  "rollup-plugin-license": "^3.0.1",
130
130
  "rollup-plugin-string": "^3.0.0",
131
131
  "rollup-plugin-thatworks": "^1.0.4",
132
132
  "semver": "^7.5.4",
133
133
  "shx": "^0.3.4",
134
- "signal-exit": "^4.0.2",
134
+ "signal-exit": "^4.1.0",
135
135
  "source-map": "^0.7.4",
136
136
  "source-map-support": "^0.5.21",
137
- "systemjs": "^6.14.1",
137
+ "systemjs": "^6.14.2",
138
138
  "terser": "^5.19.2",
139
- "tslib": "^2.6.1",
139
+ "tslib": "^2.6.2",
140
140
  "typescript": "^5.1.6",
141
- "vite": "^4.4.7",
142
- "vitepress": "^1.0.0-beta.6",
141
+ "vite": "^4.4.9",
142
+ "vitepress": "^1.0.0-rc.4",
143
143
  "vue": "^3.3.4",
144
144
  "weak-napi": "^2.0.2",
145
145
  "yargs-parser": "^21.1.1"