rollup 4.40.1 → 4.41.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/dist/bin/rollup CHANGED
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
  /*
3
3
  @license
4
- Rollup.js v4.40.1
5
- Mon, 28 Apr 2025 04:34:51 GMT - commit 1e6c40f49c428b7657fe3b9a2026f705acd39da1
4
+ Rollup.js v4.41.0
5
+ Sun, 18 May 2025 05:33:01 GMT - commit 0928185cd544907dab472754634ddf988452aae6
6
6
 
7
7
  https://github.com/rollup/rollup
8
8
 
@@ -1577,8 +1577,36 @@ const toLocaleString = (number, locale, options) => {
1577
1577
  return result;
1578
1578
  };
1579
1579
 
1580
+ const log10 = numberOrBigInt => {
1581
+ if (typeof numberOrBigInt === 'number') {
1582
+ return Math.log10(numberOrBigInt);
1583
+ }
1584
+
1585
+ const string = numberOrBigInt.toString(10);
1586
+
1587
+ return string.length + Math.log10('0.' + string.slice(0, 15));
1588
+ };
1589
+
1590
+ const log = numberOrBigInt => {
1591
+ if (typeof numberOrBigInt === 'number') {
1592
+ return Math.log(numberOrBigInt);
1593
+ }
1594
+
1595
+ return log10(numberOrBigInt) * Math.log(10);
1596
+ };
1597
+
1598
+ const divide = (numberOrBigInt, divisor) => {
1599
+ if (typeof numberOrBigInt === 'number') {
1600
+ return numberOrBigInt / divisor;
1601
+ }
1602
+
1603
+ const integerPart = numberOrBigInt / BigInt(divisor);
1604
+ const remainder = numberOrBigInt % BigInt(divisor);
1605
+ return Number(integerPart) + (Number(remainder) / divisor);
1606
+ };
1607
+
1580
1608
  function prettyBytes(number, options) {
1581
- if (!Number.isFinite(number)) {
1609
+ if (typeof number !== 'bigint' && !Number.isFinite(number)) {
1582
1610
  throw new TypeError(`Expected a finite number, got ${typeof number}: ${number}`);
1583
1611
  }
1584
1612
 
@@ -1595,7 +1623,7 @@ function prettyBytes(number, options) {
1595
1623
 
1596
1624
  const separator = options.space ? ' ' : '';
1597
1625
 
1598
- if (options.signed && number === 0) {
1626
+ if (options.signed && (typeof number === 'number' ? number === 0 : number === 0n)) {
1599
1627
  return ` 0${separator}${UNITS[0]}`;
1600
1628
  }
1601
1629
 
@@ -1621,8 +1649,8 @@ function prettyBytes(number, options) {
1621
1649
  return prefix + numberString + separator + UNITS[0];
1622
1650
  }
1623
1651
 
1624
- const exponent = Math.min(Math.floor(options.binary ? Math.log(number) / Math.log(1024) : Math.log10(number) / 3), UNITS.length - 1);
1625
- number /= (options.binary ? 1024 : 1000) ** exponent;
1652
+ const exponent = Math.min(Math.floor(options.binary ? log(number) / Math.log(1024) : log10(number) / 3), UNITS.length - 1);
1653
+ number = divide(number, (options.binary ? 1024 : 1000) ** exponent);
1626
1654
 
1627
1655
  if (!localeOptions) {
1628
1656
  number = number.toPrecision(3);
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v4.40.1
4
- Mon, 28 Apr 2025 04:34:51 GMT - commit 1e6c40f49c428b7657fe3b9a2026f705acd39da1
3
+ Rollup.js v4.41.0
4
+ Sun, 18 May 2025 05:33:01 GMT - commit 0928185cd544907dab472754634ddf988452aae6
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v4.40.1
4
- Mon, 28 Apr 2025 04:34:51 GMT - commit 1e6c40f49c428b7657fe3b9a2026f705acd39da1
3
+ Rollup.js v4.41.0
4
+ Sun, 18 May 2025 05:33:01 GMT - commit 0928185cd544907dab472754634ddf988452aae6
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
package/dist/es/rollup.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v4.40.1
4
- Mon, 28 Apr 2025 04:34:51 GMT - commit 1e6c40f49c428b7657fe3b9a2026f705acd39da1
3
+ Rollup.js v4.41.0
4
+ Sun, 18 May 2025 05:33:01 GMT - commit 0928185cd544907dab472754634ddf988452aae6
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -1,13 +1,13 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v4.40.1
4
- Mon, 28 Apr 2025 04:34:51 GMT - commit 1e6c40f49c428b7657fe3b9a2026f705acd39da1
3
+ Rollup.js v4.41.0
4
+ Sun, 18 May 2025 05:33:01 GMT - commit 0928185cd544907dab472754634ddf988452aae6
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
8
8
  Released under the MIT License.
9
9
  */
