rollup 4.62.5 → 4.63.1
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 +3 -3
- package/dist/es/getLogFilter.js +2 -2
- package/dist/es/parseAst.js +2 -2
- package/dist/es/rollup.js +2 -2
- package/dist/es/shared/node-entry.js +123 -55
- package/dist/es/shared/parseAst.js +2 -2
- package/dist/es/shared/watch.js +2 -2
- package/dist/getLogFilter.js +2 -2
- package/dist/loadConfigFile.js +2 -2
- package/dist/parseAst.js +2 -2
- package/dist/rollup.js +2 -2
- package/dist/shared/fsevents-importer.js +2 -2
- package/dist/shared/index.js +2 -2
- package/dist/shared/loadConfigFile.js +2 -2
- package/dist/shared/parseAst.js +2 -2
- package/dist/shared/rollup.js +123 -55
- package/dist/shared/watch-cli.js +2 -2
- package/dist/shared/watch.js +2 -2
- package/package.json +38 -38
package/dist/shared/parseAst.js
CHANGED
package/dist/shared/rollup.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
2
|
@license
|
|
3
|
-
Rollup.js v4.
|
|
4
|
-
|
|
3
|
+
Rollup.js v4.63.1
|
|
4
|
+
Fri, 28 Aug 2026 05:58:50 GMT - commit 78bfef0cb94479566f81012fafa372c84b90bd34
|
|
5
5
|
|
|
6
6
|
https://github.com/rollup/rollup
|
|
7
7
|
|
|
@@ -42,7 +42,7 @@ function _mergeNamespaces(n, m) {
|
|
|
42
42
|
|
|
43
43
|
const promises__namespace = /*#__PURE__*/_interopNamespaceDefault(promises);
|
|
44
44
|
|
|
45
|
-
var version = "4.
|
|
45
|
+
var version = "4.63.1";
|
|
46
46
|
const package_ = {
|
|
47
47
|
version: version};
|
|
48
48
|
|
|
@@ -1309,7 +1309,7 @@ function requireScan () {
|
|
|
1309
1309
|
const opts = options || {};
|
|
1310
1310
|
|
|
1311
1311
|
const length = input.length - 1;
|
|
1312
|
-
const scanToEnd = opts.parts === true || opts.scanToEnd === true;
|
|
1312
|
+
const scanToEnd = opts.parts === true || opts.tokens === true || opts.scanToEnd === true;
|
|
1313
1313
|
const slashes = [];
|
|
1314
1314
|
const tokens = [];
|
|
1315
1315
|
const parts = [];
|
|
@@ -1443,15 +1443,21 @@ function requireScan () {
|
|
|
1443
1443
|
}
|
|
1444
1444
|
|
|
1445
1445
|
if (scanToEnd === true) {
|
|
1446
|
+
let parens = 0;
|
|
1447
|
+
|
|
1446
1448
|
while (eos() !== true && (code = advance())) {
|
|
1447
1449
|
if (code === CHAR_BACKWARD_SLASH) {
|
|
1448
1450
|
backslashes = token.backslashes = true;
|
|
1449
|
-
|
|
1451
|
+
advance();
|
|
1452
|
+
continue;
|
|
1453
|
+
}
|
|
1454
|
+
|
|
1455
|
+
if (code === CHAR_LEFT_PARENTHESES) {
|
|
1456
|
+
parens++;
|
|
1450
1457
|
continue;
|
|
1451
1458
|
}
|
|
1452
1459
|
|
|
1453
|
-
if (code === CHAR_RIGHT_PARENTHESES) {
|
|
1454
|
-
isGlob = token.isGlob = true;
|
|
1460
|
+
if (code === CHAR_RIGHT_PARENTHESES && --parens === 0) {
|
|
1455
1461
|
finished = true;
|
|
1456
1462
|
break;
|
|
1457
1463
|
}
|
|
@@ -1516,14 +1522,21 @@ function requireScan () {
|
|
|
1516
1522
|
isGlob = token.isGlob = true;
|
|
1517
1523
|
|
|
1518
1524
|
if (scanToEnd === true) {
|
|
1525
|
+
let parens = 1;
|
|
1526
|
+
|
|
1519
1527
|
while (eos() !== true && (code = advance())) {
|
|
1520
|
-
if (code ===
|
|
1528
|
+
if (code === CHAR_BACKWARD_SLASH) {
|
|
1521
1529
|
backslashes = token.backslashes = true;
|
|
1522
|
-
|
|
1530
|
+
advance();
|
|
1523
1531
|
continue;
|
|
1524
1532
|
}
|
|
1525
1533
|
|
|
1526
|
-
if (code ===
|
|
1534
|
+
if (code === CHAR_LEFT_PARENTHESES) {
|
|
1535
|
+
parens++;
|
|
1536
|
+
continue;
|
|
1537
|
+
}
|
|
1538
|
+
|
|
1539
|
+
if (code === CHAR_RIGHT_PARENTHESES && --parens === 0) {
|
|
1527
1540
|
finished = true;
|
|
1528
1541
|
break;
|
|
1529
1542
|
}
|
|
@@ -1610,7 +1623,7 @@ function requireScan () {
|
|
|
1610
1623
|
let prevIndex;
|
|
1611
1624
|
|
|
1612
1625
|
for (let idx = 0; idx < slashes.length; idx++) {
|
|
1613
|
-
const n = prevIndex ? prevIndex + 1 : start;
|
|
1626
|
+
const n = prevIndex !== undefined ? prevIndex + 1 : start;
|
|
1614
1627
|
const i = slashes[idx];
|
|
1615
1628
|
const value = input.slice(n, i);
|
|
1616
1629
|
if (opts.tokens) {
|
|
@@ -1623,21 +1636,20 @@ function requireScan () {
|
|
|
1623
1636
|
depth(tokens[idx]);
|
|
1624
1637
|
state.maxDepth += tokens[idx].depth;
|
|
1625
1638
|
}
|
|
1626
|
-
if (
|
|
1639
|
+
if (i >= start) {
|
|
1627
1640
|
parts.push(value);
|
|
1641
|
+
prevIndex = i;
|
|
1628
1642
|
}
|
|
1629
|
-
prevIndex = i;
|
|
1630
1643
|
}
|
|
1631
1644
|
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1645
|
+
const n = prevIndex !== undefined ? prevIndex + 1 : start;
|
|
1646
|
+
const value = input.slice(n);
|
|
1647
|
+
parts.push(value);
|
|
1635
1648
|
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
}
|
|
1649
|
+
if (opts.tokens && prevIndex && prevIndex + 1 < input.length) {
|
|
1650
|
+
tokens[tokens.length - 1].value = value;
|
|
1651
|
+
depth(tokens[tokens.length - 1]);
|
|
1652
|
+
state.maxDepth += tokens[tokens.length - 1].depth;
|
|
1641
1653
|
}
|
|
1642
1654
|
|
|
1643
1655
|
state.slashes = slashes;
|
|
@@ -2826,6 +2838,15 @@ function requireParse () {
|
|
|
2826
2838
|
consume('/**', 3);
|
|
2827
2839
|
}
|
|
2828
2840
|
|
|
2841
|
+
// A globstar followed only by balanced closing parens is at the logical end of patterns like
|
|
2842
|
+
// `test(/utils/**)` and `test?(/utils/**)`. Treat it as EOS so the trailing `/**` can match its
|
|
2843
|
+
// parent path, except in negated extglobs where that would change the exclusion semantics.
|
|
2844
|
+
const isEnd = eos() || (
|
|
2845
|
+
state.parens > 0
|
|
2846
|
+
&& rest === ')'.repeat(state.parens)
|
|
2847
|
+
&& !extglobs.some(extglob => extglob.type === 'negate')
|
|
2848
|
+
);
|
|
2849
|
+
|
|
2829
2850
|
if (prior.type === 'bos' && eos()) {
|
|
2830
2851
|
prev.type = 'globstar';
|
|
2831
2852
|
prev.value += value;
|
|
@@ -2836,7 +2857,7 @@ function requireParse () {
|
|
|
2836
2857
|
continue;
|
|
2837
2858
|
}
|
|
2838
2859
|
|
|
2839
|
-
if (prior.type === 'slash' && prior.prev.type !== 'bos' && !afterStar &&
|
|
2860
|
+
if (prior.type === 'slash' && prior.prev.type !== 'bos' && !afterStar && isEnd) {
|
|
2840
2861
|
state.output = state.output.slice(0, -(prior.output + prev.output).length);
|
|
2841
2862
|
prior.output = `(?:${prior.output}`;
|
|
2842
2863
|
|
|
@@ -4513,13 +4534,27 @@ var Chunk$1 = class Chunk {
|
|
|
4513
4534
|
}
|
|
4514
4535
|
};
|
|
4515
4536
|
//#endregion
|
|
4537
|
+
//#region src/MagicStringError.ts
|
|
4538
|
+
/**
|
|
4539
|
+
* The single error type thrown by MagicString.
|
|
4540
|
+
*
|
|
4541
|
+
* Every message is prefixed with `[MagicString]` so its source is obvious at a
|
|
4542
|
+
* glance, and is kept short and consistent in tone.
|
|
4543
|
+
*/
|
|
4544
|
+
var MagicStringError = class extends Error {
|
|
4545
|
+
name = "MagicStringError";
|
|
4546
|
+
constructor(message, options) {
|
|
4547
|
+
super(`[MagicString] ${message}`, options);
|
|
4548
|
+
}
|
|
4549
|
+
};
|
|
4550
|
+
//#endregion
|
|
4516
4551
|
//#region src/SourceMap.ts
|
|
4517
4552
|
function getBtoa() {
|
|
4518
4553
|
if (typeof globalThis !== "undefined" && typeof globalThis.btoa === "function") return (str) => globalThis.btoa(unescape(encodeURIComponent(str)));
|
|
4519
4554
|
const buffer = globalThis["Buffer"];
|
|
4520
4555
|
if (buffer) return (str) => buffer.from(str, "utf-8").toString("base64");
|
|
4521
4556
|
return () => {
|
|
4522
|
-
throw new
|
|
4557
|
+
throw new MagicStringError("unsupported environment: `btoa` or `Buffer` is required");
|
|
4523
4558
|
};
|
|
4524
4559
|
}
|
|
4525
4560
|
const btoa = /* #__PURE__ */ getBtoa();
|
|
@@ -4748,11 +4783,11 @@ var MagicString = class MagicString {
|
|
|
4748
4783
|
},
|
|
4749
4784
|
byStart: {
|
|
4750
4785
|
writable: true,
|
|
4751
|
-
value:
|
|
4786
|
+
value: /* @__PURE__ */ new Map([[0, chunk]])
|
|
4752
4787
|
},
|
|
4753
4788
|
byEnd: {
|
|
4754
4789
|
writable: true,
|
|
4755
|
-
value:
|
|
4790
|
+
value: /* @__PURE__ */ new Map([[string.length, chunk]])
|
|
4756
4791
|
},
|
|
4757
4792
|
filename: {
|
|
4758
4793
|
writable: true,
|
|
@@ -4781,10 +4816,12 @@ var MagicString = class MagicString {
|
|
|
4781
4816
|
offset: {
|
|
4782
4817
|
writable: true,
|
|
4783
4818
|
value: options.offset || 0
|
|
4819
|
+
},
|
|
4820
|
+
hasMovedChunks: {
|
|
4821
|
+
writable: true,
|
|
4822
|
+
value: false
|
|
4784
4823
|
}
|
|
4785
4824
|
});
|
|
4786
|
-
this.byStart = /* @__PURE__ */ new Map([[0, chunk]]);
|
|
4787
|
-
this.byEnd = /* @__PURE__ */ new Map([[string.length, chunk]]);
|
|
4788
4825
|
}
|
|
4789
4826
|
/**
|
|
4790
4827
|
* Adds the specified character index (with respect to the original string) to sourcemap mappings, if `hires` is false.
|
|
@@ -4796,7 +4833,7 @@ var MagicString = class MagicString {
|
|
|
4796
4833
|
* Appends the specified content to the end of the string.
|
|
4797
4834
|
*/
|
|
4798
4835
|
append(content) {
|
|
4799
|
-
if (typeof content !== "string") throw new
|
|
4836
|
+
if (typeof content !== "string") throw new MagicStringError(`content must be a string, got ${typeof content}`);
|
|
4800
4837
|
this.outro += content;
|
|
4801
4838
|
return this;
|
|
4802
4839
|
}
|
|
@@ -4807,7 +4844,7 @@ var MagicString = class MagicString {
|
|
|
4807
4844
|
*/
|
|
4808
4845
|
appendLeft(index, content) {
|
|
4809
4846
|
index = index + this.offset;
|
|
4810
|
-
if (typeof content !== "string") throw new
|
|
4847
|
+
if (typeof content !== "string") throw new MagicStringError(`content must be a string, got ${typeof content}`);
|
|
4811
4848
|
this._split(index);
|
|
4812
4849
|
const chunk = this.byEnd.get(index);
|
|
4813
4850
|
if (chunk) chunk.appendLeft(content);
|
|
@@ -4821,7 +4858,7 @@ var MagicString = class MagicString {
|
|
|
4821
4858
|
*/
|
|
4822
4859
|
appendRight(index, content) {
|
|
4823
4860
|
index = index + this.offset;
|
|
4824
|
-
if (typeof content !== "string") throw new
|
|
4861
|
+
if (typeof content !== "string") throw new MagicStringError(`content must be a string, got ${typeof content}`);
|
|
4825
4862
|
this._split(index);
|
|
4826
4863
|
const chunk = this.byStart.get(index);
|
|
4827
4864
|
if (chunk) chunk.appendRight(content);
|
|
@@ -4834,6 +4871,7 @@ var MagicString = class MagicString {
|
|
|
4834
4871
|
clone() {
|
|
4835
4872
|
const cloned = new MagicString(this.original, {
|
|
4836
4873
|
filename: this.filename,
|
|
4874
|
+
ignoreList: this.ignoreList,
|
|
4837
4875
|
offset: this.offset
|
|
4838
4876
|
});
|
|
4839
4877
|
let originalChunk = this.firstChunk;
|
|
@@ -4853,8 +4891,10 @@ var MagicString = class MagicString {
|
|
|
4853
4891
|
cloned.lastChunk = clonedChunk;
|
|
4854
4892
|
if (this.indentExclusionRanges) cloned.indentExclusionRanges = this.indentExclusionRanges.slice();
|
|
4855
4893
|
cloned.sourcemapLocations = new BitSet(this.sourcemapLocations);
|
|
4894
|
+
cloned.storedNames = { ...this.storedNames };
|
|
4856
4895
|
cloned.intro = this.intro;
|
|
4857
4896
|
cloned.outro = this.outro;
|
|
4897
|
+
cloned.hasMovedChunks = this.hasMovedChunks;
|
|
4858
4898
|
return cloned;
|
|
4859
4899
|
}
|
|
4860
4900
|
/**
|
|
@@ -4983,7 +5023,7 @@ var MagicString = class MagicString {
|
|
|
4983
5023
|
}
|
|
4984
5024
|
/** @internal */
|
|
4985
5025
|
insert() {
|
|
4986
|
-
throw new
|
|
5026
|
+
throw new MagicStringError("insert() is deprecated, use appendLeft() or prependRight()");
|
|
4987
5027
|
}
|
|
4988
5028
|
/** @internal */
|
|
4989
5029
|
insertLeft(index, content) {
|
|
@@ -5009,12 +5049,19 @@ var MagicString = class MagicString {
|
|
|
5009
5049
|
end = end + this.offset;
|
|
5010
5050
|
index = index + this.offset;
|
|
5011
5051
|
if (start === end) return this;
|
|
5012
|
-
if (index >= start && index <= end) throw new
|
|
5052
|
+
if (index >= start && index <= end) throw new MagicStringError("cannot move a selection inside itself");
|
|
5013
5053
|
this._split(start);
|
|
5014
5054
|
this._split(end);
|
|
5015
5055
|
this._split(index);
|
|
5016
5056
|
const first = this.byStart.get(start);
|
|
5017
5057
|
const last = this.byEnd.get(end);
|
|
5058
|
+
if (this.hasMovedChunks) {
|
|
5059
|
+
let cursor = first;
|
|
5060
|
+
while (cursor !== last) {
|
|
5061
|
+
cursor = cursor.next;
|
|
5062
|
+
if (!cursor || cursor.start < start || cursor.end > end) throw new MagicStringError(`cannot move ${start} to ${end} because an earlier move split that range`);
|
|
5063
|
+
}
|
|
5064
|
+
}
|
|
5018
5065
|
const oldLeft = first.previous;
|
|
5019
5066
|
const oldRight = last.next;
|
|
5020
5067
|
const newRight = this.byStart.get(index);
|
|
@@ -5033,6 +5080,7 @@ var MagicString = class MagicString {
|
|
|
5033
5080
|
last.next = newRight || null;
|
|
5034
5081
|
if (!newLeft) this.firstChunk = first;
|
|
5035
5082
|
if (!newRight) this.lastChunk = last;
|
|
5083
|
+
this.hasMovedChunks = true;
|
|
5036
5084
|
return this;
|
|
5037
5085
|
}
|
|
5038
5086
|
/**
|
|
@@ -5062,13 +5110,15 @@ var MagicString = class MagicString {
|
|
|
5062
5110
|
update(start, end, content, options) {
|
|
5063
5111
|
start = start + this.offset;
|
|
5064
5112
|
end = end + this.offset;
|
|
5065
|
-
if (typeof content !== "string") throw new
|
|
5113
|
+
if (typeof content !== "string") throw new MagicStringError(`content must be a string, got ${typeof content}`);
|
|
5066
5114
|
if (this.original.length !== 0) {
|
|
5067
5115
|
while (start < 0) start += this.original.length;
|
|
5068
5116
|
while (end < 0) end += this.original.length;
|
|
5069
5117
|
}
|
|
5070
|
-
if (
|
|
5071
|
-
if (
|
|
5118
|
+
if (start < 0) throw new MagicStringError(`start ${start} is out of bounds`);
|
|
5119
|
+
if (end > this.original.length) throw new MagicStringError(`end ${end} is out of bounds`);
|
|
5120
|
+
if (start === end) throw new MagicStringError(`cannot overwrite a zero-length range at ${start}, use appendLeft() or prependRight()`);
|
|
5121
|
+
if (start > end) throw new MagicStringError(`end must be greater than start (start: ${start}, end: ${end})`);
|
|
5072
5122
|
this._split(start);
|
|
5073
5123
|
this._split(end);
|
|
5074
5124
|
if (options === true) {
|
|
@@ -5094,7 +5144,7 @@ var MagicString = class MagicString {
|
|
|
5094
5144
|
if (first) {
|
|
5095
5145
|
let chunk = first;
|
|
5096
5146
|
while (chunk !== last) {
|
|
5097
|
-
if (chunk.next !== this.byStart.get(chunk.end)) throw new
|
|
5147
|
+
if (chunk.next !== this.byStart.get(chunk.end)) throw new MagicStringError("cannot overwrite across a split point");
|
|
5098
5148
|
chunk = chunk.next;
|
|
5099
5149
|
chunk.edit("", false);
|
|
5100
5150
|
}
|
|
@@ -5110,7 +5160,7 @@ var MagicString = class MagicString {
|
|
|
5110
5160
|
* Prepends the string with the specified content.
|
|
5111
5161
|
*/
|
|
5112
5162
|
prepend(content) {
|
|
5113
|
-
if (typeof content !== "string") throw new
|
|
5163
|
+
if (typeof content !== "string") throw new MagicStringError(`content must be a string, got ${typeof content}`);
|
|
5114
5164
|
this.intro = content + this.intro;
|
|
5115
5165
|
return this;
|
|
5116
5166
|
}
|
|
@@ -5119,7 +5169,7 @@ var MagicString = class MagicString {
|
|
|
5119
5169
|
*/
|
|
5120
5170
|
prependLeft(index, content) {
|
|
5121
5171
|
index = index + this.offset;
|
|
5122
|
-
if (typeof content !== "string") throw new
|
|
5172
|
+
if (typeof content !== "string") throw new MagicStringError(`content must be a string, got ${typeof content}`);
|
|
5123
5173
|
this._split(index);
|
|
5124
5174
|
const chunk = this.byEnd.get(index);
|
|
5125
5175
|
if (chunk) chunk.prependLeft(content);
|
|
@@ -5131,7 +5181,7 @@ var MagicString = class MagicString {
|
|
|
5131
5181
|
*/
|
|
5132
5182
|
prependRight(index, content) {
|
|
5133
5183
|
index = index + this.offset;
|
|
5134
|
-
if (typeof content !== "string") throw new
|
|
5184
|
+
if (typeof content !== "string") throw new MagicStringError(`content must be a string, got ${typeof content}`);
|
|
5135
5185
|
this._split(index);
|
|
5136
5186
|
const chunk = this.byStart.get(index);
|
|
5137
5187
|
if (chunk) chunk.prependRight(content);
|
|
@@ -5150,8 +5200,8 @@ var MagicString = class MagicString {
|
|
|
5150
5200
|
while (end < 0) end += this.original.length;
|
|
5151
5201
|
}
|
|
5152
5202
|
if (start === end) return this;
|
|
5153
|
-
if (start < 0 || end > this.original.length) throw new
|
|
5154
|
-
if (start > end) throw new
|
|
5203
|
+
if (start < 0 || end > this.original.length) throw new MagicStringError(`range ${start}–${end} is out of bounds`);
|
|
5204
|
+
if (start > end) throw new MagicStringError(`end must be greater than start (start: ${start}, end: ${end})`);
|
|
5155
5205
|
this._split(start);
|
|
5156
5206
|
this._split(end);
|
|
5157
5207
|
let chunk = this.byStart.get(start);
|
|
@@ -5174,8 +5224,8 @@ var MagicString = class MagicString {
|
|
|
5174
5224
|
while (end < 0) end += this.original.length;
|
|
5175
5225
|
}
|
|
5176
5226
|
if (start === end) return this;
|
|
5177
|
-
if (start < 0 || end > this.original.length) throw new
|
|
5178
|
-
if (start > end) throw new
|
|
5227
|
+
if (start < 0 || end > this.original.length) throw new MagicStringError(`range ${start}–${end} is out of bounds`);
|
|
5228
|
+
if (start > end) throw new MagicStringError(`end must be greater than start (start: ${start}, end: ${end})`);
|
|
5179
5229
|
this._split(start);
|
|
5180
5230
|
this._split(end);
|
|
5181
5231
|
let chunk = this.byStart.get(start);
|
|
@@ -5241,12 +5291,12 @@ var MagicString = class MagicString {
|
|
|
5241
5291
|
if (chunk.start < end && chunk.end >= end) return result;
|
|
5242
5292
|
chunk = chunk.next;
|
|
5243
5293
|
}
|
|
5244
|
-
if (chunk && chunk.edited && chunk.start !== start) throw new
|
|
5294
|
+
if (chunk && chunk.edited && chunk.start !== start) throw new MagicStringError(`cannot use edited character ${start} as slice start anchor`);
|
|
5245
5295
|
const startChunk = chunk;
|
|
5246
5296
|
while (chunk) {
|
|
5247
5297
|
if (chunk.intro && (startChunk !== chunk || chunk.start === start)) result += chunk.intro;
|
|
5248
5298
|
const containsEnd = chunk.start < end && chunk.end >= end;
|
|
5249
|
-
if (containsEnd && chunk.edited && chunk.end !== end) throw new
|
|
5299
|
+
if (containsEnd && chunk.edited && chunk.end !== end) throw new MagicStringError(`cannot use edited character ${end} as slice end anchor`);
|
|
5250
5300
|
const sliceStart = startChunk === chunk ? start - chunk.start : 0;
|
|
5251
5301
|
const sliceEnd = containsEnd ? chunk.content.length + end - chunk.end : chunk.content.length;
|
|
5252
5302
|
result += chunk.content.slice(sliceStart, sliceEnd);
|
|
@@ -5282,7 +5332,7 @@ var MagicString = class MagicString {
|
|
|
5282
5332
|
_splitChunk(chunk, index) {
|
|
5283
5333
|
if (chunk.edited && chunk.content.length) {
|
|
5284
5334
|
const loc = getLocator(this.original)(index);
|
|
5285
|
-
throw new
|
|
5335
|
+
throw new MagicStringError(`cannot split a chunk that has already been edited (${loc.line}:${loc.column} – "${chunk.original}")`);
|
|
5286
5336
|
}
|
|
5287
5337
|
const newChunk = chunk.split(index);
|
|
5288
5338
|
this.byEnd.set(index, chunk);
|
|
@@ -5394,7 +5444,19 @@ var MagicString = class MagicString {
|
|
|
5394
5444
|
* Indicates if the string has been changed.
|
|
5395
5445
|
*/
|
|
5396
5446
|
hasChanged() {
|
|
5397
|
-
|
|
5447
|
+
if (this.intro || this.outro) return true;
|
|
5448
|
+
let outputIndex = 0;
|
|
5449
|
+
let chunk = this.firstChunk;
|
|
5450
|
+
while (chunk) {
|
|
5451
|
+
if (chunk.intro || chunk.outro) return true;
|
|
5452
|
+
if (!chunk.edited && chunk.start === outputIndex) outputIndex = chunk.end;
|
|
5453
|
+
else {
|
|
5454
|
+
if (!this.original.startsWith(chunk.content, outputIndex)) return true;
|
|
5455
|
+
outputIndex += chunk.content.length;
|
|
5456
|
+
}
|
|
5457
|
+
chunk = chunk.next;
|
|
5458
|
+
}
|
|
5459
|
+
return outputIndex !== this.original.length;
|
|
5398
5460
|
}
|
|
5399
5461
|
/** @internal */
|
|
5400
5462
|
_replaceRegexp(searchValue, replacement) {
|
|
@@ -5464,7 +5526,7 @@ var MagicString = class MagicString {
|
|
|
5464
5526
|
*/
|
|
5465
5527
|
replaceAll(searchValue, replacement) {
|
|
5466
5528
|
if (typeof searchValue === "string") return this._replaceAllString(searchValue, replacement);
|
|
5467
|
-
if (!searchValue.global) throw new
|
|
5529
|
+
if (!searchValue.global) throw new MagicStringError("replaceAll() requires a global RegExp");
|
|
5468
5530
|
return this._replaceRegexp(searchValue, replacement);
|
|
5469
5531
|
}
|
|
5470
5532
|
};
|
|
@@ -5495,7 +5557,7 @@ var Bundle$1 = class Bundle {
|
|
|
5495
5557
|
filename: source.filename,
|
|
5496
5558
|
separator: this.separator
|
|
5497
5559
|
});
|
|
5498
|
-
if (!isObject(source) || !source.content) throw new
|
|
5560
|
+
if (!isObject(source) || !source.content) throw new MagicStringError("addSource() requires a `content` property that is a MagicString");
|
|
5499
5561
|
[
|
|
5500
5562
|
"filename",
|
|
5501
5563
|
"ignoreList",
|
|
@@ -5513,7 +5575,7 @@ var Bundle$1 = class Bundle {
|
|
|
5513
5575
|
});
|
|
5514
5576
|
} else {
|
|
5515
5577
|
const uniqueSource = this.uniqueSources[this.uniqueSourceIndexByFilename[source.filename]];
|
|
5516
|
-
if (source.content.original !== uniqueSource.content) throw new
|
|
5578
|
+
if (source.content.original !== uniqueSource.content) throw new MagicStringError(`duplicate filename "${source.filename}" with different content, use unique filenames`);
|
|
5517
5579
|
}
|
|
5518
5580
|
this.sources.push(source);
|
|
5519
5581
|
return this;
|
|
@@ -5534,6 +5596,8 @@ var Bundle$1 = class Bundle {
|
|
|
5534
5596
|
bundle.addSource({
|
|
5535
5597
|
filename: source.filename,
|
|
5536
5598
|
content: source.content.clone(),
|
|
5599
|
+
ignoreList: source.ignoreList,
|
|
5600
|
+
indentExclusionRanges: source.indentExclusionRanges,
|
|
5537
5601
|
separator: source.separator
|
|
5538
5602
|
});
|
|
5539
5603
|
});
|
|
@@ -5550,7 +5614,7 @@ var Bundle$1 = class Bundle {
|
|
|
5550
5614
|
const mappings = new Mappings(options.hires);
|
|
5551
5615
|
if (this.intro) mappings.advance(this.intro);
|
|
5552
5616
|
this.sources.forEach((source, i) => {
|
|
5553
|
-
if (i > 0) mappings.advance(this.separator);
|
|
5617
|
+
if (i > 0) mappings.advance(source.separator !== void 0 ? source.separator : this.separator);
|
|
5554
5618
|
const sourceIndex = source.filename ? this.uniqueSourceIndexByFilename[source.filename] : -1;
|
|
5555
5619
|
const magicString = source.content;
|
|
5556
5620
|
const locate = getLocator(magicString.original);
|
|
@@ -5628,11 +5692,17 @@ var Bundle$1 = class Bundle {
|
|
|
5628
5692
|
}
|
|
5629
5693
|
isEmpty() {
|
|
5630
5694
|
if (this.intro.length && this.intro.trim()) return false;
|
|
5631
|
-
if (this.sources.some((source) =>
|
|
5695
|
+
if (this.sources.some((source, i) => {
|
|
5696
|
+
const separator = source.separator !== void 0 ? source.separator : this.separator;
|
|
5697
|
+
return i > 0 && separator.trim() !== "" || !source.content.isEmpty();
|
|
5698
|
+
})) return false;
|
|
5632
5699
|
return true;
|
|
5633
5700
|
}
|
|
5634
5701
|
length() {
|
|
5635
|
-
return this.sources.reduce((length, source) =>
|
|
5702
|
+
return this.sources.reduce((length, source, i) => {
|
|
5703
|
+
const separator = source.separator !== void 0 ? source.separator : this.separator;
|
|
5704
|
+
return length + (i > 0 ? separator.length : 0) + source.content.length();
|
|
5705
|
+
}, this.intro.length);
|
|
5636
5706
|
}
|
|
5637
5707
|
trimLines() {
|
|
5638
5708
|
return this.trim("[\\r\\n]");
|
|
@@ -20795,7 +20865,6 @@ class Chunk {
|
|
|
20795
20865
|
const usedModules = [];
|
|
20796
20866
|
let hoistedSource = '';
|
|
20797
20867
|
const accessedGlobals = new Set();
|
|
20798
|
-
const renderedModuleSources = new Map();
|
|
20799
20868
|
const renderOptions = {
|
|
20800
20869
|
accessedDocumentCurrentScript: false,
|
|
20801
20870
|
exportNamesByVariable,
|
|
@@ -20825,7 +20894,6 @@ class Chunk {
|
|
|
20825
20894
|
if (renderedLength) {
|
|
20826
20895
|
if (compact && source.lastLine().includes('//'))
|
|
20827
20896
|
source.append('\n');
|
|
20828
|
-
renderedModuleSources.set(module, source);
|
|
20829
20897
|
magicString.addSource(source);
|
|
20830
20898
|
usedModules.push(module);
|
|
20831
20899
|
}
|
package/dist/shared/watch-cli.js
CHANGED
package/dist/shared/watch.js
CHANGED