rollup 3.17.3-1 → 3.18.0-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
@@ -2,8 +2,8 @@
2
2
 
3
3
  /*
4
4
  @license
5
- Rollup.js v3.17.3-1
6
- Thu, 23 Feb 2023 18:26:12 GMT - commit a44e087fa8b10fcbee144d5d296611c72c4f489c
5
+ Rollup.js v3.18.0-0
6
+ Mon, 27 Feb 2023 06:19:25 GMT - commit a4bb325dbdad691e53bd6e969816d43c41d9e37e
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.17.3-1
4
- Thu, 23 Feb 2023 18:26:12 GMT - commit a44e087fa8b10fcbee144d5d296611c72c4f489c
3
+ Rollup.js v3.18.0-0
4
+ Mon, 27 Feb 2023 06:19:25 GMT - commit a4bb325dbdad691e53bd6e969816d43c41d9e37e
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v3.17.3-1
4
- Thu, 23 Feb 2023 18:26:12 GMT - commit a44e087fa8b10fcbee144d5d296611c72c4f489c
3
+ Rollup.js v3.18.0-0
4
+ Mon, 27 Feb 2023 06:19:25 GMT - commit a4bb325dbdad691e53bd6e969816d43c41d9e37e
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -16,7 +16,7 @@ import { lstat, realpath, readdir, readFile, mkdir, writeFile } from 'node:fs/pr
16
16
  import { EventEmitter } from 'node:events';
17
17
  import * as tty from 'tty';
18
18
 
19
- var version$1 = "3.17.3-1";
19
+ var version$1 = "3.18.0-0";
20
20
 
21
21
  const comma = ','.charCodeAt(0);
22
22
  const semicolon = ';'.charCodeAt(0);
@@ -2005,8 +2005,14 @@ function spaces(index) {
2005
2005
  function tabsToSpaces(value) {
2006
2006
  return value.replace(/^\t+/, match => match.split('\t').join(' '));
2007
2007
  }
2008
+ const LINE_TRUNCATE_LENGTH = 120;
2009
+ const MIN_CHARACTERS_SHOWN_AFTER_LOCATION = 10;
2010
+ const ELLIPSIS = '...';
2008
2011
  function getCodeFrame(source, line, column) {
2009
2012
  let lines = source.split('\n');
2013
+ const maxLineLength = Math.max(tabsToSpaces(lines[line - 1].slice(0, column)).length +
2014
+ MIN_CHARACTERS_SHOWN_AFTER_LOCATION +
2015
+ ELLIPSIS.length, LINE_TRUNCATE_LENGTH);
2010
2016
  const frameStart = Math.max(0, line - 3);
2011
2017
  let frameEnd = Math.min(line + 2, lines.length);
2012
2018
  lines = lines.slice(frameStart, frameEnd);
@@ -2021,11 +2027,15 @@ function getCodeFrame(source, line, column) {
2021
2027
  let lineNumber = String(index + frameStart + 1);
2022
2028
  while (lineNumber.length < digits)
2023
2029
  lineNumber = ` ${lineNumber}`;
2030
+ let displayedLine = tabsToSpaces(sourceLine);
2031
+ if (displayedLine.length > maxLineLength) {
2032
+ displayedLine = `${displayedLine.slice(0, maxLineLength - ELLIPSIS.length)}${ELLIPSIS}`;
2033
+ }
2024
2034
  if (isErrorLine) {
2025
2035
  const indicator = spaces(digits + 2 + tabsToSpaces(sourceLine.slice(0, column)).length) + '^';
2026
- return `${lineNumber}: ${tabsToSpaces(sourceLine)}\n${indicator}`;
2036
+ return `${lineNumber}: ${displayedLine}\n${indicator}`;
2027
2037
  }
2028
- return `${lineNumber}: ${tabsToSpaces(sourceLine)}`;
2038
+ return `${lineNumber}: ${displayedLine}`;
2029
2039
  })
2030
2040
  .join('\n');
2031
2041
  }
@@ -5851,9 +5861,6 @@ class NodeBase extends ExpressionEntity {
5851
5861
  this.context.requestTreeshakingPass();
5852
5862
  }
5853
5863
  }
5854
- function logNode(node) {
5855
- return node.context.code.slice(node.start, node.end);
5856
- }
5857
5864
 
5858
5865
  class SpreadElement extends NodeBase {
5859
5866
  deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker) {
@@ -11286,6 +11293,8 @@ const getGenericImportMetaMechanism = (getUrl) => (property, { chunkId }) => {
11286
11293
  ? urlMechanism
11287
11294
  : 'undefined';
11288
11295
  };
11296
+ const getFileUrlFromFullPath = (path) => `require('u' + 'rl').pathToFileURL(${path}).href`;
11297
+ const getFileUrlFromRelativePath = (path) => getFileUrlFromFullPath(`__dirname + '/${path}'`);
11289
11298
  const getUrlFromDocument = (chunkId, umd = false) => `${umd ? `typeof document === 'undefined' ? location.href : ` : ''}(document.currentScript && document.currentScript.src || new URL('${escapeId(chunkId)}', document.baseURI).href)`;
11290
11299
  const relativeUrlMechanisms = {
11291
11300
  amd: relativePath => {
@@ -11293,18 +11302,18 @@ const relativeUrlMechanisms = {
11293
11302
  relativePath = './' + relativePath;
11294
11303
  return getResolveUrl(`require.toUrl('${relativePath}'), document.baseURI`);
11295
11304
  },
11296
- cjs: relativePath => `(typeof document === 'undefined' ? ${getResolveUrl(`'file:' + __dirname + '/${relativePath}'`, `(require('u' + 'rl').URL)`)} : ${getRelativeUrlFromDocument(relativePath)})`,
11305
+ cjs: relativePath => `(typeof document === 'undefined' ? ${getFileUrlFromRelativePath(relativePath)} : ${getRelativeUrlFromDocument(relativePath)})`,
11297
11306
  es: relativePath => getResolveUrl(`'${relativePath}', import.meta.url`),
11298
11307
  iife: relativePath => getRelativeUrlFromDocument(relativePath),
11299
11308
  system: relativePath => getResolveUrl(`'${relativePath}', module.meta.url`),
11300
- umd: relativePath => `(typeof document === 'undefined' && typeof location === 'undefined' ? ${getResolveUrl(`'file:' + __dirname + '/${relativePath}'`, `(require('u' + 'rl').URL)`)} : ${getRelativeUrlFromDocument(relativePath, true)})`
11309
+ umd: relativePath => `(typeof document === 'undefined' && typeof location === 'undefined' ? ${getFileUrlFromRelativePath(relativePath)} : ${getRelativeUrlFromDocument(relativePath, true)})`
11301
11310
  };
11302
11311
  const importMetaMechanisms = {
11303
11312
  amd: getGenericImportMetaMechanism(() => getResolveUrl(`module.uri, document.baseURI`)),
11304
- cjs: getGenericImportMetaMechanism(chunkId => `(typeof document === 'undefined' ? ${getResolveUrl(`'file:' + __filename`, `(require('u' + 'rl').URL)`)} : ${getUrlFromDocument(chunkId)})`),
11313
+ cjs: getGenericImportMetaMechanism(chunkId => `(typeof document === 'undefined' ? ${getFileUrlFromFullPath('__filename')} : ${getUrlFromDocument(chunkId)})`),
11305
11314
  iife: getGenericImportMetaMechanism(chunkId => getUrlFromDocument(chunkId)),
11306
11315
  system: (property, { snippets: { getPropertyAccess } }) => property === null ? `module.meta` : `module.meta${getPropertyAccess(property)}`,
11307
- umd: getGenericImportMetaMechanism(chunkId => `(typeof document === 'undefined' && typeof location === 'undefined' ? ${getResolveUrl(`'file:' + __filename`, `(require('u' + 'rl').URL)`)} : ${getUrlFromDocument(chunkId, true)})`)
11316
+ umd: getGenericImportMetaMechanism(chunkId => `(typeof document === 'undefined' && typeof location === 'undefined' ? ${getFileUrlFromFullPath('__filename')} : ${getUrlFromDocument(chunkId, true)})`)
11308
11317
  };
11309
11318
 
11310
11319
  class NewExpression extends NodeBase {
@@ -11439,6 +11448,29 @@ class ObjectExpression extends NodeBase {
11439
11448
  class PrivateIdentifier extends NodeBase {
11440
11449
  }
11441
11450
 
11451
+ function getOriginalLocation(sourcemapChain, location) {
11452
+ const filteredSourcemapChain = sourcemapChain.filter((sourcemap) => !!sourcemap.mappings);
11453
+ traceSourcemap: while (filteredSourcemapChain.length > 0) {
11454
+ const sourcemap = filteredSourcemapChain.pop();
11455
+ const line = sourcemap.mappings[location.line - 1];
11456
+ if (line) {
11457
+ const filteredLine = line.filter((segment) => segment.length > 1);
11458
+ const lastSegment = filteredLine[filteredLine.length - 1];
11459
+ for (const segment of filteredLine) {
11460
+ if (segment[0] >= location.column || segment === lastSegment) {
11461
+ location = {
11462
+ column: segment[3],
11463
+ line: segment[2] + 1
11464
+ };
11465
+ continue traceSourcemap;
11466
+ }
11467
+ }
11468
+ }
11469
+ throw new Error("Can't resolve original location of error.");
11470
+ }
11471
+ return location;
11472
+ }
11473
+
11442
11474
  class Program extends NodeBase {
11443
11475
  constructor() {
11444
11476
  super(...arguments);
@@ -11453,17 +11485,21 @@ class Program extends NodeBase {
11453
11485
  hasEffects(context) {
11454
11486
  for (const node of this.body) {
11455
11487
  if (node.hasEffects(context)) {
11456
- if (!this.hasLoggedEffect) {
11488
+ if (this.context.options.experimentalLogSideEffects && !this.hasLoggedEffect) {
11457
11489
  this.hasLoggedEffect = true;
11458
- let effect = logNode(node);
11459
- let truncated = false;
11460
- if (effect.length > 150) {
11461
- truncated = true;
11462
- effect = effect.slice(0, 150) + '...';
11490
+ const { code, module } = this.context;
11491
+ const { line, column } = locate(code, node.start, { offsetLine: 1 });
11492
+ console.log(`First side effect in ${relativeId(module.id)} is at (${line}:${column})\n${getCodeFrame(code, line, column)}`);
11493
+ try {
11494
+ const { column: originalColumn, line: originalLine } = getOriginalLocation(module.sourcemapChain, { column, line });
11495
+ if (originalLine !== line) {
11496
+ console.log(`Original location is at (${originalLine}:${originalColumn})\n${getCodeFrame(module.originalCode, originalLine, originalColumn)}\n`);
11497
+ }
11463
11498
  }
11464
- console.log(`==> First side effect in ${relativeId(this.context.module.id)}${truncated ? ' (truncated)' : ''}:`);
11465
- console.log(effect);
11466
- console.log('<==\n');
11499
+ catch {
11500
+ /* ignored */
11501
+ }
11502
+ console.log();
11467
11503
  }
