rollup 3.17.3 → 3.18.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
6
- Sat, 25 Feb 2023 20:27:53 GMT - commit fa4e9a5fd037e94759390595f867220fa0af8a3e
5
+ Rollup.js v3.18.0
6
+ Wed, 01 Mar 2023 18:45:12 GMT - commit 25bdc129d21685b69a00ee55397d42ac6eff6449
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
4
- Sat, 25 Feb 2023 20:27:53 GMT - commit fa4e9a5fd037e94759390595f867220fa0af8a3e
3
+ Rollup.js v3.18.0
4
+ Wed, 01 Mar 2023 18:45:12 GMT - commit 25bdc129d21685b69a00ee55397d42ac6eff6449
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
4
- Sat, 25 Feb 2023 20:27:53 GMT - commit fa4e9a5fd037e94759390595f867220fa0af8a3e
3
+ Rollup.js v3.18.0
4
+ Wed, 01 Mar 2023 18:45:12 GMT - commit 25bdc129d21685b69a00ee55397d42ac6eff6449
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";
19
+ var version$1 = "3.18.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
  }
@@ -5701,8 +5711,8 @@ class NodeBase extends ExpressionEntity {
5701
5711
  }
5702
5712
  addExportedVariables(_variables, _exportNamesByVariable) { }
5703
5713
  /**
5704
- * Override this to bind assignments to variables and do any initialisations that
5705
- * require the scopes to be populated with variables.
5714
+ * Override this to bind assignments to variables and do any initialisations
5715
+ * that require the scopes to be populated with variables.
5706
5716
  */
