rollup 3.8.0 → 3.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE.md CHANGED
@@ -247,6 +247,23 @@ Repository: jonschlinkert/fill-range
247
247
 
248
248
  ---------------------------------------
249
249
 
250
+ ## flru
251
+ License: MIT
252
+ By: Luke Edwards
253
+ Repository: lukeed/flru
254
+
255
+ > MIT License
256
+ >
257
+ > Copyright (c) Luke Edwards <luke.edwards05@gmail.com> (lukeed.com)
258
+ >
259
+ > Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
260
+ >
261
+ > The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
262
+ >
263
+ > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
264
+
265
+ ---------------------------------------
266
+
250
267
  ## glob-parent
251
268
  License: ISC
252
269
  By: Gulp Team, Elan Shanker, Blaine Bublitz
package/dist/bin/rollup CHANGED
@@ -2,8 +2,8 @@
2
2
 
3
3
  /*
4
4
  @license
5
- Rollup.js v3.8.0
6
- Thu, 22 Dec 2022 05:21:04 GMT - commit d750ef25d5b31bc21237963446c0a46789b8630b
5
+ Rollup.js v3.9.0
6
+ Wed, 28 Dec 2022 05:59:30 GMT - commit 5aa1cce444e767c40cf86cdd96953201e4d32774
7
7
 
8
8
  https://github.com/rollup/rollup
9
9
 
package/dist/es/rollup.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v3.8.0
4
- Thu, 22 Dec 2022 05:21:04 GMT - commit d750ef25d5b31bc21237963446c0a46789b8630b
3
+ Rollup.js v3.9.0
4
+ Wed, 28 Dec 2022 05:59:30 GMT - commit 5aa1cce444e767c40cf86cdd96953201e4d32774
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v3.8.0
4
- Thu, 22 Dec 2022 05:21:04 GMT - commit d750ef25d5b31bc21237963446c0a46789b8630b
3
+ Rollup.js v3.9.0
4
+ Wed, 28 Dec 2022 05:59:30 GMT - commit 5aa1cce444e767c40cf86cdd96953201e4d32774
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -16,7 +16,7 @@ import { promises } from 'node:fs';
16
16
  import { EventEmitter } from 'node:events';
17
17
  import * as tty from 'tty';
18
18
 
19
- var version$1 = "3.8.0";
19
+ var version$1 = "3.9.0";
20
20
 
21
21
  var charToInteger = {};
22
22
  var chars$1 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
@@ -5399,8 +5399,6 @@ const ChainExpression$1 = 'ChainExpression';
5399
5399
  const ConditionalExpression$1 = 'ConditionalExpression';
5400
5400
  const ExpressionStatement$1 = 'ExpressionStatement';
5401
5401
  const Identifier$1 = 'Identifier';
5402
- const ImportDefaultSpecifier$1 = 'ImportDefaultSpecifier';
5403
- const ImportNamespaceSpecifier$1 = 'ImportNamespaceSpecifier';
5404
5402
  const LogicalExpression$1 = 'LogicalExpression';
5405
5403
  const NewExpression$1 = 'NewExpression';
5406
5404
  const Program$1 = 'Program';
@@ -5566,7 +5564,7 @@ function getAndCreateKeys(esTreeNode) {
5566
5564
 
5567
5565
  const INCLUDE_PARAMETERS = 'variables';
5568
5566
  class NodeBase extends ExpressionEntity {
5569
- constructor(esTreeNode, parent, parentScope) {
5567
+ constructor(esTreeNode, parent, parentScope, keepEsTreeNode = false) {
5570
5568
  super();
5571
5569
  /**
5572
5570
  * Nodes can apply custom deoptimizations once they become part of the
@@ -5575,7 +5573,9 @@ class NodeBase extends ExpressionEntity {
5575
5573
  * custom handlers
5576
5574
  */
5577
5575
  this.deoptimized = false;
5578
- this.esTreeNode = esTreeNode;
5576
+ // Nodes can opt-in to keep the AST if needed during the build pipeline.
5577
+ // Avoid true when possible as large AST takes up memory.
5578
+ this.esTreeNode = keepEsTreeNode ? esTreeNode : null;
5579
5579
  this.keys = keys[esTreeNode.type] || getAndCreateKeys(esTreeNode);
