rollup 2.61.0 → 2.64.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 v2.61.0
4
- Thu, 09 Dec 2021 05:43:43 GMT - commit 49d41f78987a1dd13488df009fe2db1b5d1b6e7c
3
+ Rollup.js v2.64.0
4
+ Fri, 14 Jan 2022 14:02:32 GMT - commit 82a3e2634a9d51b5040752e4fb2fd264651d504e
5
5
 
6
6
 
7
7
  https://github.com/rollup/rollup
@@ -10,10 +10,12 @@
10
10
  */
11
11
  'use strict';
12
12
 
13
- const path$2 = require('path');
13
+ const require$$0 = require('path');
14
+ const process$1 = require('process');
15
+ const perf_hooks = require('perf_hooks');
14
16
  const crypto = require('crypto');
15
17
  const fs = require('fs');
16
- const require$$0 = require('events');
18
+ const require$$0$1 = require('events');
17
19
 
18
20
  function _interopNamespaceDefault(e) {
19
21
  const n = Object.create(null);
@@ -26,7 +28,7 @@ function _interopNamespaceDefault(e) {
26
28
  return n;
27
29
  }
28
30
 
29
- var version$1 = "2.61.0";
31
+ var version$1 = "2.64.0";
30
32
 
31
33
  function ensureArray$1(items) {
32
34
  if (Array.isArray(items)) {
@@ -140,13 +142,13 @@ function normalize(path) {
140
142
  }
141
143
 
142
144
  function getAliasName(id) {
143
- const base = path$2.basename(id);
144
- return base.substr(0, base.length - path$2.extname(id).length);
145
+ const base = require$$0.basename(id);
146
+ return base.substr(0, base.length - require$$0.extname(id).length);
145
147
  }
146
148
  function relativeId(id) {
147
149
  if (!isAbsolute(id))
148
150
  return id;
149
- return path$2.relative(path$2.resolve(), id);
151
+ return require$$0.relative(require$$0.resolve(), id);
150
152
  }
151
153
  function isPathFragment(name) {
152
154
  // starting with "/", "./", "../", "C:/"
@@ -554,6 +556,7 @@ const generatedCodePresets = {
554
556
  reservedNamesAsProps: true
555
557
  }
556
558
  };
559
+ const objectifyOption = (value) => value && typeof value === 'object' ? value : {};
557
560
  const objectifyOptionWithPresets = (presets, optionName, additionalValues) => (value) => {
558
561
  if (typeof value === 'string') {
559
562
  const preset = presets[value];
@@ -562,7 +565,7 @@ const objectifyOptionWithPresets = (presets, optionName, additionalValues) => (v
562
565
  }
563
566
  error(errInvalidOption(optionName, getHashFromObjectOption(optionName), `valid values are ${additionalValues}${printQuotedStringList(Object.keys(presets))}. You can also supply an object for more fine-grained control`, value));
564
567
  }
565
- return value && typeof value === 'object' ? value : {};
568
+ return objectifyOption(value);
566
569
  };
567
570
  const getOptionWithPreset = (value, presets, optionName, additionalValues) => {
568
571
  var _a;
@@ -582,19 +585,45 @@ const getHashFromObjectOption = (optionName) => optionName.split('.').join('').t
582
585
 
583
586
  let fsEvents;
584
587
  let fsEventsImportError;
585
- function loadFsEvents() {
588
+ async function loadFsEvents() {
586
589
  const moduleName = 'fsevents';
587
- return Promise.resolve().then(() => /*#__PURE__*/_interopNamespaceDefault(require(moduleName)))
588
- .then(namespace => {
589
- fsEvents = namespace.default;
590
- })
591
- .catch(err => {
590
+ try {
591
+ ({ default: fsEvents } = await Promise.resolve().then(() => /*#__PURE__*/_interopNamespaceDefault(require(moduleName))));
592
+ }
593
+ catch (err) {
592
594
  fsEventsImportError = err;
593
- });
595
+ }
594
596
  }
597
+ // A call to this function will be injected into the chokidar code
598
+ function getFsEvents() {
599
+ if (fsEventsImportError)
600
+ throw fsEventsImportError;
601
+ return fsEvents;
602
+ }
603
+
604
+ const fseventsImporter = {
605
+ __proto__: null,
606
+ loadFsEvents,
607
+ getFsEvents
608
+ };
595
609
 
596
610
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
597
611
 
612
+ function getAugmentedNamespace(n) {
613
+ if (n.__esModule) return n;
614
+ var a = Object.defineProperty({}, '__esModule', {value: true});
615
+ Object.keys(n).forEach(function (k) {
616
+ var d = Object.getOwnPropertyDescriptor(n, k);
617
+ Object.defineProperty(a, k, d.get ? d : {
618
+ enumerable: true,
619
+ get: function () {
620
+ return n[k];
621
+ }
622
+ });
623
+ });
624
+ return a;
625
+ }
626
+
598
627
  var charToInteger = {};
599
628
  var chars$1 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
600
629
  for (var i = 0; i < chars$1.length; i++) {
@@ -2225,20 +2254,70 @@ const BLANK = Object.freeze(Object.create(null));
2225
2254
  const EMPTY_OBJECT = Object.freeze({});
2226
2255
  const EMPTY_ARRAY = Object.freeze([]);
2227
2256
 
2228
- const reservedWords$2 = 'break case class catch const continue debugger default delete do else export extends finally for function if import in instanceof let new return super switch this throw try typeof var void while with yield enum await implements package protected static interface private public'.split(' ');
2229
- const builtins$2 = 'Infinity NaN undefined null true false eval uneval isFinite isNaN parseFloat parseInt decodeURI decodeURIComponent encodeURI encodeURIComponent escape unescape Object Function Boolean Symbol Error EvalError InternalError RangeError ReferenceError SyntaxError TypeError URIError Number Math Date String RegExp Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array Map Set WeakMap WeakSet SIMD ArrayBuffer DataView JSON Promise Generator GeneratorFunction Reflect Proxy Intl'.split(' ');
2230
- const blacklisted = new Set(reservedWords$2.concat(builtins$2));
2257
+ const RESERVED_NAMES = new Set([
2258
+ 'await',
2259
+ 'break',
2260
+ 'case',
2261
+ 'catch',
2262
+ 'class',
2263
+ 'const',
2264
+ 'continue',
2265
+ 'debugger',
2266
+ 'default',
2267
+ 'delete',
2268
+ 'do',
2269
+ 'else',
2270
+ 'enum',
2271
+ 'eval',
2272
+ 'export',
2273
+ 'extends',
2274
+ 'false',
2275
+ 'finally',
2276
+ 'for',
2277
+ 'function',
2278
+ 'if',
2279
+ 'implements',
2280
+ 'import',
2281
+ 'in',
2282
+ 'instanceof',
2283
+ 'interface',
2284
+ 'let',
2285
+ 'NaN',
2286
+ 'new',
2287
+ 'null',
2288
+ 'package',
2289
+ 'private',
2290
+ 'protected',
2291
+ 'public',
2292
+ 'return',
2293
+ 'static',
2294
+ 'super',
2295
+ 'switch',
2296
+ 'this',
2297
+ 'throw',
2298
+ 'true',
2299
+ 'try',
2300
+ 'typeof',
2301
+ 'undefined',
2302
+ 'var',
2303
+ 'void',
2304
+ 'while',
2305
+ 'with',
2306
+ 'yield'
2307
+ ]);
2308
+ const RESERVED_NAMES$1 = RESERVED_NAMES;
2309
+
2231
2310
  const illegalCharacters = /[^$_a-zA-Z0-9]/g;
2232
2311
  const startsWithDigit = (str) => /\d/.test(str[0]);
2233
2312
  function isLegal(str) {
2234
- if (startsWithDigit(str) || blacklisted.has(str)) {
2313
+ if (startsWithDigit(str) || RESERVED_NAMES$1.has(str)) {
2235
2314
  return false;
2236
2315
  }
2237
2316
  return !illegalCharacters.test(str);
2238
2317
  }
2239
2318
  function makeLegal(str) {
2240
2319
  str = str.replace(/-(\w)/g, (_, letter) => letter.toUpperCase()).replace(illegalCharacters, '_');
2241
- if (startsWithDigit(str) || blacklisted.has(str))
2320
+ if (startsWithDigit(str) || RESERVED_NAMES$1.has(str))
2242
2321
  str = `_${str}`;
2243
2322
  return str || '_';
2244
2323
  }
@@ -2280,6 +2359,7 @@ class ExternalModule {
2280
2359
  },
2281
2360
  isEntry: false,
2282
2361
  isExternal: true,
2362
+ isIncluded: null,
2283
2363
  meta,
2284
2364
  syntheticNamedExports: false
2285
2365
  };
@@ -2297,7 +2377,7 @@ class ExternalModule {
2297
2377
  typeof options.paths === 'function' ? options.paths(this.id) : options.paths[this.id];
2298
2378
  if (!this.renderPath) {
2299
2379
  this.renderPath = this.renormalizeRenderPath
2300
- ? normalize(path$2.relative(inputBase, this.id))
2380
+ ? normalize(require$$0.relative(inputBase, this.id))
2301
2381
  : this.id;
2302
2382
  }
2303
2383
  return this.renderPath;
@@ -2340,7 +2420,7 @@ class ExternalModule {
2340
2420
 
2341
2421
  var utils$3 = {};
2342
2422
 
2343
- const path$1 = path$2;
2423
+ const path$1 = require$$0;
2344
2424
  const WIN_SLASH = '\\\\/';
2345
2425
  const WIN_NO_SLASH = `[^${WIN_SLASH}]`;
2346
2426
 
@@ -2520,7 +2600,7 @@ var constants$2 = {
2520
2600
 
2521
2601
  (function (exports) {
2522
2602
 
2523
- const path = path$2;
2603
+ const path = require$$0;
2524
2604
  const win32 = process.platform === 'win32';
2525
2605
  const {
2526
2606
  REGEX_BACKSLASH,
@@ -4050,7 +4130,7 @@ parse$1.fastpaths = (input, options) => {
4050
4130
 
4051
4131
  var parse_1 = parse$1;
4052
4132
 
4053
- const path = path$2;
4133
+ const path = require$$0;
4054
4134
  const scan = scan_1;
4055
4135
  const parse = parse_1;
4056
4136
  const utils = utils$3;
@@ -4443,22 +4523,22 @@ function ensureArray(thing) {
4443
4523
  }
4444
4524
 
4445
4525
  const normalizePath = function normalizePath(filename) {
4446
- return filename.split(path$2.win32.sep).join(path$2.posix.sep);
4526
+ return filename.split(require$$0.win32.sep).join(require$$0.posix.sep);
4447
4527
  };
4448
4528
 
4449
4529
  function getMatcherString(id, resolutionBase) {
4450
- if (resolutionBase === false || path$2.isAbsolute(id) || id.startsWith('*')) {
4530
+ if (resolutionBase === false || require$$0.isAbsolute(id) || id.startsWith('*')) {
4451
4531
  return id;
4452
4532
  }
4453
4533
  // resolve('') is valid and will default to process.cwd()
4454
- const basePath = normalizePath(path$2.resolve(resolutionBase || ''))
4534
+ const basePath = normalizePath(require$$0.resolve(resolutionBase || ''))
4455
4535
  // escape all possible (posix + win) path characters that might interfere with regex
4456
4536
  .replace(/[-^$*+?.()|[\]{}]/g, '\\$&');
4457
4537
  // Note that we use posix.join because:
4458
4538
  // 1. the basePath has been normalized to use /
4459
4539
  // 2. the incoming glob (id) matcher, also uses /
4460
4540
  // otherwise Node will force backslash (\) on windows
4461
- return path$2.posix.join(basePath, id);
4541
+ return require$$0.posix.join(basePath, id);
4462
4542
  }
4463
4543
  const createFilter = function createFilter(include, exclude, options) {
4464
4544
  const resolutionBase = options && options.resolve;
@@ -5522,8 +5602,6 @@ const knownGlobals = {
5522
5602
  __proto__: null,
5523
5603
  [ValueProperties]: PURE,
5524
5604
  create: PF,
5525
- getNotifier: PF,
5526
- getOwn: PF,
5527
5605
  getOwnPropertyDescriptor: PF,
5528
5606
  getOwnPropertyNames: PF,
5529
5607
  getOwnPropertySymbols: PF,
@@ -6565,62 +6643,10 @@ function toBase64(num) {
6565
6643
  return outStr;
6566
6644
  }
6567
6645
 
6568
- const RESERVED_NAMES = {
6569
- __proto__: null,
6570
- await: true,
6571
- break: true,
6572
- case: true,
6573
- catch: true,
6574
- class: true,
6575
- const: true,
6576
- continue: true,
6577
- debugger: true,
6578
- default: true,
6579
- delete: true,
6580
- do: true,
6581
- else: true,
6582
- enum: true,
6583
- eval: true,
6584
- export: true,
6585
- extends: true,
6586
- false: true,
6587
- finally: true,
6588
- for: true,
6589
- function: true,
6590
- if: true,
6591
- implements: true,
6592
- import: true,
6593
- in: true,
6594
- instanceof: true,
6595
- interface: true,
6596
- let: true,
6597
- new: true,
6598
- null: true,
6599
- package: true,
6600
- private: true,
6601
- protected: true,
6602
- public: true,
6603
- return: true,
6604
- static: true,
6605
- super: true,
6606
- switch: true,
6607
- this: true,
6608
- throw: true,
6609
- true: true,
6610
- try: true,
6611
- typeof: true,
6612
- undefined: true,
6613
- var: true,
6614
- void: true,
6615
- while: true,
6616
- with: true,
6617
- yield: true
6618
- };
6619
-
6620
6646
  function getSafeName(baseName, usedNames) {
6621
6647
  let safeName = baseName;
6622
6648
  let count = 1;
6623
- while (usedNames.has(safeName) || RESERVED_NAMES[safeName]) {
6649
+ while (usedNames.has(safeName) || RESERVED_NAMES$1.has(safeName)) {
6624
6650
  safeName = `${baseName}$${toBase64(count++)}`;
6625
6651
  }
6626
6652
  usedNames.add(safeName);
@@ -6731,16 +6757,27 @@ const literalNumberMembers = assembleMemberDescriptions({
6731
6757
  valueOf: returnsNumber
6732
6758
  }, objectMembers);
6733
6759
  const literalStringMembers = assembleMemberDescriptions({
6760
+ anchor: returnsString,
6761
+ at: returnsUnknown,
6762
+ big: returnsString,
6763
+ blink: returnsString,
6764
+ bold: returnsString,
6734
6765
  charAt: returnsString,
6735
6766
  charCodeAt: returnsNumber,
6736
- codePointAt: returnsNumber,
6767
+ codePointAt: returnsUnknown,
6737
6768
  concat: returnsString,
6738
6769
  endsWith: returnsBoolean,
6770
+ fixed: returnsString,
6771
+ fontcolor: returnsString,
6772
+ fontsize: returnsString,
6739
6773
  includes: returnsBoolean,
6740
6774
  indexOf: returnsNumber,
6775
+ italics: returnsString,
6741
6776
  lastIndexOf: returnsNumber,
6777
+ link: returnsString,
6742
6778
  localeCompare: returnsNumber,
6743
- match: returnsBoolean,
6779
+ match: returnsUnknown,
6780
+ matchAll: returnsUnknown,
6744
6781
  normalize: returnsString,
6745
6782
  padEnd: returnsString,
6746
6783
  padStart: returnsString,
@@ -6751,17 +6788,32 @@ const literalStringMembers = assembleMemberDescriptions({
6751
6788
  returns: UNKNOWN_LITERAL_STRING
6752
6789
  }
6753
6790
  },
6791
+ replaceAll: {
6792
+ value: {
6793
+ callsArgs: [1],
6794
+ returns: UNKNOWN_LITERAL_STRING
6795
+ }
6796
+ },
6754
6797
  search: returnsNumber,
6755
6798
  slice: returnsString,
6799
+ small: returnsString,
6756
6800
  split: returnsUnknown,
6757
6801
  startsWith: returnsBoolean,
6802
+ strike: returnsString,
6803
+ sub: returnsString,
6758
6804
  substr: returnsString,
6759
6805
  substring: returnsString,
6806
+ sup: returnsString,
6760
6807
  toLocaleLowerCase: returnsString,
6761
6808
  toLocaleUpperCase: returnsString,
6762
6809
  toLowerCase: returnsString,
6810
+ toString: returnsString,
6763
6811
  toUpperCase: returnsString,
6764
6812
  trim: returnsString,
6813
+ trimEnd: returnsString,
6814
+ trimLeft: returnsString,
6815
+ trimRight: returnsString,
6816
+ trimStart: returnsString,
6765
6817
  valueOf: returnsString
6766
6818
  }, objectMembers);
6767
6819
  function getLiteralMembersForValue(value) {
@@ -8577,6 +8629,10 @@ const ARRAY_PROTOTYPE = new ObjectEntity({
8577
8629
  filter: METHOD_CALLS_ARG_DEOPTS_SELF_RETURNS_NEW_ARRAY,
8578
8630
  find: METHOD_CALLS_ARG_DEOPTS_SELF_RETURNS_UNKNOWN,
8579
8631
  findIndex: METHOD_CALLS_ARG_DEOPTS_SELF_RETURNS_NUMBER,
8632
+ findLast: METHOD_CALLS_ARG_DEOPTS_SELF_RETURNS_UNKNOWN,
8633
+ findLastIndex: METHOD_CALLS_ARG_DEOPTS_SELF_RETURNS_NUMBER,
8634
+ flat: METHOD_DEOPTS_SELF_RETURNS_NEW_ARRAY,
8635
+ flatMap: METHOD_CALLS_ARG_DEOPTS_SELF_RETURNS_NEW_ARRAY,
8580
8636
  forEach: METHOD_CALLS_ARG_DEOPTS_SELF_RETURNS_UNKNOWN,
8581
8637
  includes: METHOD_RETURNS_BOOLEAN,
8582
8638
  indexOf: METHOD_RETURNS_NUMBER,
@@ -8594,6 +8650,8 @@ const ARRAY_PROTOTYPE = new ObjectEntity({
8594
8650
  some: METHOD_CALLS_ARG_DEOPTS_SELF_RETURNS_BOOLEAN,
8595
8651
  sort: METHOD_CALLS_ARG_MUTATES_SELF_RETURNS_SELF,
8596
8652
  splice: METHOD_MUTATES_SELF_RETURNS_NEW_ARRAY,
8653
+ toLocaleString: METHOD_RETURNS_STRING,
8654
+ toString: METHOD_RETURNS_STRING,
8597
8655
  unshift: METHOD_MUTATES_SELF_RETURNS_NUMBER,
8598
8656
  values: METHOD_DEOPTS_SELF_RETURNS_UNKNOWN
8599
8657
  }, OBJECT_PROTOTYPE, true);
@@ -10845,7 +10903,7 @@ class MetaProperty extends NodeBase {
10845
10903
  chunkReferenceId = metaProperty.substr(CHUNK_PREFIX.length);
10846
10904
  fileName = outputPluginDriver.getFileName(chunkReferenceId);
10847
10905
  }
10848
- const relativePath = normalize(path$2.relative(path$2.dirname(chunkId), fileName));
10906
+ const relativePath = normalize(require$$0.relative(require$$0.dirname(chunkId), fileName));
10849
10907
  let replacement;
10850
10908
  if (assetReferenceId !== null) {
10851
10909
  replacement = outputPluginDriver.hookFirstSync('resolveAssetUrl', [
@@ -12046,13 +12104,19 @@ class SyntheticNamedExportVariable extends Variable {
12046
12104
  }
12047
12105
  }
12048
12106
 
12107
+ var BuildPhase;
12108
+ (function (BuildPhase) {
12109
+ BuildPhase[BuildPhase["LOAD_AND_PARSE"] = 0] = "LOAD_AND_PARSE";
12110
+ BuildPhase[BuildPhase["ANALYSE"] = 1] = "ANALYSE";
12111
+ BuildPhase[BuildPhase["GENERATE"] = 2] = "GENERATE";
12112
+ })(BuildPhase || (BuildPhase = {}));
12113
+
12049
12114
  function getId(m) {
12050
12115
  return m.id;
12051
12116
  }
12052
12117
 
12053
12118
  function getOriginalLocation(sourcemapChain, location) {
12054
- // This cast is guaranteed. If it were a missing Map, it wouldn't have a mappings.
12055
- const filteredSourcemapChain = sourcemapChain.filter(sourcemap => sourcemap.mappings);
12119
+ const filteredSourcemapChain = sourcemapChain.filter((sourcemap) => !!sourcemap.mappings);
12056
12120
  while (filteredSourcemapChain.length > 0) {
12057
12121
  const sourcemap = filteredSourcemapChain.pop();
12058
12122
  const line = sourcemap.mappings[location.line - 1];
@@ -12081,24 +12145,7 @@ function getOriginalLocation(sourcemapChain, location) {
12081
12145
  }
12082
12146
 
12083
12147
  const NOOP = () => { };
12084
- let getStartTime = () => [0, 0];
12085
- let getElapsedTime = () => 0;
12086
- let getMemory = () => 0;
12087
- let timers = {};
12088
- const normalizeHrTime = (time) => time[0] * 1e3 + time[1] / 1e6;
12089
- function setTimeHelpers() {
12090
- if (typeof process !== 'undefined' && typeof process.hrtime === 'function') {
12091
- getStartTime = process.hrtime.bind(process);
12092
- getElapsedTime = previous => normalizeHrTime(process.hrtime(previous));
12093
- }
12094
- else if (typeof performance !== 'undefined' && typeof performance.now === 'function') {
12095
- getStartTime = () => [performance.now(), 0];
12096
- getElapsedTime = previous => performance.now() - previous[0];
12097
- }
12098
- if (typeof process !== 'undefined' && typeof process.memoryUsage === 'function') {
12099
- getMemory = () => process.memoryUsage().heapUsed;
12100
- }
12101
- }
12148
+ let timers = new Map();
12102
12149
  function getPersistedLabel(label, level) {
12103
12150
  switch (level) {
12104
12151
  case 1:
@@ -12113,46 +12160,47 @@ function getPersistedLabel(label, level) {
12113
12160
  }
12114
12161
  function timeStartImpl(label, level = 3) {
12115
12162
  label = getPersistedLabel(label, level);
12116
- if (!timers.hasOwnProperty(label)) {
12117
- timers[label] = {
12163
+ const startMemory = process$1.memoryUsage().heapUsed;
12164
+ const startTime = perf_hooks.performance.now();
12165
+ const timer = timers.get(label);
12166
+ if (timer === undefined) {
12167
+ timers.set(label, {
12118
12168
  memory: 0,
12119
- startMemory: undefined,
12120
- startTime: undefined,
12169
+ startMemory,
12170
+ startTime,
12121
12171
  time: 0,
12122
12172
  totalMemory: 0
12123
- };
12173
+ });
12174
+ }
12175
+ else {
12176
+ timer.startMemory = startMemory;
12177
+ timer.startTime = startTime;
12124
12178
  }
12125
- const currentMemory = getMemory();
12126
- timers[label].startTime = getStartTime();
12127
- timers[label].startMemory = currentMemory;
12128
12179
  }
12129
12180
  function timeEndImpl(label, level = 3) {
12130
12181
  label = getPersistedLabel(label, level);
12131
- if (timers.hasOwnProperty(label)) {
12132
- const currentMemory = getMemory();
12133
- timers[label].time += getElapsedTime(timers[label].startTime);
12134
- timers[label].totalMemory = Math.max(timers[label].totalMemory, currentMemory);
12135
- timers[label].memory += currentMemory - timers[label].startMemory;
12182
+ const timer = timers.get(label);
12183
+ if (timer !== undefined) {
12184
+ const currentMemory = process$1.memoryUsage().heapUsed;
12185
+ timer.memory += currentMemory - timer.startMemory;
12186
+ timer.time += perf_hooks.performance.now() - timer.startTime;
12187
+ timer.totalMemory = Math.max(timer.totalMemory, currentMemory);
12136
12188
  }
12137
12189
  }
12138
12190
  function getTimings() {
12139
12191
  const newTimings = {};
12140
- for (const [label, { time, memory, totalMemory }] of Object.entries(timers)) {
12192
+ for (const [label, { memory, time, totalMemory }] of timers) {
12141
12193
  newTimings[label] = [time, memory, totalMemory];
12142
12194
  }
12143
12195
  return newTimings;
12144
12196
  }
12145
- let timeStart = NOOP, timeEnd = NOOP;
12146
- const TIMED_PLUGIN_HOOKS = {
12147
- load: true,
12148
- resolveDynamicImport: true,
12149
- resolveId: true,
12150
- transform: true
12151
- };
12197
+ let timeStart = NOOP;
12198
+ let timeEnd = NOOP;
12199
+ const TIMED_PLUGIN_HOOKS = ['load', 'resolveDynamicImport', 'resolveId', 'transform'];
12152
12200
  function getPluginWithTimers(plugin, index) {
12153
12201
  const timedPlugin = {};
12154
- for (const hook of Object.keys(plugin)) {
12155
- if (TIMED_PLUGIN_HOOKS[hook] === true) {
12202
+ for (const hook of TIMED_PLUGIN_HOOKS) {
12203
+ if (hook in plugin) {
12156
12204
  let timerLabel = `plugin ${index}`;
12157
12205
  if (plugin.name) {
12158
12206
  timerLabel += ` (${plugin.name})`;
@@ -12160,11 +12208,11 @@ function getPluginWithTimers(plugin, index) {
12160
12208
  timerLabel += ` - ${hook}`;
12161
12209
  timedPlugin[hook] = function (...args) {
12162
12210
  timeStart(timerLabel, 4);
12163
- let result = plugin[hook].apply(this === timedPlugin ? plugin : this, args);
12211
+ const result = plugin[hook](...args);
12164
12212
  timeEnd(timerLabel, 4);
12165
12213
  if (result && typeof result.then === 'function') {
12166
12214
  timeStart(`${timerLabel} (async)`, 4);
12167
- result = result.then((hookResult) => {
12215
+ return result.then((hookResult) => {
12168
12216
  timeEnd(`${timerLabel} (async)`, 4);
12169
12217
  return hookResult;
12170
12218
  });
@@ -12172,16 +12220,15 @@ function getPluginWithTimers(plugin, index) {
12172
12220
  return result;
12173
12221
  };
12174
12222
  }
12175
- else {
12176
- timedPlugin[hook] = plugin[hook];
12177
- }
12178
12223
  }
12179
- return timedPlugin;
12224
+ return {
12225
+ ...plugin,
12226
+ ...timedPlugin
12227
+ };
12180
12228
  }
12181
12229
  function initialiseTimers(inputOptions) {
12182
12230
  if (inputOptions.perf) {
12183
- timers = {};
12184
- setTimeHelpers();
12231
+ timers = new Map();
12185
12232
  timeStart = timeStartImpl;
12186
12233
  timeEnd = timeEndImpl;
12187
12234
  inputOptions.plugins = inputOptions.plugins.map(getPluginWithTimers);
@@ -12325,10 +12372,10 @@ class Module {
12325
12372
  hasModuleSideEffects,
12326
12373
  id,
12327
12374
  get implicitlyLoadedAfterOneOf() {
12328
- return Array.from(module.implicitlyLoadedAfter, getId);
12375
+ return Array.from(module.implicitlyLoadedAfter, getId).sort();
12329
12376
  },
12330
12377
  get implicitlyLoadedBefore() {
12331
- return Array.from(module.implicitlyLoadedBefore, getId);
12378
+ return Array.from(module.implicitlyLoadedBefore, getId).sort();
12332
12379
  },
12333
12380
  get importedIds() {
12334
12381
  return Array.from(module.sources, source => { var _a; return (_a = module.resolvedIds[source]) === null || _a === void 0 ? void 0 : _a.id; }).filter(Boolean);
@@ -12338,13 +12385,19 @@ class Module {
12338
12385
  },
12339
12386
  isEntry,
12340
12387
  isExternal: false,
12341
- meta,
12388
+ get isIncluded() {
12389
+ if (module.graph.phase !== BuildPhase.GENERATE) {
12390
+ return null;
12391
+ }
12392
+ return module.isIncluded();
12393
+ },
12394
+ meta: { ...meta },
12342
12395
  syntheticNamedExports
12343
12396
  };
12344
12397
  }
12345
12398
  basename() {
12346
- const base = path$2.basename(this.id);
12347
- const ext = path$2.extname(this.id);
12399
+ const base = require$$0.basename(this.id);
12400
+ const ext = require$$0.extname(this.id);
12348
12401
  return makeLegal(ext ? base.slice(0, -ext.length) : base);
12349
12402
  }
12350
12403
  bindReferences() {
@@ -12359,7 +12412,7 @@ class Module {
12359
12412
  return this.allExportNames;
12360
12413
  }
12361
12414
  const allExportNames = (this.allExportNames = new Set());
12362
- for (const name of Object.keys(this.exports)) {
12415
+ for (const name of this.getExports()) {
12363
12416
  allExportNames.add(name);
12364
12417
  }
12365
12418
  for (const name of Object.keys(this.reexportDescriptions)) {
@@ -12383,12 +12436,11 @@ class Module {
12383
12436
  const relevantDependencies = new Set();
12384
12437
  const necessaryDependencies = new Set();
12385
12438
  const alwaysCheckedDependencies = new Set();
12386
- let dependencyVariables = this.imports.keys();
12439
+ const dependencyVariables = new Set(this.imports);
12387
12440
  if (this.info.isEntry ||
12388
12441
  this.includedDynamicImporters.length > 0 ||
12389
12442
  this.namespace.included ||
12390
12443
  this.implicitlyLoadedAfter.size > 0) {
12391
- dependencyVariables = new Set(dependencyVariables);
12392
12444
  for (const exportName of [...this.getReexports(), ...this.getExports()]) {
12393
12445
  const exportedVariable = this.getVariableForExportName(exportName);
12394
12446
  if (exportedVariable) {
@@ -12770,7 +12822,7 @@ class Module {
12770
12822
  this.info.syntheticNamedExports = syntheticNamedExports;
12771
12823
  }
12772
12824
  if (meta != null) {
12773
- this.info.meta = { ...this.info.meta, ...meta };
12825
+ Object.assign(this.info.meta, meta);
12774
12826
  }
12775
12827
  }
12776
12828
  warn(props, pos) {
@@ -12861,11 +12913,7 @@ class Module {
12861
12913
  for (const specifier of node.specifiers) {
12862
12914
  const isDefault = specifier.type === ImportDefaultSpecifier$1;
12863
12915
  const isNamespace = specifier.type === ImportNamespaceSpecifier$1;
12864
- const name = isDefault
12865
- ? 'default'
12866
- : isNamespace
12867
- ? '*'
12868
- : specifier.imported.name;
12916
+ const name = isDefault ? 'default' : isNamespace ? '*' : specifier.imported.name;
12869
12917
  this.importDescriptions[specifier.local.name] = {
12870
12918
  module: null,
12871
12919
  name,
@@ -13012,7 +13060,7 @@ class Module {
13012
13060
  variable.include();
13013
13061
  this.graph.needsTreeshakingPass = true;
13014
13062
  const variableModule = variable.module;
13015
- if (variableModule && variableModule instanceof Module) {
13063
+ if (variableModule instanceof Module) {
13016
13064
  if (!variableModule.isExecuted) {
13017
13065
  markModuleAndImpureDependenciesAsExecuted(variableModule);
13018
13066
  }
@@ -13962,9 +14010,9 @@ function getCollapsedSourcemap(id, originalCode, originalSourcemap, sourcemapCha
13962
14010
  else {
13963
14011
  const sources = originalSourcemap.sources;
13964
14012
  const sourcesContent = originalSourcemap.sourcesContent || [];
13965
- const directory = path$2.dirname(id) || '.';
14013
+ const directory = require$$0.dirname(id) || '.';
13966
14014
  const sourceRoot = originalSourcemap.sourceRoot || '.';
13967
- const baseSources = sources.map((source, i) => new Source(path$2.resolve(directory, sourceRoot, source), sourcesContent[i]));
14015
+ const baseSources = sources.map((source, i) => new Source(require$$0.resolve(directory, sourceRoot, source), sourcesContent[i]));
13968
14016
  source = new Link(originalSourcemap, baseSources);
13969
14017
  }
13970
14018
  return sourcemapChain.reduce(linkMap, source);
@@ -13980,9 +14028,9 @@ function collapseSourcemaps(file, map, modules, bundleSourcemapChain, excludeCon
13980
14028
  source = bundleSourcemapChain.reduce(linkMap, source);
13981
14029
  let { sources, sourcesContent, names, mappings } = source.traceMappings();
13982
14030
  if (file) {
13983
- const directory = path$2.dirname(file);
13984
- sources = sources.map((source) => path$2.relative(directory, source));
13985
- file = path$2.basename(file);
14031
+ const directory = require$$0.dirname(file);
14032
+ sources = sources.map((source) => require$$0.relative(directory, source));
14033
+ file = require$$0.basename(file);
13986
14034
  }
13987
14035
  sourcesContent = (excludeContent ? null : sourcesContent);
13988
14036
  return new SourceMap({ file, mappings, names, sources, sourcesContent });
@@ -14128,7 +14176,7 @@ function escapeId(id) {
14128
14176
  function assignExportsToMangledNames(exports, exportsByName, exportNamesByVariable) {
14129
14177
  let nameIndex = 0;
14130
14178
  for (const variable of exports) {
14131
- let exportName = variable.name[0];
14179
+ let [exportName] = variable.name;
14132
14180
  if (exportsByName[exportName]) {
14133
14181
  do {
14134
14182
  exportName = toBase64(++nameIndex);
@@ -14137,7 +14185,7 @@ function assignExportsToMangledNames(exports, exportsByName, exportNamesByVariab
14137
14185
  nameIndex += 9 * 64 ** (exportName.length - 1);
14138
14186
  exportName = toBase64(nameIndex);
14139
14187
  }
14140
- } while (RESERVED_NAMES[exportName] || exportsByName[exportName]);
14188
+ } while (RESERVED_NAMES$1.has(exportName) || exportsByName[exportName]);
14141
14189
  }
14142
14190
  exportsByName[exportName] = variable;
14143
14191
  exportNamesByVariable.set(variable, [exportName]);
@@ -14314,7 +14362,7 @@ function makeUnique(name, existingNames) {
14314
14362
  const existingNamesLowercase = new Set(Object.keys(existingNames).map(key => key.toLowerCase()));
14315
14363
  if (!existingNamesLowercase.has(name.toLocaleLowerCase()))
14316
14364
  return name;
14317
- const ext = path$2.extname(name);
14365
+ const ext = require$$0.extname(name);
14318
14366
  name = name.substr(0, name.length - ext.length);
14319
14367
  let uniqueName, uniqueIndex = 1;
14320
14368
  while (existingNamesLowercase.has((uniqueName = name + ++uniqueIndex + ext).toLowerCase()))
@@ -14370,6 +14418,7 @@ class Chunk {
14370
14418
  this.implicitlyLoadedBefore = new Set();
14371
14419
  this.imports = new Set();
14372
14420
  this.indentString = undefined;
14421
+ // This may only be updated in the constructor
14373
14422
  this.isEmpty = true;
14374
14423
  this.name = null;
14375
14424
  this.renderedDependencies = null;
@@ -14555,7 +14604,7 @@ class Chunk {
14555
14604
  }), existingNames);
14556
14605
  }
14557
14606
  generateIdPreserveModules(preserveModulesRelativeDir, options, existingNames, unsetOptions) {
14558
- const id = this.orderedModules[0].id;
14607
+ const [{ id }] = this.orderedModules;
14559
14608
  const sanitizedId = this.outputOptions.sanitizeFileName(id);
14560
14609
  let path;
14561
14610
  const patternOpt = unsetOptions.has('entryFileNames')
@@ -14563,8 +14612,8 @@ class Chunk {
14563
14612
  : options.entryFileNames;
14564
14613
  const pattern = typeof patternOpt === 'function' ? patternOpt(this.getChunkInfo()) : patternOpt;
14565
14614
  if (isAbsolute(id)) {
14566
- const currentDir = path$2.dirname(sanitizedId);
14567
- const extension = path$2.extname(id);
14615
+ const currentDir = require$$0.dirname(sanitizedId);
14616
+ const extension = require$$0.extname(id);
14568
14617
  const fileName = renderNamePattern(pattern, 'output.entryFileNames', {
14569
14618
  assetExtname: () => (NON_ASSET_EXTENSIONS.includes(extension) ? '' : extension),
14570
14619
  ext: () => extension.substr(1),
@@ -14582,7 +14631,7 @@ class Chunk {
14582
14631
  }
14583
14632
  }
14584
14633
  else {
14585
- const extension = path$2.extname(sanitizedId);
14634
+ const extension = require$$0.extname(sanitizedId);
14586
14635
  const fileName = renderNamePattern(pattern, 'output.entryFileNames', {
14587
14636
  assetExtname: () => (NON_ASSET_EXTENSIONS.includes(extension) ? '' : extension),
14588
14637
  ext: () => extension.substr(1),
@@ -14835,11 +14884,11 @@ class Chunk {
14835
14884
  timeStart('sourcemap', 2);
14836
14885
  let file;
14837
14886
  if (options.file)
14838
- file = path$2.resolve(options.sourcemapFile || options.file);
14887
+ file = require$$0.resolve(options.sourcemapFile || options.file);
14839
14888
  else if (options.dir)
14840
- file = path$2.resolve(options.dir, this.id);
14889
+ file = require$$0.resolve(options.dir, this.id);
14841
14890
  else
14842
- file = path$2.resolve(this.id);
14891
+ file = require$$0.resolve(this.id);
14843
14892
  const decodedMap = magicString.generateDecodedMap({});
14844
14893
  map = collapseSourcemaps(file, decodedMap, this.usedModules, chunkSourcemapChain, options.sourcemapExcludeSources, this.inputOptions.onwarn);
14845
14894
  map.sources = map.sources
@@ -15204,14 +15253,14 @@ class Chunk {
15204
15253
  return referencedFiles;
15205
15254
  }
15206
15255
  getRelativePath(targetPath, stripJsExtension) {
15207
- let relativePath = normalize(relative(path$2.dirname(this.id), targetPath));
15256
+ let relativePath = normalize(relative(require$$0.dirname(this.id), targetPath));
15208
15257
  if (stripJsExtension && relativePath.endsWith('.js')) {
15209
15258
  relativePath = relativePath.slice(0, -3);
15210
15259
  }
15211
15260
  if (relativePath === '..')
15212
- return '../../' + path$2.basename(targetPath);
15261
+ return '../../' + require$$0.basename(targetPath);
15213
15262
  if (relativePath === '')
15214
- return '../' + path$2.basename(targetPath);
15263
+ return '../' + require$$0.basename(targetPath);
15215
15264
  return relativePath.startsWith('../') ? relativePath : './' + relativePath;
15216
15265
  }
15217
15266
  inlineChunkDependencies(chunk) {
@@ -15355,20 +15404,13 @@ function getChunkNameFromModule(module) {
15355
15404
  return module.chunkName || getAliasName(module.id);
15356
15405
  }
15357
15406
 
15358
- var BuildPhase;
15359
- (function (BuildPhase) {
15360
- BuildPhase[BuildPhase["LOAD_AND_PARSE"] = 0] = "LOAD_AND_PARSE";
15361
- BuildPhase[BuildPhase["ANALYSE"] = 1] = "ANALYSE";
15362
- BuildPhase[BuildPhase["GENERATE"] = 2] = "GENERATE";
15363
- })(BuildPhase || (BuildPhase = {}));
15364
-
15365
15407
  function generateAssetFileName(name, source, outputOptions, bundle) {
15366
15408
  const emittedName = outputOptions.sanitizeFileName(name || 'asset');
15367
15409
  return makeUnique(renderNamePattern(typeof outputOptions.assetFileNames === 'function'
15368
15410
  ? outputOptions.assetFileNames({ name, source, type: 'asset' })
15369
15411
  : outputOptions.assetFileNames, 'output.assetFileNames', {
15370
- ext: () => path$2.extname(emittedName).substr(1),
15371
- extname: () => path$2.extname(emittedName),
15412
+ ext: () => require$$0.extname(emittedName).substr(1),
15413
+ extname: () => require$$0.extname(emittedName),
15372
15414
  hash() {
15373
15415
  const hash = createHash();
15374
15416
  hash.update(emittedName);
@@ -15376,7 +15418,7 @@ function generateAssetFileName(name, source, outputOptions, bundle) {
15376
15418
  hash.update(source);
15377
15419
  return hash.digest('hex').substr(0, 8);
15378
15420
  },
15379
- name: () => emittedName.substr(0, emittedName.length - path$2.extname(emittedName).length)
15421
+ name: () => emittedName.substr(0, emittedName.length - require$$0.extname(emittedName).length)
15380
15422
  }), bundle);
15381
15423
  }
15382
15424
  function reserveFileNameInBundle(fileName, bundle, warn) {
@@ -15768,7 +15810,7 @@ function commondir(files) {
15768
15810
  if (files.length === 0)
15769
15811
  return '/';
15770
15812
  if (files.length === 1)
15771
- return path$2.dirname(files[0]);
15813
+ return require$$0.dirname(files[0]);
15772
15814
  const commonSegments = files.slice(1).reduce((commonSegments, file) => {
15773
15815
  const pathSegements = file.split(/\/+|\\+/);
15774
15816
  let i;
@@ -15872,7 +15914,7 @@ function getGenerateCodeSnippets({ compact, generatedCode: { arrowFunctions, con
15872
15914
  ];
15873
15915
  const isValidPropName = reservedNamesAsProps
15874
15916
  ? (name) => validPropName.test(name)
15875
- : (name) => !RESERVED_NAMES[name] && validPropName.test(name);
15917
+ : (name) => !RESERVED_NAMES$1.has(name) && validPropName.test(name);
15876
15918
  return {
15877
15919
  _,
15878
15920
  cnst,
@@ -15988,7 +16030,7 @@ class Bundle {
15988
16030
  const chunksForNaming = entryChunks.concat(otherChunks);
15989
16031
  for (const chunk of chunksForNaming) {
15990
16032
  if (this.outputOptions.file) {
15991
- chunk.id = path$2.basename(this.outputOptions.file);
16033
+ chunk.id = require$$0.basename(this.outputOptions.file);
15992
16034
  }
15993
16035
  else if (this.outputOptions.preserveModules) {
15994
16036
  chunk.id = chunk.generateIdPreserveModules(inputBase, this.outputOptions, bundle, this.unsetOptions);
@@ -16097,7 +16139,7 @@ function validateOptionsForMultiChunkOutput(outputOptions, onWarn) {
16097
16139
  onWarn(errInvalidOption('output.amd.id', 'outputamd', 'this option is only properly supported for single-file builds. Use "output.amd.autoId" and "output.amd.basePath" instead'));
16098
16140
  }
16099
16141
  function getIncludedModules(modulesById) {
16100
- return [...modulesById.values()].filter(module => module instanceof Module &&
16142
+ return [...modulesById.values()].filter((module) => module instanceof Module &&
16101
16143
  (module.isIncluded() || module.info.isEntry || module.includedDynamicImporters.length > 0));
16102
16144
  }
16103
16145
  function addModuleToManualChunk(alias, module, manualChunkAliasByEntry) {
@@ -21641,7 +21683,7 @@ Parser.acorn = {
21641
21683
 
21642
21684
  const readFile = (file) => new Promise((fulfil, reject) => fs.readFile(file, 'utf-8', (err, contents) => (err ? reject(err) : fulfil(contents))));
21643
21685
  function mkdirpath(path) {
21644
- const dir = path$2.dirname(path);
21686
+ const dir = require$$0.dirname(path);
21645
21687
  fs.mkdirSync(dir, { recursive: true });
21646
21688
  }
21647
21689
  function writeFile(dest, data) {
@@ -21659,9 +21701,9 @@ function writeFile(dest, data) {
21659
21701
  }
21660
21702
 
21661
21703
  class Queue {
21662
- constructor(maxParallel = 1) {
21704
+ constructor(maxParallel) {
21663
21705
  this.maxParallel = maxParallel;
21664
- this.queue = new Array();
21706
+ this.queue = [];
21665
21707
  this.workerCount = 0;
21666
21708
  }
21667
21709
  run(task) {
@@ -21721,7 +21763,7 @@ async function resolveId(source, importer, preserveSymlinks, pluginDriver, modul
21721
21763
  // absolute path is created. Absolute importees therefore shortcircuit the
21722
21764
  // resolve call and require no special handing on our part.
21723
21765
  // See https://nodejs.org/api/path.html#path_path_resolve_paths
21724
- return addJsExtensionIfNecessary(importer ? path$2.resolve(path$2.dirname(importer), source) : path$2.resolve(source), preserveSymlinks);
21766
+ return addJsExtensionIfNecessary(importer ? require$$0.resolve(require$$0.dirname(importer), source) : require$$0.resolve(source), preserveSymlinks);
21725
21767
  }
21726
21768
  function addJsExtensionIfNecessary(file, preserveSymlinks) {
21727
21769
  let found = findFile(file, preserveSymlinks);
@@ -21740,8 +21782,8 @@ function findFile(file, preserveSymlinks) {
21740
21782
  return findFile(fs.realpathSync(file), preserveSymlinks);
21741
21783
  if ((preserveSymlinks && stats.isSymbolicLink()) || stats.isFile()) {
21742
21784
  // check case
21743
- const name = path$2.basename(file);
21744
- const files = fs.readdirSync(path$2.dirname(file));
21785
+ const name = require$$0.basename(file);
21786
+ const files = fs.readdirSync(require$$0.dirname(file));
21745
21787
  if (files.indexOf(name) !== -1)
21746
21788
  return file;
21747
21789
  }
@@ -21871,7 +21913,7 @@ function getCacheForUncacheablePlugin(pluginName) {
21871
21913
  };
21872
21914
  }
21873
21915
 
21874
- function transform(source, module, pluginDriver, warn) {
21916
+ async function transform(source, module, pluginDriver, warn) {
21875
21917
  const id = module.id;
21876
21918
  const sourcemapChain = [];
21877
21919
  let originalSourcemap = source.map === null ? null : decodedSourcemap(source.map);
@@ -21881,7 +21923,7 @@ function transform(source, module, pluginDriver, warn) {
21881
21923
  const emittedFiles = [];
21882
21924
  let customTransformCache = false;
21883
21925
  const useCustomTransformCache = () => (customTransformCache = true);
21884
- let curPlugin;
21926
+ let pluginName = '';
21885
21927
  const curSource = source.code;
21886
21928
  function transformReducer(previousCode, result, plugin) {
21887
21929
  let code;
@@ -21912,90 +21954,91 @@ function transform(source, module, pluginDriver, warn) {
21912
21954
  }
21913
21955
  return code;
21914
21956
  }
21915
- return pluginDriver
21916
- .hookReduceArg0('transform', [curSource, id], transformReducer, (pluginContext, plugin) => {
21917
- curPlugin = plugin;
21918
- return {
21919
- ...pluginContext,
21920
- addWatchFile(id) {
21921
- transformDependencies.push(id);
21922
- pluginContext.addWatchFile(id);
21923
- },
21924
- cache: customTransformCache
21925
- ? pluginContext.cache
21926
- : getTrackedPluginCache(pluginContext.cache, useCustomTransformCache),
21927
- emitAsset(name, source) {
21928
- emittedFiles.push({ name, source, type: 'asset' });
21929
- return pluginContext.emitAsset(name, source);
21930
- },
21931
- emitChunk(id, options) {
21932
- emittedFiles.push({ id, name: options && options.name, type: 'chunk' });
21933
- return pluginContext.emitChunk(id, options);
21934
- },
21935
- emitFile(emittedFile) {
21936
- emittedFiles.push(emittedFile);
21937
- return pluginDriver.emitFile(emittedFile);
21938
- },
21939
- error(err, pos) {
21940
- if (typeof err === 'string')
21941
- err = { message: err };
21942
- if (pos)
21943
- augmentCodeLocation(err, pos, curSource, id);
21944
- err.id = id;
21945
- err.hook = 'transform';
21946
- return pluginContext.error(err);
21947
- },
21948
- getCombinedSourcemap() {
21949
- const combinedMap = collapseSourcemap(id, originalCode, originalSourcemap, sourcemapChain, warn);
21950
- if (!combinedMap) {
21951
- const magicString = new MagicString$1(originalCode);
21952
- return magicString.generateMap({ hires: true, includeContent: true, source: id });
21953
- }
21954
- if (originalSourcemap !== combinedMap) {
21955
- originalSourcemap = combinedMap;
21956
- sourcemapChain.length = 0;
21957
+ let code;
21958
+ try {
21959
+ code = await pluginDriver.hookReduceArg0('transform', [curSource, id], transformReducer, (pluginContext, plugin) => {
21960
+ pluginName = plugin.name;
21961
+ return {
21962
+ ...pluginContext,
21963
+ addWatchFile(id) {
21964
+ transformDependencies.push(id);
21965
+ pluginContext.addWatchFile(id);
21966
+ },
21967
+ cache: customTransformCache
21968
+ ? pluginContext.cache
21969
+ : getTrackedPluginCache(pluginContext.cache, useCustomTransformCache),
21970
+ emitAsset(name, source) {
21971
+ emittedFiles.push({ name, source, type: 'asset' });
21972
+ return pluginContext.emitAsset(name, source);
21973
+ },
21974
+ emitChunk(id, options) {
21975
+ emittedFiles.push({ id, name: options && options.name, type: 'chunk' });
21976
+ return pluginContext.emitChunk(id, options);
21977
+ },
21978
+ emitFile(emittedFile) {
21979
+ emittedFiles.push(emittedFile);
21980
+ return pluginDriver.emitFile(emittedFile);
21981
+ },
21982
+ error(err, pos) {
21983
+ if (typeof err === 'string')
21984
+ err = { message: err };
21985
+ if (pos)
21986
+ augmentCodeLocation(err, pos, curSource, id);
21987
+ err.id = id;
21988
+ err.hook = 'transform';
21989
+ return pluginContext.error(err);
21990
+ },
21991
+ getCombinedSourcemap() {
21992
+ const combinedMap = collapseSourcemap(id, originalCode, originalSourcemap, sourcemapChain, warn);
21993
+ if (!combinedMap) {
21994
+ const magicString = new MagicString$1(originalCode);
21995
+ return magicString.generateMap({ hires: true, includeContent: true, source: id });
21996
+ }
21997
+ if (originalSourcemap !== combinedMap) {
21998
+ originalSourcemap = combinedMap;
21999
+ sourcemapChain.length = 0;
22000
+ }
22001
+ return new SourceMap({
22002
+ ...combinedMap,
22003
+ file: null,
22004
+ sourcesContent: combinedMap.sourcesContent
22005
+ });
22006
+ },
22007
+ setAssetSource() {
22008
+ return this.error({
22009
+ code: 'INVALID_SETASSETSOURCE',
22010
+ message: `setAssetSource cannot be called in transform for caching reasons. Use emitFile with a source, or call setAssetSource in another hook.`
22011
+ });
22012
+ },
22013
+ warn(warning, pos) {
22014
+ if (typeof warning === 'string')
22015
+ warning = { message: warning };
22016
+ if (pos)
22017
+ augmentCodeLocation(warning, pos, curSource, id);
22018
+ warning.id = id;
22019
+ warning.hook = 'transform';
22020
+ pluginContext.warn(warning);
21957
22021
  }
21958
- return new SourceMap({
21959
- ...combinedMap,
21960
- file: null,
21961
- sourcesContent: combinedMap.sourcesContent
21962
- });
21963
- },
21964
- setAssetSource() {
21965
- return this.error({
21966
- code: 'INVALID_SETASSETSOURCE',
21967
- message: `setAssetSource cannot be called in transform for caching reasons. Use emitFile with a source, or call setAssetSource in another hook.`
21968
- });
21969
- },
21970
- warn(warning, pos) {
21971
- if (typeof warning === 'string')
21972
- warning = { message: warning };
21973
- if (pos)
21974
- augmentCodeLocation(warning, pos, curSource, id);
21975
- warning.id = id;
21976
- warning.hook = 'transform';
21977
- pluginContext.warn(warning);
21978
- }
21979
- };
21980
- })
21981
- .catch(err => throwPluginError(err, curPlugin.name, { hook: 'transform', id }))
21982
- .then(code => {
21983
- if (!customTransformCache) {
21984
- // files emitted by a transform hook need to be emitted again if the hook is skipped
21985
- if (emittedFiles.length)
21986
- module.transformFiles = emittedFiles;
21987
- }
21988
- return {
21989
- ast,
21990
- code,
21991
- customTransformCache,
21992
- meta: module.info.meta,
21993
- originalCode,
21994
- originalSourcemap,
21995
- sourcemapChain,
21996
- transformDependencies
21997
- };
21998
- });
22022
+ };
22023
+ });
22024
+ }
22025
+ catch (err) {
22026
+ throwPluginError(err, pluginName, { hook: 'transform', id });
22027
+ }
22028
+ if (!customTransformCache) {
22029
+ // files emitted by a transform hook need to be emitted again if the hook is skipped
22030
+ if (emittedFiles.length)
22031
+ module.transformFiles = emittedFiles;
22032
+ }
22033
+ return {
22034
+ ast,
22035
+ code,
22036
+ customTransformCache,
22037
+ originalCode,
22038
+ originalSourcemap,
22039
+ sourcemapChain,
22040
+ transformDependencies
22041
+ };
21999
22042
  }
22000
22043
 
22001
22044
  class ModuleLoader {
@@ -22008,8 +22051,8 @@ class ModuleLoader {
22008
22051
  this.indexedEntryModules = [];
22009
22052
  this.latestLoadModulesPromise = Promise.resolve();
22010
22053
  this.moduleLoadPromises = new Map();
22054
+ this.modulesWithLoadedDependencies = new Set();
22011
22055
  this.nextEntryModuleIndex = 0;
22012
- this.readQueue = new Queue();
22013
22056
  this.resolveId = async (source, importer, customOptions, isEntry, skip = null) => {
22014
22057
  return this.addDefaultsToResolvedId(this.getNormalizedResolvedIdWithoutDefaults(this.options.external(source, importer, false)
22015
22058
  ? false
@@ -22018,7 +22061,7 @@ class ModuleLoader {
22018
22061
  this.hasModuleSideEffects = options.treeshake
22019
22062
  ? options.treeshake.moduleSideEffects
22020
22063
  : () => true;
22021
- this.readQueue.maxParallel = options.maxParallelFileReads;
22064
+ this.readQueue = new Queue(options.maxParallelFileReads);
22022
22065
  }
22023
22066
  async addAdditionalModules(unresolvedModules) {
22024
22067
  const result = this.extendLoadModulesPromise(Promise.all(unresolvedModules.map(id => this.loadEntryModule(id, false, undefined, null))));
@@ -22069,8 +22112,9 @@ class ModuleLoader {
22069
22112
  }
22070
22113
  return module;
22071
22114
  }
22072
- preloadModule(resolvedId) {
22073
- return this.fetchModule(this.addDefaultsToResolvedId(resolvedId), undefined, false, true).then(module => module.info);
22115
+ async preloadModule(resolvedId) {
22116
+ const module = await this.fetchModule(this.addDefaultsToResolvedId(resolvedId), undefined, false, true);
22117
+ return module.info;
22074
22118
  }
22075
22119
  addDefaultsToResolvedId(resolvedId) {
22076
22120
  var _a, _b;
@@ -22081,7 +22125,7 @@ class ModuleLoader {
22081
22125
  return {
22082
22126
  external,
22083
22127
  id: resolvedId.id,
22084
- meta: resolvedId.meta || EMPTY_OBJECT,
22128
+ meta: resolvedId.meta || {},
22085
22129
  moduleSideEffects: (_a = resolvedId.moduleSideEffects) !== null && _a !== void 0 ? _a : this.hasModuleSideEffects(resolvedId.id, !!external),
22086
22130
  syntheticNamedExports: (_b = resolvedId.syntheticNamedExports) !== null && _b !== void 0 ? _b : false
22087
22131
  };
@@ -22120,13 +22164,23 @@ class ModuleLoader {
22120
22164
  timeEnd('load modules', 3);
22121
22165
  const sourceDescription = typeof source === 'string'
22122
22166
  ? { code: source }
22123
- : typeof source === 'object' && typeof source.code === 'string'
22167
+ : source != null && typeof source === 'object' && typeof source.code === 'string'
22124
22168
  ? source
22125
22169
  : error(errBadLoader(id));
22126
22170
  const cachedModule = this.graph.cachedModules.get(id);
22127
22171
  if (cachedModule &&
22128
22172
  !cachedModule.customTransformCache &&
22129
- cachedModule.originalCode === sourceDescription.code) {
22173
+ cachedModule.originalCode === sourceDescription.code &&
22174
+ !(await this.pluginDriver.hookFirst('shouldTransformCachedModule', [
22175
+ {
22176
+ ast: cachedModule.ast,
22177
+ code: cachedModule.code,
22178
+ id: cachedModule.id,
22179
+ meta: cachedModule.meta,
22180
+ moduleSideEffects: cachedModule.moduleSideEffects,
22181
+ syntheticNamedExports: cachedModule.syntheticNamedExports
22182
+ }
22183
+ ]))) {
22130
22184
  if (cachedModule.transformFiles) {
22131
22185
  for (const emittedFile of cachedModule.transformFiles)
22132
22186
  this.pluginDriver.emitFile(emittedFile);
@@ -22186,7 +22240,8 @@ class ModuleLoader {
22186
22240
  this.graph.watchFiles[id] = true;
22187
22241
  const loadPromise = this.addModuleSource(id, importer, module).then(() => [
22188
22242
  this.getResolveStaticDependencyPromises(module),
22189
- this.getResolveDynamicImportPromises(module)
22243
+ this.getResolveDynamicImportPromises(module),
22244
+ loadAndResolveDependenciesPromise
22190
22245
  ]);
22191
22246
  const loadAndResolveDependenciesPromise = loadPromise
22192
22247
  .then(([resolveStaticDependencyPromises, resolveDynamicImportPromises]) => Promise.all([...resolveStaticDependencyPromises, ...resolveDynamicImportPromises]))
@@ -22194,23 +22249,25 @@ class ModuleLoader {
22194
22249
  loadAndResolveDependenciesPromise.catch(() => {
22195
22250
  /* avoid unhandled promise rejections */
22196
22251
  });
22197
- if (isPreload) {
22198
- this.moduleLoadPromises.set(module, loadPromise);
22199
- await loadPromise;
22200
- }
22201
- else {
22202
- await this.fetchModuleDependencies(module, ...(await loadPromise));
22203
- // To handle errors when resolving dependencies or in moduleParsed
22204
- await loadAndResolveDependenciesPromise;
22252
+ this.moduleLoadPromises.set(module, loadPromise);
22253
+ const resolveDependencyPromises = await loadPromise;
22254
+ if (!isPreload) {
22255
+ await this.fetchModuleDependencies(module, ...resolveDependencyPromises);
22205
22256
  }
22206
22257
  return module;
22207
22258
  }
22208
- async fetchModuleDependencies(module, resolveStaticDependencyPromises, resolveDynamicDependencyPromises) {
22259
+ async fetchModuleDependencies(module, resolveStaticDependencyPromises, resolveDynamicDependencyPromises, loadAndResolveDependenciesPromise) {
22260
+ if (this.modulesWithLoadedDependencies.has(module)) {
22261
+ return;
22262
+ }
22263
+ this.modulesWithLoadedDependencies.add(module);
22209
22264
  await Promise.all([
22210
22265
  this.fetchStaticDependencies(module, resolveStaticDependencyPromises),
22211
22266
  this.fetchDynamicDependencies(module, resolveDynamicDependencyPromises)
22212
22267
  ]);
22213
22268
  module.linkImports();
22269
+ // To handle errors when resolving dependencies or in moduleParsed
22270
+ await loadAndResolveDependenciesPromise;
22214
22271
  }
22215
22272
  fetchResolvedDependency(source, importer, resolvedId) {
22216
22273
  if (resolvedId.external) {
@@ -22299,8 +22356,7 @@ class ModuleLoader {
22299
22356
  async handleExistingModule(module, isEntry, isPreload) {
22300
22357
  const loadPromise = this.moduleLoadPromises.get(module);
22301
22358
  if (isPreload) {
22302
- await loadPromise;
22303
- return;
22359
+ return loadPromise;
22304
22360
  }
22305
22361
  if (isEntry) {
22306
22362
  module.info.isEntry = true;
@@ -22310,11 +22366,7 @@ class ModuleLoader {
22310
22366
  }
22311
22367
  module.implicitlyLoadedAfter.clear();
22312
22368
  }
22313
- if (loadPromise) {
22314
- this.moduleLoadPromises.delete(module);
22315
- await this.fetchModuleDependencies(module, ...(await loadPromise));
22316
- }
22317
- return;
22369
+ return this.fetchModuleDependencies(module, ...(await loadPromise));
22318
22370
  }
22319
22371
  handleResolveId(resolvedId, source, importer) {
22320
22372
  if (resolvedId === null) {
@@ -22325,7 +22377,7 @@ class ModuleLoader {
22325
22377
  return {
22326
22378
  external: true,
22327
22379
  id: source,
22328
- meta: EMPTY_OBJECT,
22380
+ meta: {},
22329
22381
  moduleSideEffects: this.hasModuleSideEffects(source, true),
22330
22382
  syntheticNamedExports: false
22331
22383
  };
@@ -22383,8 +22435,8 @@ class ModuleLoader {
22383
22435
  function normalizeRelativeExternalId(source, importer) {
22384
22436
  return isRelative(source)
22385
22437
  ? importer
22386
- ? path$2.resolve(importer, '..', source)
22387
- : path$2.resolve(source)
22438
+ ? require$$0.resolve(importer, '..', source)
22439
+ : require$$0.resolve(source)
22388
22440
  : source;
22389
22441
  }
22390
22442
  function addChunkNamesToModule(module, { fileName, name }, isUserDefined) {
@@ -22520,6 +22572,40 @@ function getPluginContext(plugin, pluginCache, graph, options, fileEmitter, exis
22520
22572
  return context;
22521
22573
  }
22522
22574
 
22575
+ const unfulfilledActions = new Set();
22576
+ function addUnresolvedAction(actionTuple) {
22577
+ unfulfilledActions.add(actionTuple);
22578
+ }
22579
+ function resolveAction(actionTuple) {
22580
+ unfulfilledActions.delete(actionTuple);
22581
+ }
22582
+ function formatAction([pluginName, hookName, args]) {
22583
+ let action = `(${pluginName}) ${hookName}`;
22584
+ const s = JSON.stringify;
22585
+ switch (hookName) {
22586
+ case 'resolveId':
22587
+ action += ` ${s(args[0])} ${s(args[1])}`;
22588
+ break;
22589
+ case 'load':
22590
+ action += ` ${s(args[0])}`;
22591
+ break;
22592
+ case 'transform':
22593
+ action += ` ${s(args[1])}`;
22594
+ break;
22595
+ }
22596
+ return action;
22597
+ }
22598
+ process.on('exit', () => {
22599
+ if (unfulfilledActions.size) {
22600
+ let err = '[!] Error: unfinished hook action(s) on exit:\n';
22601
+ for (const action of unfulfilledActions) {
22602
+ err += formatAction(action) + '\n';
22603
+ }
22604
+ console.error('%s', err);
22605
+ process.exit(1);
22606
+ }
22607
+ });
22608
+
22523
22609
  const inputHookNames = {
22524
22610
  buildEnd: 1,
22525
22611
  buildStart: 1,
@@ -22530,6 +22616,7 @@ const inputHookNames = {
22530
22616
  options: 1,
22531
22617
  resolveDynamicImport: 1,
22532
22618
  resolveId: 1,
22619
+ shouldTransformCachedModule: 1,
22533
22620
  transform: 1,
22534
22621
  watchChange: 1
22535
22622
  };
@@ -22671,6 +22758,7 @@ class PluginDriver {
22671
22758
  if (hookContext) {
22672
22759
  context = hookContext(context, plugin);
22673
22760
  }
22761
+ let action = null;
22674
22762
  return Promise.resolve()
22675
22763
  .then(() => {
22676
22764
  // permit values allows values to be returned instead of a functional hook
@@ -22680,9 +22768,35 @@ class PluginDriver {
22680
22768
  return throwInvalidHookError(hookName, plugin.name);
22681
22769
  }
22682
22770
  // eslint-disable-next-line @typescript-eslint/ban-types
22683
- return hook.apply(context, args);
22771
+ const hookResult = hook.apply(context, args);
22772
+ if (!hookResult || !hookResult.then) {
22773
+ // short circuit for non-thenables and non-Promises
22774
+ return hookResult;
22775
+ }
22776
+ // Track pending hook actions to properly error out when
22777
+ // unfulfilled promises cause rollup to abruptly and confusingly
22778
+ // exit with a successful 0 return code but without producing any
22779
+ // output, errors or warnings.
22780
+ action = [plugin.name, hookName, args];
22781
+ addUnresolvedAction(action);
22782
+ // Although it would be more elegant to just return hookResult here
22783
+ // and put the .then() handler just above the .catch() handler below,
22784
+ // doing so would subtly change the defacto async event dispatch order
22785
+ // which at least one test and some plugins in the wild may depend on.
22786
+ const promise = Promise.resolve(hookResult);
22787
+ return promise.then(() => {
22788
+ // action was fulfilled
22789
+ resolveAction(action);
22790
+ return promise;
22791
+ });
22684
22792
  })
22685
- .catch(err => throwPluginError(err, plugin.name, { hook: hookName }));
22793
+ .catch(err => {
22794
+ if (action !== null) {
22795
+ // action considered to be fulfilled since error being handled
22796
+ resolveAction(action);
22797
+ }
22798
+ return throwPluginError(err, plugin.name, { hook: hookName });
22799
+ });
22686
22800
  }
22687
22801
  /**
22688
22802
  * Run a sync plugin hook and return the result.
@@ -23047,7 +23161,7 @@ const getModuleContext = (config, context) => {
23047
23161
  if (configModuleContext) {
23048
23162
  const contextByModuleId = Object.create(null);
23049
23163
  for (const [key, moduleContext] of Object.entries(configModuleContext)) {
23050
- contextByModuleId[path$2.resolve(key)] = moduleContext;
23164
+ contextByModuleId[require$$0.resolve(key)] = moduleContext;
23051
23165
  }
23052
23166
  return id => contextByModuleId[id] || context;
23053
23167
  }
@@ -23253,7 +23367,7 @@ const getPreserveModulesRoot = (config) => {
23253
23367
  if (preserveModulesRoot === null || preserveModulesRoot === undefined) {
23254
23368
  return undefined;
23255
23369
  }
23256
- return path$2.resolve(preserveModulesRoot);
23370
+ return require$$0.resolve(preserveModulesRoot);
23257
23371
  };
23258
23372
  const getAmd = (config) => {
23259
23373
  const mergedOption = {
@@ -23525,7 +23639,7 @@ function getSortingFileType(file) {
23525
23639
  return SortingFileType.SECONDARY_CHUNK;
23526
23640
  }
23527
23641
  function writeOutputFile(outputFile, outputOptions) {
23528
- const fileName = path$2.resolve(outputOptions.dir || path$2.dirname(outputOptions.file), outputFile.fileName);
23642
+ const fileName = require$$0.resolve(outputOptions.dir || require$$0.dirname(outputOptions.file), outputFile.fileName);
23529
23643
  let writeSourceMapPromise;
23530
23644
  let source;
23531
23645
  if (outputFile.type === 'asset') {
@@ -23539,7 +23653,7 @@ function writeOutputFile(outputFile, outputOptions) {
23539
23653
  url = outputFile.map.toUrl();
23540
23654
  }
23541
23655
  else {
23542
- url = `${path$2.basename(outputFile.fileName)}.map`;
23656
+ url = `${require$$0.basename(outputFile.fileName)}.map`;
23543
23657
  writeSourceMapPromise = writeFile(`${fileName}.map`, outputFile.map.toString());
23544
23658
  }
23545
23659
  if (outputOptions.sourcemap !== 'hidden') {
@@ -23558,7 +23672,7 @@ function defineConfig(options) {
23558
23672
  return options;
23559
23673
  }
23560
23674
 
23561
- class WatchEmitter extends require$$0.EventEmitter {
23675
+ class WatchEmitter extends require$$0$1.EventEmitter {
23562
23676
  constructor() {
23563
23677
  super();
23564
23678
  // Allows more than 10 bundles to be watched without
@@ -23586,10 +23700,13 @@ exports.defaultOnWarn = defaultOnWarn;
23586
23700
  exports.defineConfig = defineConfig;
23587
23701
  exports.ensureArray = ensureArray$1;
23588
23702
  exports.error = error;
23703
+ exports.fseventsImporter = fseventsImporter;
23589
23704
  exports.generatedCodePresets = generatedCodePresets;
23590
23705
  exports.getAliasName = getAliasName;
23706
+ exports.getAugmentedNamespace = getAugmentedNamespace;
23591
23707
  exports.getOrCreate = getOrCreate;
23592
23708
  exports.loadFsEvents = loadFsEvents;
23709
+ exports.objectifyOption = objectifyOption;
23593
23710
  exports.objectifyOptionWithPresets = objectifyOptionWithPresets;
23594
23711
  exports.picomatch = picomatch;
23595
23712
  exports.printQuotedStringList = printQuotedStringList;