10
- import { EMPTY_OBJECT, ExportDefaultDeclaration as ExportDefaultDeclaration$1, CallExpression as CallExpression$1, EMPTY_ARRAY, LOGLEVEL_WARN, logUnusedExternalImports, ANNOTATION_KEY, INVALID_ANNOTATION_KEY, ObjectExpression as ObjectExpression$1, Property as Property$1, Program as Program$1, logIllegalImportReassignment, BLANK, logRedeclarationError, StaticBlock as StaticBlock$1, CatchClause as CatchClause$1, logDuplicateArgumentNameError, logModuleLevelDirective, ReturnStatement as ReturnStatement$1, VariableDeclarator as VariableDeclarator$1, ExpressionStatement as ExpressionStatement$1, logMissingExport, normalize, getImportPath, logMissingNodeBuiltins, logReservedNamespace, error, logIllegalIdentifierAsName, logMissingNameOptionForIifeExport, logMissingNameOptionForUmdExport, RestElement as RestElement$1, logConstVariableReassignError, ArrowFunctionExpression as ArrowFunctionExpression$1, EMPTY_SET, logCannotCallNamespace, logEval, BlockStatement as BlockStatement$1, getRollupError, logModuleParseError, logParseError, LOGLEVEL_INFO, logFirstSideEffect, locate, logInvalidAnnotation, Identifier as Identifier$1, logThisIsUndefined, getAstBuffer, convertAnnotations, FIXED_STRINGS, convertNode as convertNode$1, logImportAttributeIsInvalid, logImportOptionsAreInvalid, logSyntheticNamedExportsNeedNamespaceExport, logMissingEntryExport, logDuplicateExportError, logInvalidSourcemapForError, augmentCodeLocation, logInconsistentImportAttributes, logMissingJsxExport, logNamespaceConflict, logAmbiguousExternalNamespaces, logShimmedExport, parseAst, logInvalidFormatForTopLevelAwait, TemplateLiteral as TemplateLiteral$1, Literal as Literal$1, logCircularReexport, logAddonNotGenerated, logIncompatibleExportOptionValue, logMixedExport, logFailedValidation, isPathFragment, logCyclicCrossChunkReexport, getAliasName, logUnexpectedNamedImport, isAbsolute as isAbsolute$1, relative as relative$1, logUnexpectedNamespaceReexport, logEmptyChunk, logMissingGlobalName, logOptimizeChunkStatus, logSourcemapBroken, logConflictingSourcemapSources, logChunkInvalid, logInvalidOption, logCannotAssignModuleToChunk, URL_OUTPUT_FORMAT, URL_OUTPUT_DIR, URL_OUTPUT_SOURCEMAPFILE, URL_OUTPUT_AMD_ID, logAnonymousPluginCache, logDuplicatePluginName, logUnknownOption, LOGLEVEL_ERROR, logLevelPriority, LOGLEVEL_DEBUG, printQuotedStringList, logInvalidSetAssetSourceCall, logPluginError, logNoTransformMapOrAstWithoutCode, relativeId, logBadLoader, logExternalModulesCannotBeTransformedToModules, logInternalIdCannotBeExternal, isRelative, logUnresolvedImport, logUnresolvedImportTreatedAsExternal, logExternalSyntheticExports, logUnresolvedEntry, logUnresolvedImplicitDependant, logExternalModulesCannotBeIncludedInManualChunks, logEntryCannotBeExternal, logImplicitDependantCannotBeExternal, logNoAssetSourceSet, logFileReferenceIdNotFoundForFilename, logAssetReferenceIdNotFoundForSetSource, logAssetSourceAlreadySet, logInvalidRollupPhaseForChunkEmission, warnDeprecation, logChunkNotGeneratedForFileName, logAssetNotFinalisedForFileName, logFileNameConflict, URL_GENERATEBUNDLE, logInvalidLogPosition, logInputHookInOutputPlugin, logInvalidAddonPluginHook, logInvalidFunctionPluginHook, logImplicitDependantIsNotIncluded, logCircularDependency, augmentLogMessage, URL_TREESHAKE, URL_JSX, URL_TREESHAKE_MODULESIDEEFFECTS, URL_OUTPUT_INLINEDYNAMICIMPORTS, URL_PRESERVEENTRYSIGNATURES, URL_OUTPUT_GENERATEDCODE, isValidUrl, addTrailingSlashIfMissed, URL_OUTPUT_SOURCEMAPBASEURL, URL_OUTPUT_MANUALCHUNKS, logInvalidExportOptionValue, URL_OUTPUT_AMD_BASEPATH, URL_OUTPUT_INTEROP, URL_OUTPUT_EXTERNALIMPORTATTRIBUTES, logAlreadyClosed, logMissingFileOrDirOption, logCannotEmitFromOptionsHook, URL_WATCH } from './parseAst.js';
10
+ import { EMPTY_OBJECT, ExportDefaultDeclaration as ExportDefaultDeclaration$1, CallExpression as CallExpression$1, EMPTY_ARRAY, LOGLEVEL_WARN, logUnusedExternalImports, ANNOTATION_KEY, INVALID_ANNOTATION_KEY, ArrowFunctionExpression as ArrowFunctionExpression$1, MemberExpression as MemberExpression$1, Identifier as Identifier$1, ImportExpression as ImportExpression$1, AwaitExpression as AwaitExpression$1, ObjectExpression as ObjectExpression$1, Property as Property$1, Program as Program$1, logIllegalImportReassignment, BLANK, logRedeclarationError, StaticBlock as StaticBlock$1, CatchClause as CatchClause$1, logDuplicateArgumentNameError, logModuleLevelDirective, ReturnStatement as ReturnStatement$1, VariableDeclarator as VariableDeclarator$1, ExpressionStatement as ExpressionStatement$1, logMissingExport, normalize, getImportPath, logMissingNodeBuiltins, logReservedNamespace, error, logIllegalIdentifierAsName, logMissingNameOptionForIifeExport, logMissingNameOptionForUmdExport, RestElement as RestElement$1, logConstVariableReassignError, EMPTY_SET, logCannotCallNamespace, logEval, BlockStatement as BlockStatement$1, getRollupError, logModuleParseError, logParseError, LOGLEVEL_INFO, logFirstSideEffect, locate, logInvalidAnnotation, logThisIsUndefined, getAstBuffer, convertAnnotations, FIXED_STRINGS, convertNode as convertNode$1, logImportAttributeIsInvalid, logImportOptionsAreInvalid, logSyntheticNamedExportsNeedNamespaceExport, logMissingEntryExport, logDuplicateExportError, logInvalidSourcemapForError, augmentCodeLocation, logInconsistentImportAttributes, logMissingJsxExport, logNamespaceConflict, logAmbiguousExternalNamespaces, logShimmedExport, parseAst, logInvalidFormatForTopLevelAwait, TemplateLiteral as TemplateLiteral$1, Literal as Literal$1, logCircularReexport, logAddonNotGenerated, logIncompatibleExportOptionValue, logMixedExport, logFailedValidation, isPathFragment, logCyclicCrossChunkReexport, getAliasName, logUnexpectedNamedImport, isAbsolute as isAbsolute$1, relative as relative$1, logUnexpectedNamespaceReexport, logEmptyChunk, logMissingGlobalName, logOptimizeChunkStatus, logSourcemapBroken, logConflictingSourcemapSources, logChunkInvalid, logInvalidOption, URL_OUTPUT_FORMAT, URL_OUTPUT_DIR, URL_OUTPUT_SOURCEMAPFILE, URL_OUTPUT_AMD_ID, logCannotAssignModuleToChunk, logAnonymousPluginCache, logDuplicatePluginName, logUnknownOption, LOGLEVEL_ERROR, logLevelPriority, LOGLEVEL_DEBUG, printQuotedStringList, logInvalidSetAssetSourceCall, logPluginError, logNoTransformMapOrAstWithoutCode, relativeId, logBadLoader, logExternalModulesCannotBeTransformedToModules, logInternalIdCannotBeExternal, isRelative, logUnresolvedImport, logUnresolvedImportTreatedAsExternal, logExternalSyntheticExports, logUnresolvedEntry, logUnresolvedImplicitDependant, logExternalModulesCannotBeIncludedInManualChunks, logEntryCannotBeExternal, logImplicitDependantCannotBeExternal, logNoAssetSourceSet, logFileReferenceIdNotFoundForFilename, logAssetReferenceIdNotFoundForSetSource, logAssetSourceAlreadySet, logInvalidRollupPhaseForChunkEmission, warnDeprecation, logChunkNotGeneratedForFileName, logAssetNotFinalisedForFileName, logFileNameConflict, URL_GENERATEBUNDLE, logInvalidLogPosition, logInputHookInOutputPlugin, logInvalidAddonPluginHook, logInvalidFunctionPluginHook, logImplicitDependantIsNotIncluded, logCircularDependency, augmentLogMessage, URL_JSX, URL_TREESHAKE_MODULESIDEEFFECTS, URL_TREESHAKE, URL_OUTPUT_INLINEDYNAMICIMPORTS, URL_PRESERVEENTRYSIGNATURES, URL_OUTPUT_GENERATEDCODE, isValidUrl, addTrailingSlashIfMissed, URL_OUTPUT_SOURCEMAPBASEURL, URL_OUTPUT_MANUALCHUNKS, logInvalidExportOptionValue, URL_OUTPUT_AMD_BASEPATH, URL_OUTPUT_INTEROP, URL_OUTPUT_EXTERNALIMPORTATTRIBUTES, logAlreadyClosed, logMissingFileOrDirOption, logCannotEmitFromOptionsHook, URL_WATCH } from './parseAst.js';
11
11
  import { relative, dirname, basename, extname, resolve as resolve$1 } from 'node:path';