5580
5580
  this.parent = parent;
5581
5581
  this.context = parent.context;
@@ -5661,7 +5661,7 @@ class NodeBase extends ExpressionEntity {
5661
5661
  code.appendLeft(this.end, ';');
5662
5662
  }
5663
5663
  }
5664
- parseNode(esTreeNode) {
5664
+ parseNode(esTreeNode, keepEsTreeNodeKeys) {
5665
5665
  for (const [key, value] of Object.entries(esTreeNode)) {
5666
5666
  // That way, we can override this function to add custom initialisation and then call super.parseNode
5667
5667
  if (this.hasOwnProperty(key))
@@ -5683,11 +5683,11 @@ class NodeBase extends ExpressionEntity {
5683
5683
  for (const child of value) {
5684
5684
  this[key].push(child === null
5685
5685
  ? null
5686
- : new (this.context.getNodeConstructor(child.type))(child, this, this.scope));
5686
+ : new (this.context.getNodeConstructor(child.type))(child, this, this.scope, keepEsTreeNodeKeys?.includes(key)));
5687
5687
  }
5688
5688
  }
5689
5689
  else {
5690
- this[key] = new (this.context.getNodeConstructor(value.type))(value, this, this.scope);
5690
+ this[key] = new (this.context.getNodeConstructor(value.type))(value, this, this.scope, keepEsTreeNodeKeys?.includes(key));
5691
5691
  }
5692
5692
  }
5693
5693
  }