5707
5717
  bind() {
5708
5718
  for (const key of this.keys) {
@@ -5718,7 +5728,8 @@ class NodeBase extends ExpressionEntity {
5718
5728
  }
5719
5729
  }
5720
5730
  /**
5721
- * Override if this node should receive a different scope than the parent scope.
5731
+ * Override if this node should receive a different scope than the parent
5732
+ * scope.
5722
5733
  */
5723
5734
  createScope(parentScope) {
5724
5735
  this.scope = parentScope;
@@ -5767,7 +5778,8 @@ class NodeBase extends ExpressionEntity {
5767
5778
  this.include(context, includeChildrenRecursively);
5768
5779
  }
5769
5780
  /**
5770
- * Override to perform special initialisation steps after the scope is initialised
5781
+ * Override to perform special initialisation steps after the scope is
5782
+ * initialised
5771
5783
  */
5772
5784
  initialise() { }
5773
5785
  insertSemicolon(code) {
@@ -11436,10 +11448,34 @@ class ObjectExpression extends NodeBase {
11436
11448
  class PrivateIdentifier extends NodeBase {
11437
11449
  }
11438
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
+
11439
11474
  class Program extends NodeBase {
11440
11475
  constructor() {
11441
11476
  super(...arguments);
11442
11477
  this.hasCachedEffect = null;
11478
+ this.hasLoggedEffect = false;
11443
11479
  }
11444
11480
  hasCachedEffects() {
11445
11481
  return this.hasCachedEffect === null
@@ -11449,6 +11485,22 @@ class Program extends NodeBase {
11449
11485
  hasEffects(context) {
11450
11486
  for (const node of this.body) {
11451
11487
  if (node.hasEffects(context)) {
11488
+ if (this.context.options.experimentalLogSideEffects && !this.hasLoggedEffect) {
11489
+ this.hasLoggedEffect = true;
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
+ }
11498
+ }
11499
+ catch {
11500
+ /* ignored */
11501
+ }
11502
+ console.log();
11503
+ }
11452
11504
  return (this.hasCachedEffect = true);
11453
11505
  }
11454
11506
  }
@@ -12761,29 +12813,6 @@ function getId(m) {
12761
12813
  return m.id;
12762
12814
  }
12763
12815
 
12764
- function getOriginalLocation(sourcemapChain, location) {
12765
- const filteredSourcemapChain = sourcemapChain.filter((sourcemap) => !!sourcemap.mappings);
12766
- traceSourcemap: while (filteredSourcemapChain.length > 0) {
12767
- const sourcemap = filteredSourcemapChain.pop();
12768
- const line = sourcemap.mappings[location.line - 1];
12769
- if (line) {
12770
- const filteredLine = line.filter((segment) => segment.length > 1);
12771
- const lastSegment = filteredLine[filteredLine.length - 1];
12772
- for (const segment of filteredLine) {
12773
- if (segment[0] >= location.column || segment === lastSegment) {
12774
- location = {
12775
- column: segment[3],
12776
- line: segment[2] + 1
12777
- };
12778
- continue traceSourcemap;
12779
- }
12780
- }
12781
- }
12782
- throw new Error("Can't resolve original location of error.");
12783
- }
12784
- return location;
12785
- }
12786
-
12787
12816
  function getAssertionsFromImportExpression(node) {
12788
12817
  const assertProperty = node.arguments?.[0]?.properties.find((property) => getPropertyKey(property) === 'assert')?.value;
12789
12818
  if (!assertProperty) {
@@ -17036,18 +17065,16 @@ async function transformChunk(magicString, fileName, usedModules, chunkGraph, op
17036
17065
  for (let sourcesIndex = 0; sourcesIndex < map.sources.length; ++sourcesIndex) {
17037
17066
  let sourcePath = map.sources[sourcesIndex];
17038
17067
  const sourcemapPath = `${resultingFile}.map`;
17039
- if (sourcemapIgnoreList) {
17040
- const ignoreList = sourcemapIgnoreList(sourcePath, sourcemapPath);
17041
- if (typeof ignoreList !== 'boolean') {
17042
- error(errorFailedValidation('sourcemapIgnoreList function must return a boolean.'));
17068
+ const ignoreList = sourcemapIgnoreList(sourcePath, sourcemapPath);
17069
+ if (typeof ignoreList !== 'boolean') {
17070
+ error(errorFailedValidation('sourcemapIgnoreList function must return a boolean.'));
17071
+ }
17072
+ if (ignoreList) {
17073
+ if (map.x_google_ignoreList === undefined) {
17074
+ map.x_google_ignoreList = [];
17043
17075
  }
17044
- if (ignoreList) {
17045
- if (map.x_google_ignoreList === undefined) {
17046
- map.x_google_ignoreList = [];
17047
- }
17048
- if (!map.x_google_ignoreList.includes(sourcesIndex)) {
17049
- map.x_google_ignoreList.push(sourcesIndex);
17050
- }
17076
+ if (!map.x_google_ignoreList.includes(sourcesIndex)) {
17077
+ map.x_google_ignoreList.push(sourcesIndex);
17051
17078
  }
17052
17079
  }
17053
17080
  if (sourcemapPathTransform) {
@@ -17082,11 +17109,10 @@ async function transformChunksAndGenerateContentHashes(renderedChunks, chunkGrap
17082
17109
  };
17083
17110
  const { code } = transformedChunk;
17084
17111
  if (hashPlaceholder) {
17085
- const hash = createHash();
17086
17112
  // To create a reproducible content-only hash, all placeholders are
17087
17113
  // replaced with the same value before hashing
17088
17114
  const { containedPlaceholders, transformedCode } = replacePlaceholdersWithDefaultAndGetContainedPlaceholders(code, placeholders);
17089
- hash.update(transformedCode);
17115
+ const hash = createHash().update(transformedCode);
17090
17116
  const hashAugmentation = pluginDriver.hookReduceValueSync('augmentChunkHash', '', [chunk.getRenderedChunkInfo()], (augmentation, pluginHash) => {
17091
17117
  if (pluginHash) {
17092
17118
  augmentation += pluginHash;
@@ -17130,8 +17156,7 @@ function generateFinalHashes(renderedChunksByPlaceholder, hashDependenciesByPlac
17130
17156
  do {
17131
17157
  // In case of a hash collision, create a hash of the hash
17132
17158
  if (finalHash) {
17133
- hash = createHash();
17134
- hash.update(finalHash);
17159
+ hash = createHash().update(finalHash);
17135
17160
  }
17136
17161
  finalHash = hash.digest('hex').slice(0, placeholder.length);
17137
17162
  finalFileName = replaceSinglePlaceholder(fileName, placeholder, finalHash);
@@ -24887,6 +24912,7 @@ async function normalizeInputOptions(config) {
24887
24912
  cache: getCache(config),
24888
24913
  context,
24889
24914
  experimentalCacheExpiry: config.experimentalCacheExpiry ?? 10,
24915
+ experimentalLogSideEffects: config.experimentalLogSideEffects || false,
24890
24916
  external: getIdMatcher(config.external),
24891
24917
  inlineDynamicImports: getInlineDynamicImports$1(config, onwarn, strictDeprecations),
24892
24918
  input: getInput(config),
@@ -25120,7 +25146,11 @@ async function normalizeOutputOptions(config, inputOptions, unsetInputOptions) {
25120
25146
  sourcemapBaseUrl: getSourcemapBaseUrl(config),
25121
25147
  sourcemapExcludeSources: config.sourcemapExcludeSources || false,
25122
25148
  sourcemapFile: config.sourcemapFile,
25123
- sourcemapIgnoreList: config.sourcemapIgnoreList,
25149
+ sourcemapIgnoreList: typeof config.sourcemapIgnoreList === 'function'
25150
+ ? config.sourcemapIgnoreList
25151
+ : config.sourcemapIgnoreList === false
25152
+ ? () => false
25153
+ : relativeSourcePath => relativeSourcePath.includes('node_modules'),
25124
25154
  sourcemapPathTransform: config.sourcemapPathTransform,
25125
25155
  strict: config.strict ?? true,
25126
25156
  systemNullSetters: config.systemNullSetters ?? true,
@@ -25723,6 +25753,7 @@ async function mergeInputOptions(config, overrides, defaultOnWarnHandler) {
25723
25753
  cache: config.cache,
25724
25754
  context: getOption('context'),
25725
25755
  experimentalCacheExpiry: getOption('experimentalCacheExpiry'),
25756
+ experimentalLogSideEffects: getOption('experimentalLogSideEffects'),
25726
25757
  external: getExternal(config, overrides),
25727
25758
  inlineDynamicImports: getOption('inlineDynamicImports'),
25728
25759
  input: getOption('input') || [],
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v3.17.3
4
- Sat, 25 Feb 2023 20:27:53 GMT - commit fa4e9a5fd037e94759390595f867220fa0af8a3e
3
+ Rollup.js v3.18.0
4
+ Wed, 01 Mar 2023 18:45:12 GMT - commit 25bdc129d21685b69a00ee55397d42ac6eff6449
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
4
- Sat, 25 Feb 2023 20:27:53 GMT - commit fa4e9a5fd037e94759390595f867220fa0af8a3e
3
+ Rollup.js v3.18.0
4
+ Wed, 01 Mar 2023 18:45:12 GMT - commit 25bdc129d21685b69a00ee55397d42ac6eff6449
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;
@@ -691,7 +693,7 @@ export interface OutputOptions {
691
693
  sourcemapBaseUrl?: string;
692
694
  sourcemapExcludeSources?: boolean;
693
695
  sourcemapFile?: string;
694
- sourcemapIgnoreList?: SourcemapIgnoreListOption;
696
+ sourcemapIgnoreList?: boolean | SourcemapIgnoreListOption;
695
697
  sourcemapPathTransform?: SourcemapPathTransformOption;
696
698
  strict?: boolean;
697
699
  systemNullSetters?: boolean;
@@ -746,7 +748,7 @@ export interface NormalizedOutputOptions {
746
748
  sourcemapBaseUrl: string | undefined;
747
749
  sourcemapExcludeSources: boolean;
748
750
  sourcemapFile: string | undefined;
749
- sourcemapIgnoreList: SourcemapIgnoreListOption | undefined;
751
+ sourcemapIgnoreList: SourcemapIgnoreListOption;
750
752
  sourcemapPathTransform: SourcemapPathTransformOption | undefined;
751
753
  strict: boolean;
752
754
  systemNullSetters: boolean;
package/dist/rollup.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v3.17.3
4
- Sat, 25 Feb 2023 20:27:53 GMT - commit fa4e9a5fd037e94759390595f867220fa0af8a3e
3
+ Rollup.js v3.18.0
4
+ Wed, 01 Mar 2023 18:45:12 GMT - commit 25bdc129d21685b69a00ee55397d42ac6eff6449
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
4
- Sat, 25 Feb 2023 20:27:53 GMT - commit fa4e9a5fd037e94759390595f867220fa0af8a3e
3
+ Rollup.js v3.18.0
4
+ Wed, 01 Mar 2023 18:45:12 GMT - commit 25bdc129d21685b69a00ee55397d42ac6eff6449
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
4
- Sat, 25 Feb 2023 20:27:53 GMT - commit fa4e9a5fd037e94759390595f867220fa0af8a3e
3
+ Rollup.js v3.18.0
4
+ Wed, 01 Mar 2023 18:45:12 GMT - commit 25bdc129d21685b69a00ee55397d42ac6eff6449
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
4
- Sat, 25 Feb 2023 20:27:53 GMT - commit fa4e9a5fd037e94759390595f867220fa0af8a3e
3
+ Rollup.js v3.18.0
4
+ Wed, 01 Mar 2023 18:45:12 GMT - commit 25bdc129d21685b69a00ee55397d42ac6eff6449
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
4
- Sat, 25 Feb 2023 20:27:53 GMT - commit fa4e9a5fd037e94759390595f867220fa0af8a3e
3
+ Rollup.js v3.18.0
4
+ Wed, 01 Mar 2023 18:45:12 GMT - commit 25bdc129d21685b69a00ee55397d42ac6eff6449
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";
34
+ var version$1 = "3.18.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') || [],
@@ -6198,8 +6209,8 @@ class NodeBase extends ExpressionEntity {
6198
6209
  }
6199
6210
  addExportedVariables(_variables, _exportNamesByVariable) { }
6200
6211
  /**
6201
- * Override this to bind assignments to variables and do any initialisations that
6202
- * require the scopes to be populated with variables.
6212
+ * Override this to bind assignments to variables and do any initialisations
6213
+ * that require the scopes to be populated with variables.
6203
6214
  */
6204
6215
  bind() {
6205
6216
  for (const key of this.keys) {
@@ -6215,7 +6226,8 @@ class NodeBase extends ExpressionEntity {
6215
6226
  }
6216
6227
  }
6217
6228
  /**
6218
- * Override if this node should receive a different scope than the parent scope.
6229
+ * Override if this node should receive a different scope than the parent
6230
+ * scope.
6219
6231
  */
6220
6232
  createScope(parentScope) {
6221
6233
  this.scope = parentScope;
@@ -6264,7 +6276,8 @@ class NodeBase extends ExpressionEntity {
6264
6276
  this.include(context, includeChildrenRecursively);
6265
6277
  }
6266
6278
  /**
6267
- * Override to perform special initialisation steps after the scope is initialised
6279
+ * Override to perform special initialisation steps after the scope is
6280
+ * initialised
6268
6281
  */
6269
6282
  initialise() { }
6270
6283
  insertSemicolon(code) {
@@ -11933,10 +11946,34 @@ class ObjectExpression extends NodeBase {
11933
11946
  class PrivateIdentifier extends NodeBase {
11934
11947
  }
11935
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
+
11936
11972
  class Program extends NodeBase {
11937
11973
  constructor() {
11938
11974
  super(...arguments);
11939
11975
  this.hasCachedEffect = null;
11976
+ this.hasLoggedEffect = false;
11940
11977
  }
11941
11978
  hasCachedEffects() {
11942
11979
  return this.hasCachedEffect === null
@@ -11946,6 +11983,22 @@ class Program extends NodeBase {
11946
11983
  hasEffects(context) {
11947
11984
  for (const node of this.body) {
11948
11985
  if (node.hasEffects(context)) {
11986
+ if (this.context.options.experimentalLogSideEffects && !this.hasLoggedEffect) {
11987
+ this.hasLoggedEffect = true;
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
+ }
11996
+ }
11997
+ catch {
11998
+ /* ignored */
11999
+ }
12000
+ console.log();
12001
+ }
11949
12002
  return (this.hasCachedEffect = true);
11950
12003
  }
11951
12004
  }
@@ -13258,29 +13311,6 @@ function getId(m) {
13258
13311
  return m.id;
13259
13312
  }
13260
13313
 
13261
- function getOriginalLocation(sourcemapChain, location) {
13262
- const filteredSourcemapChain = sourcemapChain.filter((sourcemap) => !!sourcemap.mappings);
13263
- traceSourcemap: while (filteredSourcemapChain.length > 0) {
13264
- const sourcemap = filteredSourcemapChain.pop();
13265
- const line = sourcemap.mappings[location.line - 1];
13266
- if (line) {
13267
- const filteredLine = line.filter((segment) => segment.length > 1);
13268
- const lastSegment = filteredLine[filteredLine.length - 1];
13269
- for (const segment of filteredLine) {
13270
- if (segment[0] >= location.column || segment === lastSegment) {
13271
- location = {
13272
- column: segment[3],
13273
- line: segment[2] + 1
13274
- };
13275
- continue traceSourcemap;
13276
- }
13277
- }
13278
- }
13279
- throw new Error("Can't resolve original location of error.");
13280
- }
13281
- return location;
13282
- }
13283
-
13284
13314
  function getAssertionsFromImportExpression(node) {
13285
13315
  const assertProperty = node.arguments?.[0]?.properties.find((property) => getPropertyKey(property) === 'assert')?.value;
13286
13316
  if (!assertProperty) {
@@ -17533,18 +17563,16 @@ async function transformChunk(magicString, fileName, usedModules, chunkGraph, op
17533
17563
  for (let sourcesIndex = 0; sourcesIndex < map.sources.length; ++sourcesIndex) {
17534
17564
  let sourcePath = map.sources[sourcesIndex];
17535
17565
  const sourcemapPath = `${resultingFile}.map`;
17536
- if (sourcemapIgnoreList) {
17537
- const ignoreList = sourcemapIgnoreList(sourcePath, sourcemapPath);
17538
- if (typeof ignoreList !== 'boolean') {
17539
- error(errorFailedValidation('sourcemapIgnoreList function must return a boolean.'));
17566
+ const ignoreList = sourcemapIgnoreList(sourcePath, sourcemapPath);
17567
+ if (typeof ignoreList !== 'boolean') {
17568
+ error(errorFailedValidation('sourcemapIgnoreList function must return a boolean.'));
17569
+ }
17570
+ if (ignoreList) {
17571
+ if (map.x_google_ignoreList === undefined) {
17572
+ map.x_google_ignoreList = [];
17540
17573
  }
17541
- if (ignoreList) {
17542
- if (map.x_google_ignoreList === undefined) {
17543
- map.x_google_ignoreList = [];
17544
- }
17545
- if (!map.x_google_ignoreList.includes(sourcesIndex)) {
17546
- map.x_google_ignoreList.push(sourcesIndex);
17547
- }
17574
+ if (!map.x_google_ignoreList.includes(sourcesIndex)) {
17575
+ map.x_google_ignoreList.push(sourcesIndex);
17548
17576
  }
17549
17577
  }
17550
17578
  if (sourcemapPathTransform) {
@@ -17579,11 +17607,10 @@ async function transformChunksAndGenerateContentHashes(renderedChunks, chunkGrap
17579
17607
  };
17580
17608
  const { code } = transformedChunk;
17581
17609
  if (hashPlaceholder) {
17582
- const hash = createHash();
17583
17610
  // To create a reproducible content-only hash, all placeholders are
17584
17611
  // replaced with the same value before hashing
17585
17612
  const { containedPlaceholders, transformedCode } = replacePlaceholdersWithDefaultAndGetContainedPlaceholders(code, placeholders);
17586
- hash.update(transformedCode);
17613
+ const hash = createHash().update(transformedCode);
17587
17614
  const hashAugmentation = pluginDriver.hookReduceValueSync('augmentChunkHash', '', [chunk.getRenderedChunkInfo()], (augmentation, pluginHash) => {
17588
17615
  if (pluginHash) {
17589
17616
  augmentation += pluginHash;
@@ -17627,8 +17654,7 @@ function generateFinalHashes(renderedChunksByPlaceholder, hashDependenciesByPlac
17627
17654
  do {
17628
17655
  // In case of a hash collision, create a hash of the hash
17629
17656
  if (finalHash) {
17630
- hash = createHash();
17631
- hash.update(finalHash);
17657
+ hash = createHash().update(finalHash);
17632
17658
  }
17633
17659
  finalHash = hash.digest('hex').slice(0, placeholder.length);
17634
17660
  finalFileName = replaceSinglePlaceholder(fileName, placeholder, finalHash);
@@ -25288,6 +25314,7 @@ async function normalizeInputOptions(config) {
25288
25314
  cache: getCache(config),
25289
25315
  context,
25290
25316
  experimentalCacheExpiry: config.experimentalCacheExpiry ?? 10,
25317
+ experimentalLogSideEffects: config.experimentalLogSideEffects || false,
25291
25318
  external: getIdMatcher(config.external),
25292
25319
  inlineDynamicImports: getInlineDynamicImports$1(config, onwarn, strictDeprecations),
25293
25320
  input: getInput(config),
@@ -25521,7 +25548,11 @@ async function normalizeOutputOptions(config, inputOptions, unsetInputOptions) {
25521
25548
  sourcemapBaseUrl: getSourcemapBaseUrl(config),
25522
25549
  sourcemapExcludeSources: config.sourcemapExcludeSources || false,
25523
25550
  sourcemapFile: config.sourcemapFile,
25524
- sourcemapIgnoreList: config.sourcemapIgnoreList,
25551
+ sourcemapIgnoreList: typeof config.sourcemapIgnoreList === 'function'
25552
+ ? config.sourcemapIgnoreList
25553
+ : config.sourcemapIgnoreList === false
25554
+ ? () => false
25555
+ : relativeSourcePath => relativeSourcePath.includes('node_modules'),
25525
25556
  sourcemapPathTransform: config.sourcemapPathTransform,
25526
25557
  strict: config.strict ?? true,
25527
25558
  systemNullSetters: config.systemNullSetters ?? true,
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v3.17.3
4
- Sat, 25 Feb 2023 20:27:53 GMT - commit fa4e9a5fd037e94759390595f867220fa0af8a3e
3
+ Rollup.js v3.18.0
4
+ Wed, 01 Mar 2023 18:45:12 GMT - commit 25bdc129d21685b69a00ee55397d42ac6eff6449
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
4
- Sat, 25 Feb 2023 20:27:53 GMT - commit fa4e9a5fd037e94759390595f867220fa0af8a3e
3
+ Rollup.js v3.18.0
4
+ Wed, 01 Mar 2023 18:45:12 GMT - commit 25bdc129d21685b69a00ee55397d42ac6eff6449
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
4
- Sat, 25 Feb 2023 20:27:53 GMT - commit fa4e9a5fd037e94759390595f867220fa0af8a3e
3
+ Rollup.js v3.18.0
4
+ Wed, 01 Mar 2023 18:45:12 GMT - commit 25bdc129d21685b69a00ee55397d42ac6eff6449
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",
3
+ "version": "3.18.0",
4
4
  "description": "Next-generation ES module bundler",
5
5
  "main": "dist/rollup.js",
6
6
  "module": "dist/es/rollup.js",