12
12
  import { posix, isAbsolute, resolve, win32 } from 'path';
13
13
  import { parseAsync, xxhashBase16, xxhashBase64Url, xxhashBase36 } from '../../native.js';
@@ -15,7 +15,7 @@ import process$1, { env } from 'node:process';
15
15
  import { performance } from 'node:perf_hooks';
16
16
  import { lstat, realpath, readdir, readFile, mkdir, writeFile } from 'node:fs/promises';
17
17
 
18
- var version = "4.40.1";
18
+ var version = "4.41.0";
19
19
 
20
20
  const comma = ','.charCodeAt(0);
21
21
  const semicolon = ';'.charCodeAt(0);
@@ -2192,8 +2192,7 @@ function createInclusionContext() {
2192
2192
  hasBreak: false,
2193
2193
  hasContinue: false,
2194
2194
  includedCallArguments: new Set(),
2195
- includedLabels: new Set(),
2196
- withinTopLevelAwait: false
2195
+ includedLabels: new Set()
2197
2196
  };
2198
2197
  }
2199
2198
  function createHasEffectsContext() {
@@ -2288,10 +2287,13 @@ const deoptimizeInteraction = (interaction) => {
2288
2287
  argument?.deoptimizePath(UNKNOWN_PATH);
2289
2288
  }
2290
2289
  };