@@ -10674,6 +10674,10 @@ class ImportExpression extends NodeBase {
10674
10674
  initialise() {
10675
10675
  this.context.addDynamicImport(this);
10676
10676
  }
10677
+ parseNode(esTreeNode) {
10678
+ // Keep the source AST to be used by renderDynamicImport
10679
+ super.parseNode(esTreeNode, ['source']);
10680
+ }
10677
10681
  render(code, options) {
10678
10682
  const { snippets: { _, getDirectReturnFunction, getObject, getPropertyAccess } } = options;
10679
10683
  if (this.inlineNamespace) {
@@ -13264,9 +13268,7 @@ class Module {
13264
13268
  this.transformDependencies = transformDependencies;
13265
13269
  this.customTransformCache = customTransformCache;
13266
13270
  this.updateOptions(moduleOptions);
13267
- if (!ast) {
13268
- ast = this.tryParse();
13269
- }
13271
+ const moduleAst = ast || this.tryParse();
13270
13272
  timeEnd('generate ast', 3);
13271
13273
  timeStart('analyze ast', 3);
13272
13274
  this.resolvedIds = resolvedIds || Object.create(null);
@@ -13308,14 +13310,33 @@ class Module {
13308
13310
  };
13309
13311
  this.scope = new ModuleScope(this.graph.scope, this.astContext);
13310
13312
  this.namespace = new NamespaceVariable(this.astContext);
13311
- this.ast = new Program(ast, { context: this.astContext, type: 'Module' }, this.scope);
13312
- this.info.ast = ast;
13313
+ this.ast = new Program(moduleAst, { context: this.astContext, type: 'Module' }, this.scope);
13314
+ // Assign AST directly if has existing one as there's no way to drop it from memory.
13315
+ // If cache is enabled, also assign directly as otherwise it takes more CPU and memory to re-compute.
13316
+ if (ast || this.options.cache !== false) {
13317
+ this.info.ast = moduleAst;
13318
+ }
13319
+ else {
13320
+ // Make lazy and apply LRU cache to not hog the memory
13321
+ Object.defineProperty(this.info, 'ast', {
13322
+ get: () => {
13323
+ if (this.graph.astLru.has(fileName)) {
13324
+ return this.graph.astLru.get(fileName);
13325
+ }
13326
+ else {
13327
+ const parsedAst = this.tryParse();
13328
+ this.graph.astLru.set(fileName, parsedAst);
13329
+ return parsedAst;
13330
+ }
13331
+ }
13332
+ });
13333
+ }
13313
13334
  timeEnd('analyze ast', 3);
13314
13335
  }
13315
13336
  toJSON() {
13316
13337
  return {
13317
13338
  assertions: this.info.assertions,
13318
- ast: this.ast.esTreeNode,
13339
+ ast: this.info.ast,
13319
13340
  code: this.info.code,
13320
13341
  customTransformCache: this.customTransformCache,
13321
13342
  // eslint-disable-next-line unicorn/prefer-spread
@@ -13337,15 +13358,15 @@ class Module {
13337
13358
  if (localVariable) {
13338
13359
  return localVariable;
13339
13360
  }
13340
- const importDeclaration = this.importDescriptions.get(name);
13341
- if (importDeclaration) {
13342
- const otherModule = importDeclaration.module;
13343
- if (otherModule instanceof Module && importDeclaration.name === '*') {
13361
+ const importDescription = this.importDescriptions.get(name);
13362
+ if (importDescription) {
13363
+ const otherModule = importDescription.module;
13364
+ if (otherModule instanceof Module && importDescription.name === '*') {
13344
13365
  return otherModule.namespace;
13345
13366
  }
13346
- const [declaration] = getVariableForExportNameRecursive(otherModule, importDeclaration.name, importerForSideEffects || this, isExportAllSearch, searchedNamesAndModules);
13367
+ const [declaration] = getVariableForExportNameRecursive(otherModule, importDescription.name, importerForSideEffects || this, isExportAllSearch, searchedNamesAndModules);
13347
13368
  if (!declaration) {
13348
- return this.error(errorMissingExport(importDeclaration.name, this.id, otherModule.id), importDeclaration.start);
13369
+ return this.error(errorMissingExport(importDescription.name, this.id, otherModule.id), importDescription.start);
13349
13370
  }
13350
13371
  return declaration;
13351
13372
  }
@@ -13416,13 +13437,13 @@ class Module {
13416
13437
  // export { name } from './other'
13417
13438
  const source = node.source.value;
13418
13439
  this.addSource(source, node);
13419
- for (const specifier of node.specifiers) {
13420
- const name = specifier.exported.name;
13440
+ for (const { exported, local, start } of node.specifiers) {
13441
+ const name = exported instanceof Literal ? exported.value : exported.name;
13421
13442
  this.reexportDescriptions.set(name, {
13422
- localName: specifier.local.name,
13443
+ localName: local instanceof Literal ? local.value : local.name,
13423
13444
  module: null,
13424
13445
  source,
13425
- start: specifier.start
13446
+ start
13426
13447
  });
13427
13448
  }
13428
13449
  }
@@ -13445,9 +13466,10 @@ class Module {
13445
13466
  }
13446
13467
  else {
13447
13468
  // export { foo, bar, baz }
13448
- for (const specifier of node.specifiers) {
13449
- const localName = specifier.local.name;
13450
- const exportedName = specifier.exported.name;
13469
+ for (const { local, exported } of node.specifiers) {
13470
+ // except for reexports, local must be an Identifier
13471
+ const localName = local.name;
13472
+ const exportedName = exported instanceof Identifier ? exported.name : exported.value;
13451
13473
  this.exports.set(exportedName, { identifier: null, localName });
13452
13474
  }
13453
13475
  }
@@ -13456,9 +13478,13 @@ class Module {
13456
13478
  const source = node.source.value;
13457
13479
  this.addSource(source, node);
13458
13480
  for (const specifier of node.specifiers) {
13459
- const isDefault = specifier.type === ImportDefaultSpecifier$1;
13460
- const isNamespace = specifier.type === ImportNamespaceSpecifier$1;
13461
- const name = isDefault ? 'default' : isNamespace ? '*' : specifier.imported.name;
13481
+ const name = specifier instanceof ImportDefaultSpecifier
13482
+ ? 'default'
13483
+ : specifier instanceof ImportNamespaceSpecifier
13484
+ ? '*'
13485
+ : specifier.imported instanceof Identifier
13486
+ ? specifier.imported.name
13487
+ : specifier.imported.value;
13462
13488
  this.importDescriptions.set(specifier.local.name, {
13463
13489
  module: null,
13464
13490
  name,
@@ -15269,6 +15295,9 @@ class Chunk {
15269
15295
  continue;
15270
15296
  }
15271
15297
  const chunkDep = this.renderedDependencies.get(chunk);
15298
+ if (!chunkDep) {
15299
+ continue;
15300
+ }
15272
15301
  const { imports, reexports } = chunkDep;
15273
15302
  const importedByReexported = reexports?.find(({ reexported }) => reexported === exportName);
15274
15303
  const isImported = imports?.find(({ imported }) => imported === importedByReexported?.imported);
@@ -22328,6 +22357,50 @@ const acorn = /*#__PURE__*/Object.defineProperty({
22328
22357
  version
22329
22358
  }, Symbol.toStringTag, { value: 'Module' });
22330
22359
 
22360
+ function flru (max) {
22361
+ var num, curr, prev;
22362
+ var limit = max || 1;
22363
+
22364
+ function keep(key, value) {
22365
+ if (++num > limit) {
22366
+ prev = curr;
22367
+ reset(1);
22368
+ ++num;
22369
+ }
22370
+ curr[key] = value;
22371
+ }
22372
+
22373
+ function reset(isPartial) {
22374
+ num = 0;
22375
+ curr = Object.create(null);
22376
+ isPartial || (prev=Object.create(null));
22377
+ }
22378
+
22379
+ reset();
22380
+
22381
+ return {
22382
+ clear: reset,
22383
+ has: function (key) {
22384
+ return curr[key] !== void 0 || prev[key] !== void 0;
22385
+ },
22386
+ get: function (key) {
22387
+ var val = curr[key];
22388
+ if (val !== void 0) return val;
22389
+ if ((val=prev[key]) !== void 0) {
22390
+ keep(key, val);
22391
+ return val;
22392
+ }
22393
+ },
22394
+ set: function (key, value) {
22395
+ if (curr[key] !== void 0) {
22396
+ curr[key] = value;
22397
+ } else {
22398
+ keep(key, value);
22399
+ }
22400
+ }
22401
+ };
22402
+ }
22403
+
22331
22404
  function resolveIdViaPlugins(source, importer, pluginDriver, moduleLoaderResolveId, skip, customOptions, isEntry, assertions) {
22332
22405
  let skipped = null;
22333
22406
  let replaceContext = null;
@@ -23629,6 +23702,7 @@ function normalizeEntryModules(entryModules) {
23629
23702
  class Graph {
23630
23703
  constructor(options, watcher) {
23631
23704
  this.options = options;
23705
+ this.astLru = flru(5);
23632
23706
  this.cachedModules = new Map();
23633
23707
  this.deoptimizationTracker = new PathTracker();
23634
23708
  this.entryModules = [];
@@ -24731,10 +24805,12 @@ async function rollupInternal(rawInputOptions, watcher) {
24731
24805
  const { options: inputOptions, unsetOptions: unsetInputOptions } = await getInputOptions(rawInputOptions, watcher !== null);
24732
24806
  initialiseTimers(inputOptions);
24733
24807
  const graph = new Graph(inputOptions, watcher);
24734
- // remove the cache option from the memory after graph creation (cache is not used anymore)
24808
+ // remove the cache object from the memory after graph creation (cache is not used anymore)
24735
24809
  const useCache = rawInputOptions.cache !== false;
24736
- delete inputOptions.cache;
24737
- delete rawInputOptions.cache;
24810
+ if (rawInputOptions.cache) {
24811
+ inputOptions.cache = undefined;
24812
+ rawInputOptions.cache = undefined;
24813
+ }
24738
24814
  timeStart('BUILD', 1);
24739
24815
  await catchUnfinishedHookActions(graph.pluginDriver, async () => {
24740
24816
  try {
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v3.8.0
4
- Thu, 22 Dec 2022 05:21:04 GMT - commit d750ef25d5b31bc21237963446c0a46789b8630b
3
+ Rollup.js v3.9.0
4
+ Wed, 28 Dec 2022 05:59:30 GMT - commit 5aa1cce444e767c40cf86cdd96953201e4d32774
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v3.8.0
4
- Thu, 22 Dec 2022 05:21:04 GMT - commit d750ef25d5b31bc21237963446c0a46789b8630b
3
+ Rollup.js v3.9.0
4
+ Wed, 28 Dec 2022 05:59:30 GMT - commit 5aa1cce444e767c40cf86cdd96953201e4d32774
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
package/dist/rollup.d.ts CHANGED
@@ -456,6 +456,7 @@ export interface OutputPlugin
456
456
  Partial<{ [K in AddonHooks]: ObjectHook<AddonHook> }> {
457
457
  cacheKey?: string;
458
458
  name: string;
459
+ version?: string;
459
460
  }
460
461
 
461
462
  export interface Plugin extends OutputPlugin, Partial<PluginHooks> {
package/dist/rollup.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v3.8.0
4
- Thu, 22 Dec 2022 05:21:04 GMT - commit d750ef25d5b31bc21237963446c0a46789b8630b
3
+ Rollup.js v3.9.0
4
+ Wed, 28 Dec 2022 05:59:30 GMT - commit 5aa1cce444e767c40cf86cdd96953201e4d32774
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v3.8.0
4
- Thu, 22 Dec 2022 05:21:04 GMT - commit d750ef25d5b31bc21237963446c0a46789b8630b
3
+ Rollup.js v3.9.0
4
+ Wed, 28 Dec 2022 05:59:30 GMT - commit 5aa1cce444e767c40cf86cdd96953201e4d32774
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v3.8.0
4
- Thu, 22 Dec 2022 05:21:04 GMT - commit d750ef25d5b31bc21237963446c0a46789b8630b
3
+ Rollup.js v3.9.0
4
+ Wed, 28 Dec 2022 05:59:30 GMT - commit 5aa1cce444e767c40cf86cdd96953201e4d32774
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v3.8.0
4
- Thu, 22 Dec 2022 05:21:04 GMT - commit d750ef25d5b31bc21237963446c0a46789b8630b
3
+ Rollup.js v3.9.0
4
+ Wed, 28 Dec 2022 05:59:30 GMT - commit 5aa1cce444e767c40cf86cdd96953201e4d32774
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -31,7 +31,7 @@ function _interopNamespaceDefault(e) {
31
31
 
32
32
  const tty__namespace = /*#__PURE__*/_interopNamespaceDefault(tty);
33
33
 
34
- var version$1 = "3.8.0";
34
+ var version$1 = "3.9.0";
35
35
 
36
36
  function ensureArray$1(items) {
37
37
  if (Array.isArray(items)) {
@@ -5915,8 +5915,6 @@ const ChainExpression$1 = 'ChainExpression';
5915
5915
  const ConditionalExpression$1 = 'ConditionalExpression';
5916
5916
  const ExpressionStatement$1 = 'ExpressionStatement';
5917
5917
  const Identifier$1 = 'Identifier';
5918
- const ImportDefaultSpecifier$1 = 'ImportDefaultSpecifier';
5919
- const ImportNamespaceSpecifier$1 = 'ImportNamespaceSpecifier';
5920
5918
  const LogicalExpression$1 = 'LogicalExpression';
5921
5919
  const NewExpression$1 = 'NewExpression';
5922
5920
  const Program$1 = 'Program';
@@ -6082,7 +6080,7 @@ function getAndCreateKeys(esTreeNode) {
6082
6080
 
6083
6081
  const INCLUDE_PARAMETERS = 'variables';
6084
6082
  class NodeBase extends ExpressionEntity {
6085
- constructor(esTreeNode, parent, parentScope) {
6083
+ constructor(esTreeNode, parent, parentScope, keepEsTreeNode = false) {
6086
6084
  super();
6087
6085
  /**
6088
6086
  * Nodes can apply custom deoptimizations once they become part of the
@@ -6091,7 +6089,9 @@ class NodeBase extends ExpressionEntity {
6091
6089
  * custom handlers
6092
6090
  */
6093
6091
  this.deoptimized = false;
6094
- this.esTreeNode = esTreeNode;
6092
+ // Nodes can opt-in to keep the AST if needed during the build pipeline.
6093
+ // Avoid true when possible as large AST takes up memory.
6094
+ this.esTreeNode = keepEsTreeNode ? esTreeNode : null;
6095
6095
  this.keys = keys[esTreeNode.type] || getAndCreateKeys(esTreeNode);
6096
6096
  this.parent = parent;
6097
6097
  this.context = parent.context;
@@ -6177,7 +6177,7 @@ class NodeBase extends ExpressionEntity {
6177
6177
  code.appendLeft(this.end, ';');
6178
6178
  }
6179
6179
  }
6180
- parseNode(esTreeNode) {
6180
+ parseNode(esTreeNode, keepEsTreeNodeKeys) {
6181
6181
  for (const [key, value] of Object.entries(esTreeNode)) {
6182
6182
  // That way, we can override this function to add custom initialisation and then call super.parseNode
6183
6183
  if (this.hasOwnProperty(key))
@@ -6199,11 +6199,11 @@ class NodeBase extends ExpressionEntity {
6199
6199
  for (const child of value) {
6200
6200
  this[key].push(child === null
6201
6201
  ? null
6202
- : new (this.context.getNodeConstructor(child.type))(child, this, this.scope));
6202
+ : new (this.context.getNodeConstructor(child.type))(child, this, this.scope, keepEsTreeNodeKeys?.includes(key)));
6203
6203
  }
6204
6204
  }
6205
6205
  else {
6206
- this[key] = new (this.context.getNodeConstructor(value.type))(value, this, this.scope);
6206
+ this[key] = new (this.context.getNodeConstructor(value.type))(value, this, this.scope, keepEsTreeNodeKeys?.includes(key));
6207
6207
  }
6208
6208
  }
6209
6209
  }
@@ -11190,6 +11190,10 @@ class ImportExpression extends NodeBase {
11190
11190
  initialise() {
11191
11191
  this.context.addDynamicImport(this);
11192
11192
  }
11193
+ parseNode(esTreeNode) {
11194
+ // Keep the source AST to be used by renderDynamicImport
11195
+ super.parseNode(esTreeNode, ['source']);
11196
+ }
11193
11197
  render(code, options) {
11194
11198
  const { snippets: { _, getDirectReturnFunction, getObject, getPropertyAccess } } = options;
11195
11199
  if (this.inlineNamespace) {
@@ -13780,9 +13784,7 @@ class Module {
13780
13784
  this.transformDependencies = transformDependencies;
13781
13785
  this.customTransformCache = customTransformCache;
13782
13786
  this.updateOptions(moduleOptions);
13783
- if (!ast) {
13784
- ast = this.tryParse();
13785
- }
13787
+ const moduleAst = ast || this.tryParse();
13786
13788
  timeEnd('generate ast', 3);
13787
13789
  timeStart('analyze ast', 3);
13788
13790
  this.resolvedIds = resolvedIds || Object.create(null);
@@ -13824,14 +13826,33 @@ class Module {
13824
13826
  };
13825
13827
  this.scope = new ModuleScope(this.graph.scope, this.astContext);
13826
13828
  this.namespace = new NamespaceVariable(this.astContext);
13827
- this.ast = new Program(ast, { context: this.astContext, type: 'Module' }, this.scope);
13828
- this.info.ast = ast;
13829
+ this.ast = new Program(moduleAst, { context: this.astContext, type: 'Module' }, this.scope);
13830
+ // Assign AST directly if has existing one as there's no way to drop it from memory.
13831
+ // If cache is enabled, also assign directly as otherwise it takes more CPU and memory to re-compute.
13832
+ if (ast || this.options.cache !== false) {
13833
+ this.info.ast = moduleAst;
13834
+ }
13835
+ else {
13836
+ // Make lazy and apply LRU cache to not hog the memory
13837
+ Object.defineProperty(this.info, 'ast', {
13838
+ get: () => {
13839
+ if (this.graph.astLru.has(fileName)) {
13840
+ return this.graph.astLru.get(fileName);
13841
+ }
13842
+ else {
13843
+ const parsedAst = this.tryParse();
13844
+ this.graph.astLru.set(fileName, parsedAst);
13845
+ return parsedAst;
13846
+ }
13847
+ }
13848
+ });
13849
+ }
13829
13850
  timeEnd('analyze ast', 3);
13830
13851
  }
13831
13852
  toJSON() {
13832
13853
  return {
13833
13854
  assertions: this.info.assertions,
13834
- ast: this.ast.esTreeNode,
13855
+ ast: this.info.ast,
13835
13856
  code: this.info.code,
13836
13857
  customTransformCache: this.customTransformCache,
13837
13858
  // eslint-disable-next-line unicorn/prefer-spread
@@ -13853,15 +13874,15 @@ class Module {
13853
13874
  if (localVariable) {
13854
13875
  return localVariable;
13855
13876
  }
13856
- const importDeclaration = this.importDescriptions.get(name);
13857
- if (importDeclaration) {
13858
- const otherModule = importDeclaration.module;
13859
- if (otherModule instanceof Module && importDeclaration.name === '*') {
13877
+ const importDescription = this.importDescriptions.get(name);
13878
+ if (importDescription) {
13879
+ const otherModule = importDescription.module;
13880
+ if (otherModule instanceof Module && importDescription.name === '*') {
13860
13881
  return otherModule.namespace;
13861
13882
  }
13862
- const [declaration] = getVariableForExportNameRecursive(otherModule, importDeclaration.name, importerForSideEffects || this, isExportAllSearch, searchedNamesAndModules);
13883
+ const [declaration] = getVariableForExportNameRecursive(otherModule, importDescription.name, importerForSideEffects || this, isExportAllSearch, searchedNamesAndModules);
13863
13884
  if (!declaration) {
13864
- return this.error(errorMissingExport(importDeclaration.name, this.id, otherModule.id), importDeclaration.start);
13885
+ return this.error(errorMissingExport(importDescription.name, this.id, otherModule.id), importDescription.start);
13865
13886
  }
13866
13887
  return declaration;
13867
13888
  }
@@ -13932,13 +13953,13 @@ class Module {
13932
13953
  // export { name } from './other'
13933
13954
  const source = node.source.value;
13934
13955
  this.addSource(source, node);
13935
- for (const specifier of node.specifiers) {
13936
- const name = specifier.exported.name;
13956
+ for (const { exported, local, start } of node.specifiers) {
13957
+ const name = exported instanceof Literal ? exported.value : exported.name;
13937
13958
  this.reexportDescriptions.set(name, {
13938
- localName: specifier.local.name,
13959
+ localName: local instanceof Literal ? local.value : local.name,
13939
13960
  module: null,
13940
13961
  source,
13941
- start: specifier.start
13962
+ start
13942
13963
  });
13943
13964
  }
13944
13965
  }
@@ -13961,9 +13982,10 @@ class Module {
13961
13982
  }
13962
13983
  else {
13963
13984
  // export { foo, bar, baz }
13964
- for (const specifier of node.specifiers) {
13965
- const localName = specifier.local.name;
13966
- const exportedName = specifier.exported.name;
13985
+ for (const { local, exported } of node.specifiers) {
13986
+ // except for reexports, local must be an Identifier
13987
+ const localName = local.name;
13988
+ const exportedName = exported instanceof Identifier ? exported.name : exported.value;
13967
13989
  this.exports.set(exportedName, { identifier: null, localName });
13968
13990
  }
13969
13991
  }
@@ -13972,9 +13994,13 @@ class Module {
13972
13994
  const source = node.source.value;
13973
13995
  this.addSource(source, node);
13974
13996
  for (const specifier of node.specifiers) {
13975
- const isDefault = specifier.type === ImportDefaultSpecifier$1;
13976
- const isNamespace = specifier.type === ImportNamespaceSpecifier$1;
13977
- const name = isDefault ? 'default' : isNamespace ? '*' : specifier.imported.name;
13997
+ const name = specifier instanceof ImportDefaultSpecifier
13998
+ ? 'default'
13999
+ : specifier instanceof ImportNamespaceSpecifier
14000
+ ? '*'
14001
+ : specifier.imported instanceof Identifier
14002
+ ? specifier.imported.name
14003
+ : specifier.imported.value;
13978
14004
  this.importDescriptions.set(specifier.local.name, {
13979
14005
  module: null,
13980
14006
  name,
@@ -15785,6 +15811,9 @@ class Chunk {
15785
15811
  continue;
15786
15812
  }
15787
15813
  const chunkDep = this.renderedDependencies.get(chunk);
15814
+ if (!chunkDep) {
15815
+ continue;
15816
+ }
15788
15817
  const { imports, reexports } = chunkDep;
15789
15818
  const importedByReexported = reexports?.find(({ reexported }) => reexported === exportName);
15790
15819
  const isImported = imports?.find(({ imported }) => imported === importedByReexported?.imported);
@@ -22844,6 +22873,50 @@ const acorn = /*#__PURE__*/Object.defineProperty({
22844
22873
  version
22845
22874
  }, Symbol.toStringTag, { value: 'Module' });
22846
22875
 
22876
+ function flru (max) {
22877
+ var num, curr, prev;
22878
+ var limit = max || 1;
22879
+
22880
+ function keep(key, value) {
22881
+ if (++num > limit) {
22882
+ prev = curr;
22883
+ reset(1);
22884
+ ++num;
22885
+ }
22886
+ curr[key] = value;
22887
+ }
22888
+
22889
+ function reset(isPartial) {
22890
+ num = 0;
22891
+ curr = Object.create(null);
22892
+ isPartial || (prev=Object.create(null));
22893
+ }
22894
+
22895
+ reset();
22896
+
22897
+ return {
22898
+ clear: reset,
22899
+ has: function (key) {
22900
+ return curr[key] !== void 0 || prev[key] !== void 0;
22901
+ },
22902
+ get: function (key) {
22903
+ var val = curr[key];
22904
+ if (val !== void 0) return val;
22905
+ if ((val=prev[key]) !== void 0) {
22906
+ keep(key, val);
22907
+ return val;
22908
+ }
22909
+ },
22910
+ set: function (key, value) {
22911
+ if (curr[key] !== void 0) {
22912
+ curr[key] = value;
22913
+ } else {
22914
+ keep(key, value);
22915
+ }
22916
+ }
22917
+ };
22918
+ }
22919
+
22847
22920
  function resolveIdViaPlugins(source, importer, pluginDriver, moduleLoaderResolveId, skip, customOptions, isEntry, assertions) {
22848
22921
  let skipped = null;
22849
22922
  let replaceContext = null;
@@ -24145,6 +24218,7 @@ function normalizeEntryModules(entryModules) {
24145
24218
  class Graph {
24146
24219
  constructor(options, watcher) {
24147
24220
  this.options = options;
24221
+ this.astLru = flru(5);
24148
24222
  this.cachedModules = new Map();
24149
24223
  this.deoptimizationTracker = new PathTracker();
24150
24224
  this.entryModules = [];
@@ -25150,10 +25224,12 @@ async function rollupInternal(rawInputOptions, watcher) {
25150
25224
  const { options: inputOptions, unsetOptions: unsetInputOptions } = await getInputOptions(rawInputOptions, watcher !== null);
25151
25225
  initialiseTimers(inputOptions);
25152
25226
  const graph = new Graph(inputOptions, watcher);
25153
- // remove the cache option from the memory after graph creation (cache is not used anymore)
25227
+ // remove the cache object from the memory after graph creation (cache is not used anymore)
25154
25228
  const useCache = rawInputOptions.cache !== false;
25155
- delete inputOptions.cache;
25156
- delete rawInputOptions.cache;
25229
+ if (rawInputOptions.cache) {
25230
+ inputOptions.cache = undefined;
25231
+ rawInputOptions.cache = undefined;
25232
+ }
25157
25233
  timeStart('BUILD', 1);
25158
25234
  await catchUnfinishedHookActions(graph.pluginDriver, async () => {
25159
25235
  try {
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v3.8.0
4
- Thu, 22 Dec 2022 05:21:04 GMT - commit d750ef25d5b31bc21237963446c0a46789b8630b
3
+ Rollup.js v3.9.0
4
+ Wed, 28 Dec 2022 05:59:30 GMT - commit 5aa1cce444e767c40cf86cdd96953201e4d32774
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v3.8.0
4
- Thu, 22 Dec 2022 05:21:04 GMT - commit d750ef25d5b31bc21237963446c0a46789b8630b
3
+ Rollup.js v3.9.0
4
+ Wed, 28 Dec 2022 05:59:30 GMT - commit 5aa1cce444e767c40cf86cdd96953201e4d32774
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.8.0",
3
+ "version": "3.9.0",
4
4
  "description": "Next-generation ES module bundler",
5
5
  "main": "dist/rollup.js",
6
6
  "module": "dist/es/rollup.js",
@@ -90,6 +90,7 @@
90
90
  "eslint-plugin-prettier": "^4.2.1",
91
91
  "eslint-plugin-unicorn": "^44.0.2",
92
92
  "fixturify": "^2.1.1",
93
+ "flru": "^1.0.2",
93
94
  "fs-extra": "^10.1.0",
94
95
  "github-api": "^3.4.0",
95
96
  "hash.js": "^1.1.7",