11468
11504
  return (this.hasCachedEffect = true);
11469
11505
  }
@@ -12777,29 +12813,6 @@ function getId(m) {
12777
12813
  return m.id;
12778
12814
  }
12779
12815
 
12780
- function getOriginalLocation(sourcemapChain, location) {
12781
- const filteredSourcemapChain = sourcemapChain.filter((sourcemap) => !!sourcemap.mappings);
12782
- traceSourcemap: while (filteredSourcemapChain.length > 0) {
12783
- const sourcemap = filteredSourcemapChain.pop();
12784
- const line = sourcemap.mappings[location.line - 1];
12785
- if (line) {
12786
- const filteredLine = line.filter((segment) => segment.length > 1);
12787
- const lastSegment = filteredLine[filteredLine.length - 1];
12788
- for (const segment of filteredLine) {
12789
- if (segment[0] >= location.column || segment === lastSegment) {
12790
- location = {
12791
- column: segment[3],
12792
- line: segment[2] + 1
12793
- };
12794
- continue traceSourcemap;
12795
- }
12796
- }
12797
- }
12798
- throw new Error("Can't resolve original location of error.");
12799
- }
12800
- return location;
12801
- }
12802
-
12803
12816
  function getAssertionsFromImportExpression(node) {
12804
12817
  const assertProperty = node.arguments?.[0]?.properties.find((property) => getPropertyKey(property) === 'assert')?.value;
12805
12818
  if (!assertProperty) {
@@ -16572,8 +16585,6 @@ function compareChunkSize({ size: sizeA }, { size: sizeB }) {
16572
16585
  return sizeA - sizeB;
16573
16586
  }
16574
16587
  function mergeChunks(chunkPartition, minChunkSize) {
16575
- console.log('---- Initial chunks');
16576
- printConsistencyCheck(chunkPartition);
16577
16588
  for (const allowArbitraryMerges of [false, true]) {
16578
16589
  for (const mergedChunk of chunkPartition.small) {
16579
16590
  let closestChunk = null;
@@ -16625,8 +16636,6 @@ function mergeChunks(chunkPartition, minChunkSize) {
16625
16636
  getChunksInPartition(closestChunk, minChunkSize, chunkPartition).add(closestChunk);
16626
16637
  }
16627
16638
  }
16628
- console.log('---- After run with arbitrary merges:', allowArbitraryMerges);
16629
- printConsistencyCheck(chunkPartition);
16630
16639
  }
16631
16640
  }
16632
16641
  // Merging will not produce cycles if none of the direct non-merged dependencies
@@ -16682,57 +16691,6 @@ function getChunkEntryDistance({ dependentEntries: sourceEntries }, { dependentE
16682
16691
  }
16683
16692
  return distance;
16684
16693
  }
16685
- function printConsistencyCheck(partition) {
16686
- const chunks = new Set([...partition.big, ...partition.small]);
16687
- console.log('Number of cycles:', getNumberOfCycles(chunks));
16688
- let missingDependencies = 0;
16689
- let missingDependentChunks = 0;
16690
- const seenModules = new Set();
16691
- for (const { modules, dependencies, dependentChunks } of chunks) {
16692
- for (const module of modules) {
16693
- if (seenModules.has(module)) {
16694
- console.log(`Module ${module.id} is duplicated between chunks.`);
16695
- }
16696
- seenModules.add(module);
16697
- }
16698
- for (const dependency of dependencies) {
16699
- if (!chunks.has(dependency)) {
16700
- missingDependencies++;
16701
- }
16702
- }
16703
- for (const dependency of dependentChunks) {
16704
- if (!chunks.has(dependency)) {
16705
- missingDependentChunks++;
16706
- }
16707
- }
16708
- }
16709
- console.log(`Missing\n dependencies: ${missingDependencies},\n missing dependent chunks: ${missingDependentChunks}\n`);
16710
- }
16711
- function getNumberOfCycles(chunks) {
16712
- const parents = new Set();
16713
- const analysedChunks = new Set();
16714
- let cycles = 0;
16715
- const analyseChunk = (chunk) => {
16716
- for (const dependency of chunk.dependencies) {
16717
- if (parents.has(dependency)) {
16718
- if (!analysedChunks.has(dependency)) {
16719
- cycles++;
16720
- }
16721
- continue;
16722
- }
16723
- parents.add(dependency);
16724
- analyseChunk(dependency);
16725
- }
16726
- analysedChunks.add(chunk);
16727
- };
16728
- for (const chunk of chunks) {
16729
- if (!parents.has(chunk)) {
16730
- parents.add(chunk);
16731
- analyseChunk(chunk);
16732
- }
16733
- }
16734
- return cycles;
16735
- }
16736
16694
 
16737
16695
  // ported from https://github.com/substack/node-commondir
16738
16696
  function commondir(files) {
@@ -24958,6 +24916,7 @@ async function normalizeInputOptions(config) {
24958
24916
  cache: getCache(config),
24959
24917
  context,
24960
24918
  experimentalCacheExpiry: config.experimentalCacheExpiry ?? 10,
24919
+ experimentalLogSideEffects: config.experimentalLogSideEffects || false,
24961
24920
  external: getIdMatcher(config.external),
24962
24921
  inlineDynamicImports: getInlineDynamicImports$1(config, onwarn, strictDeprecations),
24963
24922
  input: getInput(config),
@@ -25794,6 +25753,7 @@ async function mergeInputOptions(config, overrides, defaultOnWarnHandler) {
25794
25753
  cache: config.cache,
25795
25754
  context: getOption('context'),
25796
25755
  experimentalCacheExpiry: getOption('experimentalCacheExpiry'),
25756
+ experimentalLogSideEffects: getOption('experimentalLogSideEffects'),
25797
25757
  external: getExternal(config, overrides),
25798
25758
  inlineDynamicImports: getOption('inlineDynamicImports'),
25799
25759
  input: getOption('input') || [],
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v3.17.3-1
4
- Thu, 23 Feb 2023 18:26:12 GMT - commit a44e087fa8b10fcbee144d5d296611c72c4f489c
3
+ Rollup.js v3.18.0-0
4
+ Mon, 27 Feb 2023 06:19:25 GMT - commit a4bb325dbdad691e53bd6e969816d43c41d9e37e
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v3.17.3-1
4
- Thu, 23 Feb 2023 18:26:12 GMT - commit a44e087fa8b10fcbee144d5d296611c72c4f489c
3
+ Rollup.js v3.18.0-0
4
+ Mon, 27 Feb 2023 06:19:25 GMT - commit a4bb325dbdad691e53bd6e969816d43c41d9e37e
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
package/dist/rollup.d.ts CHANGED
@@ -523,6 +523,7 @@ export interface InputOptions {
523
523
  cache?: boolean | RollupCache;
524
524
  context?: string;
525
525
  experimentalCacheExpiry?: number;
526
+ experimentalLogSideEffects?: boolean;
526
527
  external?: ExternalOption;
527
528
  /** @deprecated Use the "inlineDynamicImports" output option instead. */
528
529
  inlineDynamicImports?: boolean;
@@ -557,6 +558,7 @@ export interface NormalizedInputOptions {
557
558
  cache: false | undefined | RollupCache;
558
559
  context: string;
559
560
  experimentalCacheExpiry: number;
561
+ experimentalLogSideEffects: boolean;
560
562
  external: IsExternal;
561
563
  /** @deprecated Use the "inlineDynamicImports" output option instead. */
562
564
  inlineDynamicImports: boolean | undefined;
package/dist/rollup.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v3.17.3-1
4
- Thu, 23 Feb 2023 18:26:12 GMT - commit a44e087fa8b10fcbee144d5d296611c72c4f489c
3
+ Rollup.js v3.18.0-0
4
+ Mon, 27 Feb 2023 06:19:25 GMT - commit a4bb325dbdad691e53bd6e969816d43c41d9e37e
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v3.17.3-1
4
- Thu, 23 Feb 2023 18:26:12 GMT - commit a44e087fa8b10fcbee144d5d296611c72c4f489c
3
+ Rollup.js v3.18.0-0
4
+ Mon, 27 Feb 2023 06:19:25 GMT - commit a4bb325dbdad691e53bd6e969816d43c41d9e37e
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v3.17.3-1
4
- Thu, 23 Feb 2023 18:26:12 GMT - commit a44e087fa8b10fcbee144d5d296611c72c4f489c
3
+ Rollup.js v3.18.0-0
4
+ Mon, 27 Feb 2023 06:19:25 GMT - commit a4bb325dbdad691e53bd6e969816d43c41d9e37e
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v3.17.3-1
4
- Thu, 23 Feb 2023 18:26:12 GMT - commit a44e087fa8b10fcbee144d5d296611c72c4f489c
3
+ Rollup.js v3.18.0-0
4
+ Mon, 27 Feb 2023 06:19:25 GMT - commit a4bb325dbdad691e53bd6e969816d43c41d9e37e
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v3.17.3-1
4
- Thu, 23 Feb 2023 18:26:12 GMT - commit a44e087fa8b10fcbee144d5d296611c72c4f489c
3
+ Rollup.js v3.18.0-0
4
+ Mon, 27 Feb 2023 06:19:25 GMT - commit a4bb325dbdad691e53bd6e969816d43c41d9e37e
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.17.3-1";
34
+ var version$1 = "3.18.0-0";
35
35
 
36
36
  function ensureArray$1(items) {
37
37
  if (Array.isArray(items)) {
@@ -142,8 +142,14 @@ function spaces(index) {
142
142
  function tabsToSpaces(value) {
143
143
  return value.replace(/^\t+/, match => match.split('\t').join(' '));
144
144
  }
145
+ const LINE_TRUNCATE_LENGTH = 120;
146
+ const MIN_CHARACTERS_SHOWN_AFTER_LOCATION = 10;
147
+ const ELLIPSIS = '...';
145
148
  function getCodeFrame(source, line, column) {
146
149
  let lines = source.split('\n');
150
+ const maxLineLength = Math.max(tabsToSpaces(lines[line - 1].slice(0, column)).length +
151
+ MIN_CHARACTERS_SHOWN_AFTER_LOCATION +
152
+ ELLIPSIS.length, LINE_TRUNCATE_LENGTH);
147
153
  const frameStart = Math.max(0, line - 3);
148
154
  let frameEnd = Math.min(line + 2, lines.length);
149
155
  lines = lines.slice(frameStart, frameEnd);
@@ -158,11 +164,15 @@ function getCodeFrame(source, line, column) {
158
164
  let lineNumber = String(index + frameStart + 1);
159
165
  while (lineNumber.length < digits)
160
166
  lineNumber = ` ${lineNumber}`;
167
+ let displayedLine = tabsToSpaces(sourceLine);
168
+ if (displayedLine.length > maxLineLength) {
169
+ displayedLine = `${displayedLine.slice(0, maxLineLength - ELLIPSIS.length)}${ELLIPSIS}`;
170
+ }
161
171
  if (isErrorLine) {
162
172
  const indicator = spaces(digits + 2 + tabsToSpaces(sourceLine.slice(0, column)).length) + '^';
163
- return `${lineNumber}: ${tabsToSpaces(sourceLine)}\n${indicator}`;
173
+ return `${lineNumber}: ${displayedLine}\n${indicator}`;
164
174
  }
165
- return `${lineNumber}: ${tabsToSpaces(sourceLine)}`;
175
+ return `${lineNumber}: ${displayedLine}`;
166
176
  })
167
177
  .join('\n');
168
178
  }
@@ -1016,6 +1026,7 @@ async function mergeInputOptions(config, overrides, defaultOnWarnHandler) {
1016
1026
  cache: config.cache,
1017
1027
  context: getOption('context'),
1018
1028
  experimentalCacheExpiry: getOption('experimentalCacheExpiry'),
1029
+ experimentalLogSideEffects: getOption('experimentalLogSideEffects'),
1019
1030
  external: getExternal(config, overrides),
1020
1031
  inlineDynamicImports: getOption('inlineDynamicImports'),
1021
1032
  input: getOption('input') || [],
@@ -6348,9 +6359,6 @@ class NodeBase extends ExpressionEntity {
6348
6359
  this.context.requestTreeshakingPass();
6349
6360
  }
6350
6361
  }
6351
- function logNode(node) {
6352
- return node.context.code.slice(node.start, node.end);
6353
- }
6354
6362
 
6355
6363
  class SpreadElement extends NodeBase {
6356
6364
  deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker) {
@@ -11783,6 +11791,8 @@ const getGenericImportMetaMechanism = (getUrl) => (property, { chunkId }) => {
11783
11791
  ? urlMechanism
11784
11792
  : 'undefined';
11785
11793
  };
11794
+ const getFileUrlFromFullPath = (path) => `require('u' + 'rl').pathToFileURL(${path}).href`;
11795
+ const getFileUrlFromRelativePath = (path) => getFileUrlFromFullPath(`__dirname + '/${path}'`);
11786
11796
  const getUrlFromDocument = (chunkId, umd = false) => `${umd ? `typeof document === 'undefined' ? location.href : ` : ''}(document.currentScript && document.currentScript.src || new URL('${escapeId(chunkId)}', document.baseURI).href)`;
11787
11797
  const relativeUrlMechanisms = {
11788
11798
  amd: relativePath => {
@@ -11790,18 +11800,18 @@ const relativeUrlMechanisms = {
11790
11800
  relativePath = './' + relativePath;
11791
11801
  return getResolveUrl(`require.toUrl('${relativePath}'), document.baseURI`);
11792
11802
  },
11793
- cjs: relativePath => `(typeof document === 'undefined' ? ${getResolveUrl(`'file:' + __dirname + '/${relativePath}'`, `(require('u' + 'rl').URL)`)} : ${getRelativeUrlFromDocument(relativePath)})`,
11803
+ cjs: relativePath => `(typeof document === 'undefined' ? ${getFileUrlFromRelativePath(relativePath)} : ${getRelativeUrlFromDocument(relativePath)})`,
11794
11804
  es: relativePath => getResolveUrl(`'${relativePath}', import.meta.url`),
11795
11805
  iife: relativePath => getRelativeUrlFromDocument(relativePath),
11796
11806
  system: relativePath => getResolveUrl(`'${relativePath}', module.meta.url`),
11797
- umd: relativePath => `(typeof document === 'undefined' && typeof location === 'undefined' ? ${getResolveUrl(`'file:' + __dirname + '/${relativePath}'`, `(require('u' + 'rl').URL)`)} : ${getRelativeUrlFromDocument(relativePath, true)})`
11807
+ umd: relativePath => `(typeof document === 'undefined' && typeof location === 'undefined' ? ${getFileUrlFromRelativePath(relativePath)} : ${getRelativeUrlFromDocument(relativePath, true)})`
11798
11808
  };
11799
11809
  const importMetaMechanisms = {
11800
11810
  amd: getGenericImportMetaMechanism(() => getResolveUrl(`module.uri, document.baseURI`)),
11801
- cjs: getGenericImportMetaMechanism(chunkId => `(typeof document === 'undefined' ? ${getResolveUrl(`'file:' + __filename`, `(require('u' + 'rl').URL)`)} : ${getUrlFromDocument(chunkId)})`),
11811
+ cjs: getGenericImportMetaMechanism(chunkId => `(typeof document === 'undefined' ? ${getFileUrlFromFullPath('__filename')} : ${getUrlFromDocument(chunkId)})`),
11802
11812
  iife: getGenericImportMetaMechanism(chunkId => getUrlFromDocument(chunkId)),
11803
11813
  system: (property, { snippets: { getPropertyAccess } }) => property === null ? `module.meta` : `module.meta${getPropertyAccess(property)}`,
11804
- umd: getGenericImportMetaMechanism(chunkId => `(typeof document === 'undefined' && typeof location === 'undefined' ? ${getResolveUrl(`'file:' + __filename`, `(require('u' + 'rl').URL)`)} : ${getUrlFromDocument(chunkId, true)})`)
11814
+ umd: getGenericImportMetaMechanism(chunkId => `(typeof document === 'undefined' && typeof location === 'undefined' ? ${getFileUrlFromFullPath('__filename')} : ${getUrlFromDocument(chunkId, true)})`)
11805
11815
  };
11806
11816
 
11807
11817
  class NewExpression extends NodeBase {
@@ -11936,6 +11946,29 @@ class ObjectExpression extends NodeBase {
11936
11946
  class PrivateIdentifier extends NodeBase {
11937
11947
  }
11938
11948
 
11949
+ function getOriginalLocation(sourcemapChain, location) {
11950
+ const filteredSourcemapChain = sourcemapChain.filter((sourcemap) => !!sourcemap.mappings);
11951
+ traceSourcemap: while (filteredSourcemapChain.length > 0) {
11952
+ const sourcemap = filteredSourcemapChain.pop();
11953
+ const line = sourcemap.mappings[location.line - 1];
11954
+ if (line) {
11955
+ const filteredLine = line.filter((segment) => segment.length > 1);
11956
+ const lastSegment = filteredLine[filteredLine.length - 1];
11957
+ for (const segment of filteredLine) {
11958
+ if (segment[0] >= location.column || segment === lastSegment) {
11959
+ location = {
11960
+ column: segment[3],
11961
+ line: segment[2] + 1
11962
+ };
11963
+ continue traceSourcemap;
11964
+ }
11965
+ }
11966
+ }
11967
+ throw new Error("Can't resolve original location of error.");
11968
+ }
11969
+ return location;
11970
+ }
11971
+
11939
11972
  class Program extends NodeBase {
11940
11973
  constructor() {
11941
11974
  super(...arguments);
@@ -11950,17 +11983,21 @@ class Program extends NodeBase {
11950
11983
  hasEffects(context) {
11951
11984
  for (const node of this.body) {
11952
11985
  if (node.hasEffects(context)) {
11953
- if (!this.hasLoggedEffect) {
11986
+ if (this.context.options.experimentalLogSideEffects && !this.hasLoggedEffect) {
11954
11987
  this.hasLoggedEffect = true;
11955
- let effect = logNode(node);
11956
- let truncated = false;
11957
- if (effect.length > 150) {
11958
- truncated = true;
11959
- effect = effect.slice(0, 150) + '...';
11988
+ const { code, module } = this.context;
11989
+ const { line, column } = locate(code, node.start, { offsetLine: 1 });
11990
+ console.log(`First side effect in ${relativeId(module.id)} is at (${line}:${column})\n${getCodeFrame(code, line, column)}`);
11991
+ try {
11992
+ const { column: originalColumn, line: originalLine } = getOriginalLocation(module.sourcemapChain, { column, line });
11993
+ if (originalLine !== line) {
11994
+ console.log(`Original location is at (${originalLine}:${originalColumn})\n${getCodeFrame(module.originalCode, originalLine, originalColumn)}\n`);
11995
+ }
11960
11996
  }
11961
- console.log(`==> First side effect in ${relativeId(this.context.module.id)}${truncated ? ' (truncated)' : ''}:`);
11962
- console.log(effect);
11963
- console.log('<==\n');
11997
+ catch {
11998
+ /* ignored */
11999
+ }
12000
+ console.log();
11964
12001
  }
11965
12002
  return (this.hasCachedEffect = true);
11966
12003
  }
@@ -13274,29 +13311,6 @@ function getId(m) {
13274
13311
  return m.id;
13275
13312
  }
13276
13313
 
13277
- function getOriginalLocation(sourcemapChain, location) {
13278
- const filteredSourcemapChain = sourcemapChain.filter((sourcemap) => !!sourcemap.mappings);
13279
- traceSourcemap: while (filteredSourcemapChain.length > 0) {
13280
- const sourcemap = filteredSourcemapChain.pop();
13281
- const line = sourcemap.mappings[location.line - 1];
13282
- if (line) {
13283
- const filteredLine = line.filter((segment) => segment.length > 1);
13284
- const lastSegment = filteredLine[filteredLine.length - 1];
13285
- for (const segment of filteredLine) {
13286
- if (segment[0] >= location.column || segment === lastSegment) {
13287
- location = {
13288
- column: segment[3],
13289
- line: segment[2] + 1
13290
- };
13291
- continue traceSourcemap;
13292
- }
13293
- }
13294
- }
13295
- throw new Error("Can't resolve original location of error.");
13296
- }
13297
- return location;
13298
- }
13299
-
13300
13314
  function getAssertionsFromImportExpression(node) {
13301
13315
  const assertProperty = node.arguments?.[0]?.properties.find((property) => getPropertyKey(property) === 'assert')?.value;
13302
13316
  if (!assertProperty) {
@@ -17069,8 +17083,6 @@ function compareChunkSize({ size: sizeA }, { size: sizeB }) {
17069
17083
  return sizeA - sizeB;
17070
17084
  }
17071
17085
  function mergeChunks(chunkPartition, minChunkSize) {
17072
- console.log('---- Initial chunks');
17073
- printConsistencyCheck(chunkPartition);
17074
17086
  for (const allowArbitraryMerges of [false, true]) {
17075
17087
  for (const mergedChunk of chunkPartition.small) {
17076
17088
  let closestChunk = null;
@@ -17122,8 +17134,6 @@ function mergeChunks(chunkPartition, minChunkSize) {
17122
17134
  getChunksInPartition(closestChunk, minChunkSize, chunkPartition).add(closestChunk);
17123
17135
  }
17124
17136
  }
17125
- console.log('---- After run with arbitrary merges:', allowArbitraryMerges);
17126
- printConsistencyCheck(chunkPartition);
17127
17137
  }
17128
17138
  }
17129
17139
  // Merging will not produce cycles if none of the direct non-merged dependencies
@@ -17179,57 +17189,6 @@ function getChunkEntryDistance({ dependentEntries: sourceEntries }, { dependentE
17179
17189
  }
17180
17190
  return distance;
17181
17191
  }
17182
- function printConsistencyCheck(partition) {
17183
- const chunks = new Set([...partition.big, ...partition.small]);
17184
- console.log('Number of cycles:', getNumberOfCycles(chunks));
17185
- let missingDependencies = 0;
17186
- let missingDependentChunks = 0;
17187
- const seenModules = new Set();
17188
- for (const { modules, dependencies, dependentChunks } of chunks) {
17189
- for (const module of modules) {
17190
- if (seenModules.has(module)) {
17191
- console.log(`Module ${module.id} is duplicated between chunks.`);
17192
- }
17193
- seenModules.add(module);
17194
- }
17195
- for (const dependency of dependencies) {
17196
- if (!chunks.has(dependency)) {
17197
- missingDependencies++;
17198
- }
17199
- }
17200
- for (const dependency of dependentChunks) {
17201
- if (!chunks.has(dependency)) {
17202
- missingDependentChunks++;
17203
- }
17204
- }
17205
- }
17206
- console.log(`Missing\n dependencies: ${missingDependencies},\n missing dependent chunks: ${missingDependentChunks}\n`);
17207
- }
17208
- function getNumberOfCycles(chunks) {
17209
- const parents = new Set();
17210
- const analysedChunks = new Set();
17211
- let cycles = 0;
17212
- const analyseChunk = (chunk) => {
17213
- for (const dependency of chunk.dependencies) {
17214
- if (parents.has(dependency)) {
17215
- if (!analysedChunks.has(dependency)) {
17216
- cycles++;
17217
- }
17218
- continue;
17219
- }
17220
- parents.add(dependency);
17221
- analyseChunk(dependency);
17222
- }
17223
- analysedChunks.add(chunk);
17224
- };
17225
- for (const chunk of chunks) {
17226
- if (!parents.has(chunk)) {
17227
- parents.add(chunk);
17228
- analyseChunk(chunk);
17229
- }
17230
- }
17231
- return cycles;
17232
- }
17233
17192
 
17234
17193
  // ported from https://github.com/substack/node-commondir
17235
17194
  function commondir(files) {
@@ -25359,6 +25318,7 @@ async function normalizeInputOptions(config) {
25359
25318
  cache: getCache(config),
25360
25319
  context,
25361
25320
  experimentalCacheExpiry: config.experimentalCacheExpiry ?? 10,
25321
+ experimentalLogSideEffects: config.experimentalLogSideEffects || false,
25362
25322
  external: getIdMatcher(config.external),
25363
25323
  inlineDynamicImports: getInlineDynamicImports$1(config, onwarn, strictDeprecations),
25364
25324
  input: getInput(config),
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v3.17.3-1
4
- Thu, 23 Feb 2023 18:26:12 GMT - commit a44e087fa8b10fcbee144d5d296611c72c4f489c
3
+ Rollup.js v3.18.0-0
4
+ Mon, 27 Feb 2023 06:19:25 GMT - commit a4bb325dbdad691e53bd6e969816d43c41d9e37e
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v3.17.3-1
4
- Thu, 23 Feb 2023 18:26:12 GMT - commit a44e087fa8b10fcbee144d5d296611c72c4f489c
3
+ Rollup.js v3.18.0-0
4
+ Mon, 27 Feb 2023 06:19:25 GMT - commit a4bb325dbdad691e53bd6e969816d43c41d9e37e
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v3.17.3-1
4
- Thu, 23 Feb 2023 18:26:12 GMT - commit a44e087fa8b10fcbee144d5d296611c72c4f489c
3
+ Rollup.js v3.18.0-0
4
+ Mon, 27 Feb 2023 06:19:25 GMT - commit a4bb325dbdad691e53bd6e969816d43c41d9e37e
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.17.3-1",
3
+ "version": "3.18.0-0",
4
4
  "description": "Next-generation ES module bundler",
5
5
  "main": "dist/rollup.js",
6
6
  "module": "dist/es/rollup.js",