2291
- const includeInteraction = ({ args }, context) => {
2290
+ const includeInteraction = (interaction, context) => {
2292
2291
  // We do not re-include the "this" argument as we expect this is already
2293
2292
  // re-included at the call site
2294
- args[0]?.includePath(UNKNOWN_PATH, context);
2293
+ interaction.args[0]?.includePath(UNKNOWN_PATH, context);
2294
+ includeInteractionWithoutThis(interaction, context);
2295
+ };
2296
+ const includeInteractionWithoutThis = ({ args }, context) => {
2295
2297
  for (let argumentIndex = 1; argumentIndex < args.length; argumentIndex++) {
2296
2298
  const argument = args[argumentIndex];
2297
2299
  if (argument) {
@@ -2968,7 +2970,25 @@ function isObjectExpressionNode(node) {
2968
2970
  return node instanceof NodeBase && node.type === ObjectExpression$1;
2969
2971
  }
2970
2972
  function isPropertyNode(node) {
2971
- return node.type === Property$1;
2973
+ return node instanceof NodeBase && node.type === Property$1;
2974
+ }
2975
+ function isArrowFunctionExpressionNode(node) {
2976
+ return node instanceof NodeBase && node.type === ArrowFunctionExpression$1;
2977
+ }
2978
+ function isCallExpressionNode(node) {
2979
+ return node instanceof NodeBase && node.type === CallExpression$1;
2980
+ }
2981
+ function isMemberExpressionNode(node) {
2982
+ return node instanceof NodeBase && node.type === MemberExpression$1;
2983
+ }
2984
+ function isImportExpressionNode(node) {
2985
+ return node instanceof NodeBase && node.type === ImportExpression$1;
2986
+ }
2987
+ function isAwaitExpressionNode(node) {
2988
+ return node instanceof NodeBase && node.type === AwaitExpression$1;
2989
+ }
2990
+ function isIdentifierNode(node) {
2991
+ return node instanceof NodeBase && node.type === Identifier$1;
2972
2992
  }
2973
2993
 
2974
2994
  function assembleMemberDescriptions(memberDescriptions, inheritedDescriptions = null) {
@@ -5103,6 +5123,20 @@ class LocalVariable extends Variable {
5103
5123
  break;
5104
5124
  node = node.parent;
5105
5125
  }
5126
+ /**
5127
+ * import('foo').then(m => {
5128
+ * console.log(m.foo)
5129
+ * })
5130
+ */
5131
+ if (this.kind === 'parameter' &&
5132
+ isArrowFunctionExpressionNode(declaration.parent) &&
5133
+ isCallExpressionNode(declaration.parent.parent) &&
5134
+ isMemberExpressionNode(declaration.parent.parent.callee) &&
5135
+ isIdentifierNode(declaration.parent.parent.callee.property) &&
5136
+ declaration.parent.parent.callee.property.name === 'then' &&
5137
+ isImportExpressionNode(declaration.parent.parent.callee.object)) {
5138
+ declaration.parent.parent.callee.object.includePath(path);
5139
+ }
5106
5140
  }
5107
5141
  // We need to make sure we include the correct path of the init
5108
5142
  if (path.length > 0) {
@@ -7493,7 +7527,21 @@ class MemberExpression extends NodeBase {
7493
7527
  this.variable.includeCallArguments(interaction, context);
7494
7528
  }
7495
7529
  else {
7496
- includeInteraction(interaction, context);
7530
+ if (isImportExpressionNode(this.object) ||
7531
+ /**
7532
+ * const c = await import('foo')
7533
+ * c.foo();
7534
+ */
7535
+ (this.object.variable &&
7536
+ !this.object.variable.isReassigned &&
7537
+ this.object.variable instanceof LocalVariable &&
7538
+ isAwaitExpressionNode(this.object.variable.init) &&
7539
+ isImportExpressionNode(this.object.variable.init.argument))) {
7540
+ includeInteractionWithoutThis(interaction, context);
7541
+ }
7542
+ else {
7543
+ includeInteraction(interaction, context);
7544
+ }
7497
7545
  }
7498
7546
  }
7499
7547
  includeDestructuredIfNecessary(context, destructuredInitPath, init) {
@@ -8424,7 +8472,7 @@ function amd(magicString, { accessedGlobals, dependencies, exports, hasDefaultEx
8424
8472
  const deps = dependencies.map(m => `'${updateExtensionForRelativeAmdId(m.importPath, amd.forceJsExtensionForImports)}'`);
8425
8473
  const parameters = dependencies.map(m => m.name);
8426
8474
  const { n, getNonArrowFunctionIntro, _ } = snippets;
8427
- if (namedExportsMode && hasExports) {
8475
+ if (hasExports && (namedExportsMode || exports[0]?.local === 'exports.default')) {
8428
8476
  parameters.unshift(`exports`);
8429
8477
  deps.unshift(`'exports'`);
8430
8478
  }
@@ -8683,7 +8731,7 @@ function iife(magicString, { accessedGlobals, dependencies, exports, hasDefaultE
8683
8731
  if (hasExports && !name) {
8684
8732
  log(LOGLEVEL_WARN, logMissingNameOptionForIifeExport());
8685
8733
  }
8686
- if (namedExportsMode && hasExports) {
8734
+ if (hasExports && (namedExportsMode || exports[0]?.local === 'exports.default')) {
8687
8735
  if (extend) {
8688
8736
  deps.unshift(`this${keypath(name, getPropertyAccess)}${_}=${_}this${keypath(name, getPropertyAccess)}${_}||${_}{}`);
8689
8737
  parameters.unshift('exports');
@@ -8902,7 +8950,8 @@ function umd(magicString, { accessedGlobals, dependencies, exports, hasDefaultEx
8902
8950
  const trimmedImports = trimEmptyImports(dependencies);
8903
8951
  const globalDeps = trimmedImports.map(module => globalProperty(module.globalName, globalVariable, getPropertyAccess));
8904
8952
  const factoryParameters = trimmedImports.map(m => m.name);
8905
- if (namedExportsMode && (hasExports || noConflict)) {
8953
+ if ((hasExports || noConflict) &&
8954
+ (namedExportsMode || (hasExports && exports[0]?.local === 'exports.default'))) {
8906
8955
  amdDeps.unshift(`'exports'`);
8907
8956
  cjsDeps.unshift(`exports`);
8908
8957
  globalDeps.unshift(assignToDeepVariable(name, globalVariable, globals, `${extend ? `${globalProperty(name, globalVariable, getPropertyAccess)}${_}||${_}` : ''}{}`, snippets, log));
@@ -11658,44 +11707,38 @@ class AssignmentPattern extends NodeBase {
11658
11707
  }
11659
11708
 
11660
11709
  class AwaitExpression extends NodeBase {
11661
- get isTopLevelAwait() {
11662
- return isFlagSet(this.flags, 134217728 /* Flag.isTopLevelAwait */);
11663
- }
11664
- set isTopLevelAwait(value) {
11665
- this.flags = setFlag(this.flags, 134217728 /* Flag.isTopLevelAwait */, value);
11666
- }
11667
11710
  hasEffects() {
11668
11711
  if (!this.deoptimized)
11669
11712
  this.applyDeoptimizations();
11670
11713
  return true;
11671
11714
  }
11715
+ initialise() {
11716
+ super.initialise();
11717
+ let parent = this.parent;
11718
+ do {
11719
+ if (parent instanceof FunctionNode || parent instanceof ArrowFunctionExpression)
11720
+ return;
11721
+ } while ((parent = parent.parent));
11722
+ this.scope.context.usesTopLevelAwait = true;
11723
+ }
11672
11724
  include(context, includeChildrenRecursively) {
11673
11725
  if (!this.included)
11674
11726
  this.includeNode(context);
11675
- this.argument.include({ ...context, withinTopLevelAwait: this.isTopLevelAwait }, includeChildrenRecursively);
11727
+ this.argument.include(context, includeChildrenRecursively);
11676
11728
  }
11677
11729
  includeNode(context) {
11678
11730
  this.included = true;
11679
11731
  if (!this.deoptimized)
11680
11732
  this.applyDeoptimizations();
11681
- checkTopLevelAwait: {
11682
- let parent = this.parent;
11683
- do {
11684
- if (parent instanceof FunctionNode || parent instanceof ArrowFunctionExpression)
11685
- break checkTopLevelAwait;
11686
- } while ((parent = parent.parent));
11687
- this.scope.context.usesTopLevelAwait = true;
11688
- this.isTopLevelAwait = true;
11689
- }
11690
11733
  // Thenables need to be included
11691
- this.argument.includePath(THEN_PATH, { ...context, withinTopLevelAwait: this.isTopLevelAwait });
11734
+ this.argument.includePath(THEN_PATH, context);
11692
11735
  }
11693
11736
  includePath(path, context) {
11694
11737
  if (!this.deoptimized)
11695
11738
  this.applyDeoptimizations();
11696
11739
  if (!this.included)
11697
11740
  this.includeNode(context);
11698
- this.argument.includePath(path, { ...context, withinTopLevelAwait: this.isTopLevelAwait });
11741
+ this.argument.includePath(path, context);
11699
11742
  }
11700
11743
  }
11701
11744
  const THEN_PATH = ['then'];
@@ -11920,10 +11963,10 @@ class CallExpressionBase extends NodeBase {
11920
11963
 
11921
11964
  class CallExpression extends CallExpressionBase {
11922
11965
  get hasCheckedForWarnings() {
11923
- return isFlagSet(this.flags, 536870912 /* Flag.checkedForWarnings */);
11966
+ return isFlagSet(this.flags, 268435456 /* Flag.checkedForWarnings */);
11924
11967
  }
11925
11968
  set hasCheckedForWarnings(value) {
11926
- this.flags = setFlag(this.flags, 536870912 /* Flag.checkedForWarnings */, value);
11969
+ this.flags = setFlag(this.flags, 268435456 /* Flag.checkedForWarnings */, value);
11927
11970
  }
11928
11971
  get optional() {
11929
11972
  return isFlagSet(this.flags, 128 /* Flag.optional */);
@@ -12929,10 +12972,10 @@ class ImportExpression extends NodeBase {
12929
12972
  this.resolutionString = null;
12930
12973
  }
12931
12974
  get withinTopLevelAwait() {
12932
- return isFlagSet(this.flags, 268435456 /* Flag.withinTopLevelAwait */);
12975
+ return isFlagSet(this.flags, 134217728 /* Flag.withinTopLevelAwait */);
12933
12976
  }
12934
12977
  set withinTopLevelAwait(value) {
12935
- this.flags = setFlag(this.flags, 268435456 /* Flag.withinTopLevelAwait */, value);
12978
+ this.flags = setFlag(this.flags, 134217728 /* Flag.withinTopLevelAwait */, value);
12936
12979
  }
12937
12980
  // Do not bind attributes
12938
12981
  bind() {
@@ -12943,8 +12986,7 @@ class ImportExpression extends NodeBase {
12943
12986
  *
12944
12987
  * 1. `const { foo } = await import('bar')`.
12945
12988
  * 2. `(await import('bar')).foo`
12946
- * 3. `import('bar').then((m) => m.foo)`
12947
- * 4. `import('bar').then(({ foo }) => {})`
12989
+ * 3. `import('bar').then(({ foo }) => {})`
12948
12990
  *
12949
12991
  * Returns empty array if it's side-effect only import.
12950
12992
  * Returns undefined if it's not fully deterministic.
@@ -13008,30 +13050,11 @@ class ImportExpression extends NodeBase {
13008
13050
  if (thenCallback.params.length === 0) {
13009
13051
  return EMPTY_ARRAY;
13010
13052
  }
13011
- if (thenCallback.params.length === 1) {
13012
- // Promises .then() can only have one argument so only look at first one
13013
- const declaration = thenCallback.params[0];
13014
- // Case 3: import('bar').then(m => m.foo)
13015
- if (declaration instanceof Identifier) {
13016
- const starName = declaration.name;
13017
- const memberExpression = thenCallback.body;
13018
- if (!(memberExpression instanceof MemberExpression) ||
13019
- memberExpression.computed ||
13020
- !(memberExpression.property instanceof Identifier)) {
13021
- return;
13022
- }
13023
- const returnVariable = memberExpression.object;
13024
- if (!(returnVariable instanceof Identifier) || returnVariable.name !== starName) {
13025
- return;
13026
- }
13027
- return [memberExpression.property.name];
13028
- }
13029
- // Case 4: import('bar').then(({ foo }) => {})
13030
- if (declaration instanceof ObjectPattern) {
13031
- return getDeterministicObjectDestructure(declaration);
13032
- }
13053
+ const declaration = thenCallback.params[0];
13054
+ if (thenCallback.params.length === 1 && declaration instanceof ObjectPattern) {
13055
+ return getDeterministicObjectDestructure(declaration);
13033
13056
  }
13034
- return;
13057
+ return this.hasUnknownAccessedKey ? undefined : [...this.accessedPropKey];
13035
13058
  }
13036
13059
  }
13037
13060
  hasEffects() {
@@ -13039,18 +13062,17 @@ class ImportExpression extends NodeBase {
13039
13062
  }
13040
13063
  include(context, includeChildrenRecursively) {
13041
13064
  if (!this.included)
13042
- this.includeNode(context);
13065
+ this.includeNode();
13043
13066
  this.source.include(context, includeChildrenRecursively);
13044
13067
  }
13045
- includeNode(context) {
13068
+ includeNode() {
13046
13069
  this.included = true;
13047
- this.withinTopLevelAwait = context.withinTopLevelAwait;
13048
13070
  this.scope.context.includeDynamicImport(this);
13049
13071
  this.scope.addAccessedDynamicImport(this);
13050
13072
  }
13051
- includePath(path, context) {
13073
+ includePath(path) {
13052
13074
  if (!this.included)
13053
- this.includeNode(context);
13075
+ this.includeNode();
13054
13076
  // Technically, this is not correct as dynamic imports return a Promise.
13055
13077
  if (this.hasUnknownAccessedKey)
13056
13078
  return;
@@ -13066,6 +13088,22 @@ class ImportExpression extends NodeBase {
13066
13088
  initialise() {
13067
13089
  super.initialise();
13068
13090
  this.scope.context.addDynamicImport(this);
13091
+ let parent = this.parent;
13092
+ let withinAwaitExpression = false;
13093
+ let withinTopLevelAwait = false;
13094
+ do {
13095
+ if (withinAwaitExpression &&
13096
+ (parent instanceof FunctionNode || parent instanceof ArrowFunctionExpression)) {
13097
+ withinTopLevelAwait = false;
13098
+ }
13099
+ if (parent instanceof AwaitExpression) {
13100
+ withinAwaitExpression = true;
13101
+ withinTopLevelAwait = true;
13102
+ }
13103
+ } while ((parent = parent.parent));
13104
+ if (withinAwaitExpression && withinTopLevelAwait) {
13105
+ this.withinTopLevelAwait = true;
13106
+ }
13069
13107
  }
13070
13108
  parseNode(esTreeNode) {
13071
13109
  this.sourceAstNode = esTreeNode.source;
@@ -14696,10 +14734,10 @@ SwitchStatement.prototype.applyDeoptimizations = doNotDeoptimize;
14696
14734
 
14697
14735
  class TaggedTemplateExpression extends CallExpressionBase {
14698
14736
  get hasCheckedForWarnings() {
14699
- return isFlagSet(this.flags, 536870912 /* Flag.checkedForWarnings */);
14737
+ return isFlagSet(this.flags, 268435456 /* Flag.checkedForWarnings */);
14700
14738
  }
14701
14739
  set hasCheckedForWarnings(value) {
14702
- this.flags = setFlag(this.flags, 536870912 /* Flag.checkedForWarnings */, value);
14740
+ this.flags = setFlag(this.flags, 268435456 /* Flag.checkedForWarnings */, value);
14703
14741
  }
14704
14742
  bind() {
14705
14743
  super.bind();
@@ -19770,24 +19808,32 @@ function analyseModuleExecution(entryModules) {
19770
19808
  const dynamicImports = new Set();
19771
19809
  const parents = new Map();
19772
19810
  const orderedModules = [];
19811
+ const handleSyncLoadedModule = (module, parent) => {
19812
+ if (parents.has(module)) {
19813
+ if (!analysedModules.has(module)) {
19814
+ cyclePaths.push(getCyclePath(module, parent, parents));
19815
+ }
19816
+ return;
19817
+ }
19818
+ parents.set(module, parent);
19819
+ analyseModule(module);
19820
+ };
19773
19821
  const analyseModule = (module) => {
19774
19822
  if (module instanceof Module) {
19775
19823
  for (const dependency of module.dependencies) {
19776
- if (parents.has(dependency)) {
19777
- if (!analysedModules.has(dependency)) {
19778
- cyclePaths.push(getCyclePath(dependency, module, parents));
19779
- }
19780
- continue;
19781
- }
19782
- parents.set(dependency, module);
19783
- analyseModule(dependency);
19824
+ handleSyncLoadedModule(dependency, module);
19784
19825
  }
19785
19826
  for (const dependency of module.implicitlyLoadedBefore) {
19786
19827
  dynamicImports.add(dependency);
19787
19828
  }
19788
- for (const { resolution } of module.dynamicImports) {
19829
+ for (const { resolution, node } of module.dynamicImports) {
19789
19830
  if (resolution instanceof Module) {
19790
- dynamicImports.add(resolution);
19831
+ if (node.withinTopLevelAwait) {
19832
+ handleSyncLoadedModule(resolution, module);
19833
+ }
19834
+ else {
19835
+ dynamicImports.add(resolution);
19836
+ }
19791
19837
  }
19792
19838
  }
19793
19839
  orderedModules.push(module);
@@ -23635,12 +23681,41 @@ function watch(configs) {
23635
23681
  });
23636
23682
  return emitter;
23637
23683
  }
23684
+ function withTrailingSlash(path) {
23685
+ if (path[path.length - 1] !== '/') {
23686
+ return `${path}/`;
23687
+ }
23688
+ return path;
23689
+ }
23690
+ function checkWatchConfig(config) {
23691
+ for (const item of config) {
23692
+ if (item.input && item.output) {
23693
+ const input = typeof item.input === 'string' ? ensureArray(item.input) : item.input;
23694
+ const output = ensureArray(item.output);
23695
+ for (const index in input) {
23696
+ const inputPath = input[index];
23697
+ const subPath = output.find(o => {
23698
+ if (!o.dir || typeof inputPath !== 'string') {
23699
+ return false;
23700
+ }
23701
+ const _outPath = withTrailingSlash(o.dir);
23702
+ const _inputPath = withTrailingSlash(inputPath);
23703
+ return _inputPath.startsWith(_outPath);
23704
+ });
23705
+ if (subPath) {
23706
+ error(logInvalidOption('watch', URL_WATCH, `the input "${inputPath}" is a subpath of the output "${subPath.dir}"`));
23707
+ }
23708
+ }
23709
+ }
23710
+ }
23711
+ }
23638
23712
  async function watchInternal(configs, emitter) {
23639
23713
  const optionsList = await Promise.all(ensureArray(configs).map(config => mergeOptions(config, true)));
23640
23714
  const watchOptionsList = optionsList.filter(config => config.watch !== false);
23641
23715
  if (watchOptionsList.length === 0) {
23642
23716
  return error(logInvalidOption('watch', URL_WATCH, 'there must be at least one config where "watch" is not set to "false"'));
23643
23717
  }
23718
+ checkWatchConfig(watchOptionsList);
23644
23719
  await loadFsEvents();
23645
23720
  const { Watcher } = await import('./watch.js');
23646
23721
  new Watcher(watchOptionsList, emitter);
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v4.40.1
4
- Mon, 28 Apr 2025 04:34:51 GMT - commit 1e6c40f49c428b7657fe3b9a2026f705acd39da1
3
+ Rollup.js v4.41.0
4
+ Sun, 18 May 2025 05:33:01 GMT - commit 0928185cd544907dab472754634ddf988452aae6
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -13,13 +13,16 @@ import { resolve, dirname, basename, extname } from 'node:path';
13
13
  // This file is generated by scripts/generate-node-types.js.
14
14
  // Do not edit this file directly.
15
15
  const ArrowFunctionExpression = 'ArrowFunctionExpression';
16
+ const AwaitExpression = 'AwaitExpression';
16
17
  const BlockStatement = 'BlockStatement';
17
18
  const CallExpression = 'CallExpression';
18
19
  const CatchClause = 'CatchClause';
19
20
  const ExportDefaultDeclaration = 'ExportDefaultDeclaration';
20
21
  const ExpressionStatement = 'ExpressionStatement';
21
22
  const Identifier = 'Identifier';
23
+ const ImportExpression = 'ImportExpression';
22
24
  const Literal = 'Literal';
25
+ const MemberExpression = 'MemberExpression';
23
26
  const ObjectExpression = 'ObjectExpression';
24
27
  const PanicError = 'PanicError';
25
28
  const ParseError = 'ParseError';
@@ -2070,4 +2073,4 @@ function getAstBuffer(astBuffer) {
2070
2073
  const parseAst = (input, { allowReturnOutsideFunction = false, jsx = false } = {}) => convertProgram(getAstBuffer(parse(input, allowReturnOutsideFunction, jsx)));
2071
2074
  const parseAstAsync = async (input, { allowReturnOutsideFunction = false, jsx = false, signal } = {}) => convertProgram(getAstBuffer(await parseAsync(input, allowReturnOutsideFunction, jsx, signal)));
2072
2075
 
2073
- export { ANNOTATION_KEY, ArrowFunctionExpression, BLANK, BlockStatement, CallExpression, CatchClause, EMPTY_ARRAY, EMPTY_OBJECT, EMPTY_SET, ExportDefaultDeclaration, ExpressionStatement, FIXED_STRINGS, INVALID_ANNOTATION_KEY, Identifier, LOGLEVEL_DEBUG, LOGLEVEL_ERROR, LOGLEVEL_INFO, LOGLEVEL_WARN, Literal, ObjectExpression, Program, Property, RestElement, ReturnStatement, StaticBlock, TemplateLiteral, URL_GENERATEBUNDLE, URL_JSX, URL_OUTPUT_AMD_BASEPATH, URL_OUTPUT_AMD_ID, URL_OUTPUT_DIR, URL_OUTPUT_EXTERNALIMPORTATTRIBUTES, URL_OUTPUT_FORMAT, URL_OUTPUT_GENERATEDCODE, URL_OUTPUT_INLINEDYNAMICIMPORTS, URL_OUTPUT_INTEROP, URL_OUTPUT_MANUALCHUNKS, URL_OUTPUT_SOURCEMAPBASEURL, URL_OUTPUT_SOURCEMAPFILE, URL_PRESERVEENTRYSIGNATURES, URL_TREESHAKE, URL_TREESHAKE_MODULESIDEEFFECTS, URL_WATCH, VariableDeclarator, addTrailingSlashIfMissed, augmentCodeLocation, augmentLogMessage, convertAnnotations, convertNode, error, getAliasName, getAstBuffer, getImportPath, getRollupError, isAbsolute, isPathFragment, isRelative, isValidUrl, locate, logAddonNotGenerated, logAlreadyClosed, logAmbiguousExternalNamespaces, logAnonymousPluginCache, logAssetNotFinalisedForFileName, logAssetReferenceIdNotFoundForSetSource, logAssetSourceAlreadySet, logBadLoader, logCannotAssignModuleToChunk, logCannotCallNamespace, logCannotEmitFromOptionsHook, logChunkInvalid, logChunkNotGeneratedForFileName, logCircularDependency, logCircularReexport, logConflictingSourcemapSources, logConstVariableReassignError, logCyclicCrossChunkReexport, logDuplicateArgumentNameError, logDuplicateExportError, logDuplicatePluginName, logEmptyChunk, logEntryCannotBeExternal, logEval, logExternalModulesCannotBeIncludedInManualChunks, logExternalModulesCannotBeTransformedToModules, logExternalSyntheticExports, logFailedValidation, logFileNameConflict, logFileReferenceIdNotFoundForFilename, logFirstSideEffect, logIllegalIdentifierAsName, logIllegalImportReassignment, logImplicitDependantCannotBeExternal, logImplicitDependantIsNotIncluded, logImportAttributeIsInvalid, logImportOptionsAreInvalid, logIncompatibleExportOptionValue, logInconsistentImportAttributes, logInputHookInOutputPlugin, logInternalIdCannotBeExternal, logInvalidAddonPluginHook, logInvalidAnnotation, logInvalidExportOptionValue, logInvalidFormatForTopLevelAwait, logInvalidFunctionPluginHook, logInvalidLogPosition, logInvalidOption, logInvalidRollupPhaseForChunkEmission, logInvalidSetAssetSourceCall, logInvalidSourcemapForError, logLevelPriority, logMissingEntryExport, logMissingExport, logMissingFileOrDirOption, logMissingGlobalName, logMissingJsxExport, logMissingNameOptionForIifeExport, logMissingNameOptionForUmdExport, logMissingNodeBuiltins, logMixedExport, logModuleLevelDirective, logModuleParseError, logNamespaceConflict, logNoAssetSourceSet, logNoTransformMapOrAstWithoutCode, logOptimizeChunkStatus, logParseError, logPluginError, logRedeclarationError, logReservedNamespace, logShimmedExport, logSourcemapBroken, logSyntheticNamedExportsNeedNamespaceExport, logThisIsUndefined, logUnexpectedNamedImport, logUnexpectedNamespaceReexport, logUnknownOption, logUnresolvedEntry, logUnresolvedImplicitDependant, logUnresolvedImport, logUnresolvedImportTreatedAsExternal, logUnusedExternalImports, normalize, parseAst, parseAstAsync, printQuotedStringList, relative, relativeId, warnDeprecation };
2076
+ export { ANNOTATION_KEY, ArrowFunctionExpression, AwaitExpression, BLANK, BlockStatement, CallExpression, CatchClause, EMPTY_ARRAY, EMPTY_OBJECT, EMPTY_SET, ExportDefaultDeclaration, ExpressionStatement, FIXED_STRINGS, INVALID_ANNOTATION_KEY, Identifier, ImportExpression, LOGLEVEL_DEBUG, LOGLEVEL_ERROR, LOGLEVEL_INFO, LOGLEVEL_WARN, Literal, MemberExpression, ObjectExpression, Program, Property, RestElement, ReturnStatement, StaticBlock, TemplateLiteral, URL_GENERATEBUNDLE, URL_JSX, URL_OUTPUT_AMD_BASEPATH, URL_OUTPUT_AMD_ID, URL_OUTPUT_DIR, URL_OUTPUT_EXTERNALIMPORTATTRIBUTES, URL_OUTPUT_FORMAT, URL_OUTPUT_GENERATEDCODE, URL_OUTPUT_INLINEDYNAMICIMPORTS, URL_OUTPUT_INTEROP, URL_OUTPUT_MANUALCHUNKS, URL_OUTPUT_SOURCEMAPBASEURL, URL_OUTPUT_SOURCEMAPFILE, URL_PRESERVEENTRYSIGNATURES, URL_TREESHAKE, URL_TREESHAKE_MODULESIDEEFFECTS, URL_WATCH, VariableDeclarator, addTrailingSlashIfMissed, augmentCodeLocation, augmentLogMessage, convertAnnotations, convertNode, error, getAliasName, getAstBuffer, getImportPath, getRollupError, isAbsolute, isPathFragment, isRelative, isValidUrl, locate, logAddonNotGenerated, logAlreadyClosed, logAmbiguousExternalNamespaces, logAnonymousPluginCache, logAssetNotFinalisedForFileName, logAssetReferenceIdNotFoundForSetSource, logAssetSourceAlreadySet, logBadLoader, logCannotAssignModuleToChunk, logCannotCallNamespace, logCannotEmitFromOptionsHook, logChunkInvalid, logChunkNotGeneratedForFileName, logCircularDependency, logCircularReexport, logConflictingSourcemapSources, logConstVariableReassignError, logCyclicCrossChunkReexport, logDuplicateArgumentNameError, logDuplicateExportError, logDuplicatePluginName, logEmptyChunk, logEntryCannotBeExternal, logEval, logExternalModulesCannotBeIncludedInManualChunks, logExternalModulesCannotBeTransformedToModules, logExternalSyntheticExports, logFailedValidation, logFileNameConflict, logFileReferenceIdNotFoundForFilename, logFirstSideEffect, logIllegalIdentifierAsName, logIllegalImportReassignment, logImplicitDependantCannotBeExternal, logImplicitDependantIsNotIncluded, logImportAttributeIsInvalid, logImportOptionsAreInvalid, logIncompatibleExportOptionValue, logInconsistentImportAttributes, logInputHookInOutputPlugin, logInternalIdCannotBeExternal, logInvalidAddonPluginHook, logInvalidAnnotation, logInvalidExportOptionValue, logInvalidFormatForTopLevelAwait, logInvalidFunctionPluginHook, logInvalidLogPosition, logInvalidOption, logInvalidRollupPhaseForChunkEmission, logInvalidSetAssetSourceCall, logInvalidSourcemapForError, logLevelPriority, logMissingEntryExport, logMissingExport, logMissingFileOrDirOption, logMissingGlobalName, logMissingJsxExport, logMissingNameOptionForIifeExport, logMissingNameOptionForUmdExport, logMissingNodeBuiltins, logMixedExport, logModuleLevelDirective, logModuleParseError, logNamespaceConflict, logNoAssetSourceSet, logNoTransformMapOrAstWithoutCode, logOptimizeChunkStatus, logParseError, logPluginError, logRedeclarationError, logReservedNamespace, logShimmedExport, logSourcemapBroken, logSyntheticNamedExportsNeedNamespaceExport, logThisIsUndefined, logUnexpectedNamedImport, logUnexpectedNamespaceReexport, logUnknownOption, logUnresolvedEntry, logUnresolvedImplicitDependant, logUnresolvedImport, logUnresolvedImportTreatedAsExternal, logUnusedExternalImports, normalize, parseAst, parseAstAsync, printQuotedStringList, relative, relativeId, warnDeprecation };
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v4.40.1
4
- Mon, 28 Apr 2025 04:34:51 GMT - commit 1e6c40f49c428b7657fe3b9a2026f705acd39da1
3
+ Rollup.js v4.41.0
4
+ Sun, 18 May 2025 05:33:01 GMT - commit 0928185cd544907dab472754634ddf988452aae6
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v4.40.1
4
- Mon, 28 Apr 2025 04:34:51 GMT - commit 1e6c40f49c428b7657fe3b9a2026f705acd39da1
3
+ Rollup.js v4.41.0
4
+ Sun, 18 May 2025 05:33:01 GMT - commit 0928185cd544907dab472754634ddf988452aae6
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v4.40.1
4
- Mon, 28 Apr 2025 04:34:51 GMT - commit 1e6c40f49c428b7657fe3b9a2026f705acd39da1
3
+ Rollup.js v4.41.0
4
+ Sun, 18 May 2025 05:33:01 GMT - commit 0928185cd544907dab472754634ddf988452aae6
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
package/dist/parseAst.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v4.40.1
4
- Mon, 28 Apr 2025 04:34:51 GMT - commit 1e6c40f49c428b7657fe3b9a2026f705acd39da1
3
+ Rollup.js v4.41.0
4
+ Sun, 18 May 2025 05:33:01 GMT - commit 0928185cd544907dab472754634ddf988452aae6
5
5
 
6
6
  https://github.com/rollup/rollup
7
7