rollup 4.63.2 → 4.63.3
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 +270 -88
- package/dist/es/shared/parseAst.js +4 -2
- package/dist/es/shared/watch.js +29 -19
- 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 +4 -2
- package/dist/shared/rollup.js +270 -88
- package/dist/shared/watch-cli.js +2 -2
- package/dist/shared/watch.js +29 -19
- package/package.json +26 -26
package/dist/shared/rollup.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
2
|
@license
|
|
3
|
-
Rollup.js v4.63.
|
|
4
|
-
|
|
3
|
+
Rollup.js v4.63.3
|
|
4
|
+
Mon, 14 Sep 2026 12:44:36 GMT - commit 250deca2945f8817350564f7d52bab0f79175d1b
|
|
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.63.
|
|
45
|
+
var version = "4.63.3";
|
|
46
46
|
const package_ = {
|
|
47
47
|
version: version};
|
|
48
48
|
|
|
@@ -4315,6 +4315,21 @@ var StringReader = class {
|
|
|
4315
4315
|
return idx === -1 ? buffer.length : idx;
|
|
4316
4316
|
}
|
|
4317
4317
|
};
|
|
4318
|
+
function encodeRangeMappings(decoded) {
|
|
4319
|
+
if (decoded.length === 0) return "";
|
|
4320
|
+
const writer = new StringWriter();
|
|
4321
|
+
for (let i = 0; i < decoded.length; i++) {
|
|
4322
|
+
const indices = decoded[i];
|
|
4323
|
+
if (i > 0) writer.write(semicolon);
|
|
4324
|
+
let index = 0;
|
|
4325
|
+
for (let j = 0; j < indices.length; j++) {
|
|
4326
|
+
const offset = indices[j];
|
|
4327
|
+
encodeInteger(writer, offset - index);
|
|
4328
|
+
index = offset;
|
|
4329
|
+
}
|
|
4330
|
+
}
|
|
4331
|
+
return writer.flush();
|
|
4332
|
+
}
|
|
4318
4333
|
|
|
4319
4334
|
// src/sourcemap-codec.ts
|
|
4320
4335
|
function decode(mappings) {
|
|
@@ -4509,8 +4524,10 @@ var Chunk$1 = class Chunk {
|
|
|
4509
4524
|
if (this.outro.length) return true;
|
|
4510
4525
|
const trimmed = this.content.replace(rx, "");
|
|
4511
4526
|
if (trimmed.length) {
|
|
4512
|
-
if (trimmed !== this.content)
|
|
4513
|
-
|
|
4527
|
+
if (trimmed !== this.content) {
|
|
4528
|
+
if (this.edited) this.edit(trimmed, this.storeName, true);
|
|
4529
|
+
else this.split(this.start + trimmed.length).edit("", void 0, true);
|
|
4530
|
+
}
|
|
4514
4531
|
return true;
|
|
4515
4532
|
} else {
|
|
4516
4533
|
this.edit("", void 0, true);
|
|
@@ -4523,10 +4540,12 @@ var Chunk$1 = class Chunk {
|
|
|
4523
4540
|
if (this.intro.length) return true;
|
|
4524
4541
|
const trimmed = this.content.replace(rx, "");
|
|
4525
4542
|
if (trimmed.length) {
|
|
4526
|
-
if (trimmed !== this.content)
|
|
4527
|
-
|
|
4528
|
-
|
|
4529
|
-
|
|
4543
|
+
if (trimmed !== this.content) {
|
|
4544
|
+
if (this.edited) this.edit(trimmed, this.storeName, true);
|
|
4545
|
+
else {
|
|
4546
|
+
this.split(this.end - trimmed.length);
|
|
4547
|
+
this.edit("", void 0, true);
|
|
4548
|
+
}
|
|
4530
4549
|
}
|
|
4531
4550
|
return true;
|
|
4532
4551
|
} else {
|
|
@@ -4553,12 +4572,14 @@ var MagicStringError = class extends Error {
|
|
|
4553
4572
|
//#endregion
|
|
4554
4573
|
//#region src/SourceMap.ts
|
|
4555
4574
|
function getBtoa() {
|
|
4575
|
+
/* v8 ignore next -- environment fallback, unreachable when `btoa` is present */
|
|
4556
4576
|
if (typeof globalThis !== "undefined" && typeof globalThis.btoa === "function") return (str) => globalThis.btoa(unescape(encodeURIComponent(str)));
|
|
4557
4577
|
const buffer = globalThis["Buffer"];
|
|
4558
4578
|
if (buffer) return (str) => buffer.from(str, "utf-8").toString("base64");
|
|
4559
4579
|
return () => {
|
|
4560
4580
|
throw new MagicStringError("unsupported environment: `btoa` or `Buffer` is required");
|
|
4561
4581
|
};
|
|
4582
|
+
/* v8 ignore stop */
|
|
4562
4583
|
}
|
|
4563
4584
|
const btoa = /* #__PURE__ */ getBtoa();
|
|
4564
4585
|
var SourceMap = class {
|
|
@@ -4571,6 +4592,14 @@ var SourceMap = class {
|
|
|
4571
4592
|
this.mappings = encode(properties.mappings);
|
|
4572
4593
|
if (typeof properties.x_google_ignoreList !== "undefined") this.x_google_ignoreList = properties.x_google_ignoreList;
|
|
4573
4594
|
if (typeof properties.debugId !== "undefined") this.debugId = properties.debugId;
|
|
4595
|
+
if (typeof properties.rangeMappings !== "undefined") {
|
|
4596
|
+
let shouldOutputRangeMapping = false;
|
|
4597
|
+
for (const line of properties.rangeMappings) if (line.length !== 0) {
|
|
4598
|
+
shouldOutputRangeMapping = true;
|
|
4599
|
+
break;
|
|
4600
|
+
}
|
|
4601
|
+
if (shouldOutputRangeMapping) this.rangeMappings = encodeRangeMappings(properties.rangeMappings);
|
|
4602
|
+
}
|
|
4574
4603
|
}
|
|
4575
4604
|
/**
|
|
4576
4605
|
* Returns the equivalent of `JSON.stringify(map)`
|
|
@@ -4589,12 +4618,8 @@ var SourceMap = class {
|
|
|
4589
4618
|
//#endregion
|
|
4590
4619
|
//#region src/utils/getLocator.ts
|
|
4591
4620
|
function getLocator(source) {
|
|
4592
|
-
const
|
|
4593
|
-
|
|
4594
|
-
for (let i = 0, pos = 0; i < originalLines.length; i++) {
|
|
4595
|
-
lineOffsets.push(pos);
|
|
4596
|
-
pos += originalLines[i].length + 1;
|
|
4597
|
-
}
|
|
4621
|
+
const lineOffsets = [0];
|
|
4622
|
+
for (let i = source.indexOf("\n"); i !== -1; i = source.indexOf("\n", i + 1)) lineOffsets.push(i + 1);
|
|
4598
4623
|
return function locate(index) {
|
|
4599
4624
|
let i = 0;
|
|
4600
4625
|
let j = lineOffsets.length;
|
|
@@ -4648,7 +4673,10 @@ function isObject(thing) {
|
|
|
4648
4673
|
}
|
|
4649
4674
|
//#endregion
|
|
4650
4675
|
//#region src/utils/Mappings.ts
|
|
4651
|
-
const
|
|
4676
|
+
const NEWLINE_CHAR$1 = 10;
|
|
4677
|
+
function isWordCode(code) {
|
|
4678
|
+
return code >= 97 && code <= 122 || code >= 65 && code <= 90 || code >= 48 && code <= 57 || code === 95;
|
|
4679
|
+
}
|
|
4652
4680
|
var Mappings = class {
|
|
4653
4681
|
constructor(hires) {
|
|
4654
4682
|
this.hires = hires;
|
|
@@ -4656,9 +4684,12 @@ var Mappings = class {
|
|
|
4656
4684
|
this.generatedCodeColumn = 0;
|
|
4657
4685
|
this.raw = [];
|
|
4658
4686
|
this.rawSegments = this.raw[this.generatedCodeLine] = [];
|
|
4687
|
+
this.rawRangeMappings = [];
|
|
4688
|
+
this.rawRangeMappingsIndices = this.rawRangeMappings[this.generatedCodeLine] = [];
|
|
4659
4689
|
this.pending = null;
|
|
4660
4690
|
}
|
|
4661
4691
|
addEdit(sourceIndex, content, loc, nameIndex) {
|
|
4692
|
+
/* v8 ignore else -- `pending` is never assigned a truthy value */
|
|
4662
4693
|
if (content.length) {
|
|
4663
4694
|
const contentLengthMinusOne = content.length - 1;
|
|
4664
4695
|
let contentLineEnd = content.indexOf("\n", 0);
|
|
@@ -4674,6 +4705,7 @@ var Mappings = class {
|
|
|
4674
4705
|
this.rawSegments.push(segment);
|
|
4675
4706
|
this.generatedCodeLine += 1;
|
|
4676
4707
|
this.raw[this.generatedCodeLine] = this.rawSegments = [];
|
|
4708
|
+
this.rawRangeMappings[this.generatedCodeLine] = this.rawRangeMappingsIndices = [];
|
|
4677
4709
|
this.generatedCodeColumn = 0;
|
|
4678
4710
|
previousContentLineEnd = contentLineEnd;
|
|
4679
4711
|
contentLineEnd = content.indexOf("\n", contentLineEnd + 1);
|
|
@@ -4694,56 +4726,128 @@ var Mappings = class {
|
|
|
4694
4726
|
this.pending = null;
|
|
4695
4727
|
}
|
|
4696
4728
|
addUneditedChunk(sourceIndex, chunk, original, loc, sourcemapLocations) {
|
|
4697
|
-
|
|
4698
|
-
let
|
|
4699
|
-
|
|
4700
|
-
|
|
4701
|
-
|
|
4702
|
-
|
|
4703
|
-
|
|
4704
|
-
|
|
4705
|
-
|
|
4706
|
-
|
|
4707
|
-
|
|
4708
|
-
|
|
4709
|
-
|
|
4710
|
-
|
|
4711
|
-
|
|
4729
|
+
const end = chunk.end;
|
|
4730
|
+
let i = chunk.start;
|
|
4731
|
+
if (this.hires) {
|
|
4732
|
+
const boundary = this.hires === "boundary";
|
|
4733
|
+
const experimentalRange = this.hires === "experimental-range";
|
|
4734
|
+
let charInHiresBoundary = false;
|
|
4735
|
+
while (i < end) {
|
|
4736
|
+
if (experimentalRange && i + 1 >= end) this.rawSegments.push([
|
|
4737
|
+
this.generatedCodeColumn,
|
|
4738
|
+
sourceIndex,
|
|
4739
|
+
loc.line,
|
|
4740
|
+
loc.column
|
|
4741
|
+
]);
|
|
4742
|
+
const code = original.charCodeAt(i);
|
|
4743
|
+
if (code === NEWLINE_CHAR$1) {
|
|
4744
|
+
loc.line += 1;
|
|
4745
|
+
loc.column = 0;
|
|
4746
|
+
this.generatedCodeLine += 1;
|
|
4747
|
+
this.raw[this.generatedCodeLine] = this.rawSegments = [];
|
|
4748
|
+
this.rawRangeMappings[this.generatedCodeLine] = this.rawRangeMappingsIndices = [];
|
|
4749
|
+
this.generatedCodeColumn = 0;
|
|
4750
|
+
charInHiresBoundary = false;
|
|
4751
|
+
} else {
|
|
4752
|
+
if (boundary) {
|
|
4753
|
+
if (isWordCode(code)) {
|
|
4754
|
+
if (!charInHiresBoundary) {
|
|
4755
|
+
this.rawSegments.push([
|
|
4756
|
+
this.generatedCodeColumn,
|
|
4757
|
+
sourceIndex,
|
|
4758
|
+
loc.line,
|
|
4759
|
+
loc.column
|
|
4760
|
+
]);
|
|
4761
|
+
charInHiresBoundary = true;
|
|
4762
|
+
}
|
|
4763
|
+
} else {
|
|
4764
|
+
this.rawSegments.push([
|
|
4765
|
+
this.generatedCodeColumn,
|
|
4766
|
+
sourceIndex,
|
|
4767
|
+
loc.line,
|
|
4768
|
+
loc.column
|
|
4769
|
+
]);
|
|
4770
|
+
charInHiresBoundary = false;
|
|
4771
|
+
}
|
|
4772
|
+
} else if (experimentalRange) {
|
|
4773
|
+
if (i === chunk.start) {
|
|
4774
|
+
this.rawRangeMappingsIndices.push(this.rawSegments.length);
|
|
4775
|
+
this.rawSegments.push([
|
|
4776
|
+
this.generatedCodeColumn,
|
|
4777
|
+
sourceIndex,
|
|
4778
|
+
loc.line,
|
|
4779
|
+
loc.column
|
|
4780
|
+
]);
|
|
4781
|
+
}
|
|
4782
|
+
} else this.rawSegments.push([
|
|
4783
|
+
this.generatedCodeColumn,
|
|
4784
|
+
sourceIndex,
|
|
4785
|
+
loc.line,
|
|
4786
|
+
loc.column
|
|
4787
|
+
]);
|
|
4788
|
+
loc.column += 1;
|
|
4789
|
+
this.generatedCodeColumn += 1;
|
|
4790
|
+
}
|
|
4791
|
+
i += 1;
|
|
4792
|
+
}
|
|
4793
|
+
} else {
|
|
4794
|
+
const bits = sourcemapLocations.bits;
|
|
4795
|
+
while (i < end) {
|
|
4796
|
+
let newline = original.indexOf("\n", i);
|
|
4797
|
+
if (newline === -1 || newline > end) newline = end;
|
|
4798
|
+
if (newline > i) {
|
|
4799
|
+
this.rawSegments.push([
|
|
4712
4800
|
this.generatedCodeColumn,
|
|
4713
4801
|
sourceIndex,
|
|
4714
4802
|
loc.line,
|
|
4715
4803
|
loc.column
|
|
4716
|
-
];
|
|
4717
|
-
|
|
4718
|
-
|
|
4719
|
-
|
|
4720
|
-
|
|
4804
|
+
]);
|
|
4805
|
+
for (let w = i + 1 >> 5, last = newline - 1 >> 5; w <= last; w++) {
|
|
4806
|
+
let word = bits[w];
|
|
4807
|
+
if (!word) continue;
|
|
4808
|
+
const base = w << 5;
|
|
4809
|
+
while (word) {
|
|
4810
|
+
const lowest = word & -word;
|
|
4811
|
+
const index = base + 31 - Math.clz32(lowest);
|
|
4812
|
+
if (index > i && index < newline) {
|
|
4813
|
+
const offset = index - i;
|
|
4814
|
+
this.rawSegments.push([
|
|
4815
|
+
this.generatedCodeColumn + offset,
|
|
4816
|
+
sourceIndex,
|
|
4817
|
+
loc.line,
|
|
4818
|
+
loc.column + offset
|
|
4819
|
+
]);
|
|
4820
|
+
}
|
|
4821
|
+
word ^= lowest;
|
|
4721
4822
|
}
|
|
4722
|
-
} else {
|
|
4723
|
-
this.rawSegments.push(segment);
|
|
4724
|
-
charInHiresBoundary = false;
|
|
4725
4823
|
}
|
|
4726
|
-
|
|
4824
|
+
loc.column += newline - i;
|
|
4825
|
+
this.generatedCodeColumn += newline - i;
|
|
4727
4826
|
}
|
|
4728
|
-
|
|
4729
|
-
|
|
4730
|
-
|
|
4827
|
+
if (newline === end) break;
|
|
4828
|
+
loc.line += 1;
|
|
4829
|
+
loc.column = 0;
|
|
4830
|
+
this.generatedCodeLine += 1;
|
|
4831
|
+
this.raw[this.generatedCodeLine] = this.rawSegments = [];
|
|
4832
|
+
this.rawRangeMappings[this.generatedCodeLine] = this.rawRangeMappingsIndices = [];
|
|
4833
|
+
this.generatedCodeColumn = 0;
|
|
4834
|
+
i = newline + 1;
|
|
4731
4835
|
}
|
|
4732
|
-
originalCharIndex += 1;
|
|
4733
4836
|
}
|
|
4734
4837
|
this.pending = null;
|
|
4735
4838
|
}
|
|
4736
4839
|
advance(str) {
|
|
4737
4840
|
if (!str) return;
|
|
4738
|
-
const
|
|
4739
|
-
if (
|
|
4740
|
-
for (let i =
|
|
4841
|
+
const lastNewline = str.lastIndexOf("\n");
|
|
4842
|
+
if (lastNewline !== -1) {
|
|
4843
|
+
for (let i = str.indexOf("\n"); i !== -1; i = str.indexOf("\n", i + 1)) {
|
|
4741
4844
|
this.generatedCodeLine++;
|
|
4742
4845
|
this.raw[this.generatedCodeLine] = this.rawSegments = [];
|
|
4846
|
+
this.rawRangeMappings[this.generatedCodeLine] = this.rawRangeMappingsIndices = [];
|
|
4743
4847
|
}
|
|
4744
4848
|
this.generatedCodeColumn = 0;
|
|
4745
4849
|
}
|
|
4746
|
-
this.generatedCodeColumn +=
|
|
4850
|
+
this.generatedCodeColumn += str.length - lastNewline - 1;
|
|
4747
4851
|
}
|
|
4748
4852
|
};
|
|
4749
4853
|
//#endregion
|
|
@@ -4756,6 +4860,63 @@ const warned = {
|
|
|
4756
4860
|
insertRight: false,
|
|
4757
4861
|
storeName: false
|
|
4758
4862
|
};
|
|
4863
|
+
/**
|
|
4864
|
+
* Expands the `$` substitution patterns that `String.prototype.replace` accepts
|
|
4865
|
+
* in a string replacement.
|
|
4866
|
+
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace#specifying_a_string_as_a_parameter
|
|
4867
|
+
*
|
|
4868
|
+
* `captures` holds the capture groups in order, so `captures[0]` is `$1`.
|
|
4869
|
+
* `namedCaptures` is `undefined` when the pattern has no named groups, and
|
|
4870
|
+
* `$<name>` is then literal text - which is also the case for a string search
|
|
4871
|
+
* value, where there are no groups of either kind.
|
|
4872
|
+
*/
|
|
4873
|
+
function expandReplacement(replacement, matched, position, str, captures, namedCaptures) {
|
|
4874
|
+
if (!replacement.includes("$")) return replacement;
|
|
4875
|
+
let result = "";
|
|
4876
|
+
let index = 0;
|
|
4877
|
+
while (index < replacement.length) {
|
|
4878
|
+
const dollar = replacement.indexOf("$", index);
|
|
4879
|
+
if (dollar === -1) {
|
|
4880
|
+
result += replacement.slice(index);
|
|
4881
|
+
break;
|
|
4882
|
+
}
|
|
4883
|
+
result += replacement.slice(index, dollar);
|
|
4884
|
+
const char = replacement[dollar + 1];
|
|
4885
|
+
let expansion = "$";
|
|
4886
|
+
let consumed = 1;
|
|
4887
|
+
if (char === "$") consumed = 2;
|
|
4888
|
+
else if (char === "&") {
|
|
4889
|
+
expansion = matched;
|
|
4890
|
+
consumed = 2;
|
|
4891
|
+
} else if (char === "`") {
|
|
4892
|
+
expansion = str.slice(0, position);
|
|
4893
|
+
consumed = 2;
|
|
4894
|
+
} else if (char === "'") {
|
|
4895
|
+
expansion = str.slice(position + matched.length);
|
|
4896
|
+
consumed = 2;
|
|
4897
|
+
} else if (char === "<" && namedCaptures !== void 0) {
|
|
4898
|
+
const close = replacement.indexOf(">", dollar + 2);
|
|
4899
|
+
if (close !== -1) {
|
|
4900
|
+
expansion = namedCaptures[replacement.slice(dollar + 2, close)] ?? "";
|
|
4901
|
+
consumed = close + 1 - dollar;
|
|
4902
|
+
}
|
|
4903
|
+
} else if (char >= "0" && char <= "9") {
|
|
4904
|
+
const second = replacement[dollar + 2];
|
|
4905
|
+
const double = second >= "0" && second <= "9" ? Number(char + second) : NaN;
|
|
4906
|
+
const single = Number(char);
|
|
4907
|
+
if (double >= 1 && double <= captures.length) {
|
|
4908
|
+
expansion = captures[double - 1] ?? "";
|
|
4909
|
+
consumed = 3;
|
|
4910
|
+
} else if (single >= 1 && single <= captures.length) {
|
|
4911
|
+
expansion = captures[single - 1] ?? "";
|
|
4912
|
+
consumed = 2;
|
|
4913
|
+
}
|
|
4914
|
+
}
|
|
4915
|
+
result += expansion;
|
|
4916
|
+
index = dollar + consumed;
|
|
4917
|
+
}
|
|
4918
|
+
return result;
|
|
4919
|
+
}
|
|
4759
4920
|
var MagicString = class MagicString {
|
|
4760
4921
|
constructor(string, options = {}) {
|
|
4761
4922
|
const chunk = new Chunk$1(0, string.length, string);
|
|
@@ -4925,7 +5086,8 @@ var MagicString = class MagicString {
|
|
|
4925
5086
|
sourcesContent: options.includeContent ? [this.original] : void 0,
|
|
4926
5087
|
names,
|
|
4927
5088
|
mappings: mappings.raw,
|
|
4928
|
-
x_google_ignoreList: this.ignoreList ? [sourceIndex] : void 0
|
|
5089
|
+
x_google_ignoreList: this.ignoreList ? [sourceIndex] : void 0,
|
|
5090
|
+
rangeMappings: mappings.rawRangeMappings
|
|
4929
5091
|
};
|
|
4930
5092
|
}
|
|
4931
5093
|
/**
|
|
@@ -4965,17 +5127,18 @@ var MagicString = class MagicString {
|
|
|
4965
5127
|
for (let i = exclusion[0]; i < exclusion[1]; i += 1) isExcluded[i] = true;
|
|
4966
5128
|
});
|
|
4967
5129
|
let shouldIndentNextCharacter = options.indentStart !== false;
|
|
4968
|
-
const
|
|
4969
|
-
if (
|
|
4970
|
-
|
|
4971
|
-
|
|
5130
|
+
const indentPiece = (str) => {
|
|
5131
|
+
if (str === "") return str;
|
|
5132
|
+
const indented = str.replace(pattern, (match, offset) => offset > 0 || shouldIndentNextCharacter ? `${resolvedIndentStr}${match}` : match);
|
|
5133
|
+
shouldIndentNextCharacter = str[str.length - 1] === "\n";
|
|
5134
|
+
return indented;
|
|
4972
5135
|
};
|
|
4973
|
-
this.intro = this.intro
|
|
5136
|
+
this.intro = indentPiece(this.intro);
|
|
4974
5137
|
let charIndex = 0;
|
|
4975
5138
|
let chunk = this.firstChunk;
|
|
4976
5139
|
const indentAt = (index) => {
|
|
4977
5140
|
shouldIndentNextCharacter = false;
|
|
4978
|
-
if (index === chunk.start) chunk.
|
|
5141
|
+
if (index === chunk.start) chunk.appendRight(resolvedIndentStr);
|
|
4979
5142
|
else {
|
|
4980
5143
|
this._splitChunk(chunk, index);
|
|
4981
5144
|
chunk = chunk.next;
|
|
@@ -4984,11 +5147,9 @@ var MagicString = class MagicString {
|
|
|
4984
5147
|
};
|
|
4985
5148
|
while (chunk) {
|
|
4986
5149
|
const end = chunk.end;
|
|
5150
|
+
if (!isExcluded[chunk.start]) chunk.intro = indentPiece(chunk.intro);
|
|
4987
5151
|
if (chunk.edited) {
|
|
4988
|
-
if (!isExcluded[charIndex])
|
|
4989
|
-
chunk.content = chunk.content.replace(pattern, replacer);
|
|
4990
|
-
if (chunk.content.length) shouldIndentNextCharacter = chunk.content[chunk.content.length - 1] === "\n";
|
|
4991
|
-
}
|
|
5152
|
+
if (!isExcluded[charIndex]) chunk.content = indentPiece(chunk.content);
|
|
4992
5153
|
} else if (options.exclude) {
|
|
4993
5154
|
charIndex = chunk.start;
|
|
4994
5155
|
while (charIndex < end) {
|
|
@@ -5018,10 +5179,11 @@ var MagicString = class MagicString {
|
|
|
5018
5179
|
charIndex += 1;
|
|
5019
5180
|
}
|
|
5020
5181
|
}
|
|
5182
|
+
if (!isExcluded[chunk.end - 1]) chunk.outro = indentPiece(chunk.outro);
|
|
5021
5183
|
charIndex = chunk.end;
|
|
5022
5184
|
chunk = chunk.next;
|
|
5023
5185
|
}
|
|
5024
|
-
this.outro = this.outro
|
|
5186
|
+
this.outro = indentPiece(this.outro);
|
|
5025
5187
|
return this;
|
|
5026
5188
|
}
|
|
5027
5189
|
/** @internal */
|
|
@@ -5144,6 +5306,7 @@ var MagicString = class MagicString {
|
|
|
5144
5306
|
}
|
|
5145
5307
|
const first = this.byStart.get(start);
|
|
5146
5308
|
const last = this.byEnd.get(end);
|
|
5309
|
+
/* v8 ignore else -- unreachable: a valid start/end always yields a `first` chunk */
|
|
5147
5310
|
if (first) {
|
|
5148
5311
|
let chunk = first;
|
|
5149
5312
|
while (chunk !== last) {
|
|
@@ -5361,11 +5524,13 @@ var MagicString = class MagicString {
|
|
|
5361
5524
|
* Returns true if the resulting source is empty (disregarding white space).
|
|
5362
5525
|
*/
|
|
5363
5526
|
isEmpty() {
|
|
5527
|
+
if (this.intro.length && this.intro.trim()) return false;
|
|
5364
5528
|
let chunk = this.firstChunk;
|
|
5365
5529
|
while (chunk) {
|
|
5366
5530
|
if (chunk.intro.length && chunk.intro.trim() || chunk.content.length && chunk.content.trim() || chunk.outro.length && chunk.outro.trim()) return false;
|
|
5367
5531
|
chunk = chunk.next;
|
|
5368
5532
|
}
|
|
5533
|
+
if (this.outro.length && this.outro.trim()) return false;
|
|
5369
5534
|
return true;
|
|
5370
5535
|
}
|
|
5371
5536
|
length() {
|
|
@@ -5464,15 +5629,11 @@ var MagicString = class MagicString {
|
|
|
5464
5629
|
/** @internal */
|
|
5465
5630
|
_replaceRegexp(searchValue, replacement) {
|
|
5466
5631
|
function getReplacement(match, str) {
|
|
5467
|
-
if (typeof replacement === "string") return replacement.
|
|
5468
|
-
|
|
5469
|
-
if (i === "&") return match[0];
|
|
5470
|
-
if (+i < match.length) return match[+i];
|
|
5471
|
-
return `$${i}`;
|
|
5472
|
-
});
|
|
5473
|
-
else return replacement(match[0], ...match.slice(1), match.index, str, match.groups);
|
|
5632
|
+
if (typeof replacement === "string") return expandReplacement(replacement, match[0], match.index, str, match.slice(1), match.groups);
|
|
5633
|
+
else return match.groups === void 0 ? replacement(match[0], ...match.slice(1), match.index, str) : replacement(match[0], ...match.slice(1), match.index, str, match.groups);
|
|
5474
5634
|
}
|
|
5475
5635
|
const replaceMatch = (match) => {
|
|
5636
|
+
/* v8 ignore next 2 -- `match.index` is always defined for matches from `matchAll` */
|
|
5476
5637
|
if (match.index == null) return;
|
|
5477
5638
|
const replacement = getReplacement(match, this.original);
|
|
5478
5639
|
if (replacement === match[0]) return;
|
|
@@ -5494,8 +5655,11 @@ var MagicString = class MagicString {
|
|
|
5494
5655
|
const index = original.indexOf(string);
|
|
5495
5656
|
if (index !== -1) {
|
|
5496
5657
|
if (typeof replacement === "function") replacement = replacement(string, index, original);
|
|
5497
|
-
|
|
5498
|
-
|
|
5658
|
+
else replacement = expandReplacement(replacement, string, index, original, [], void 0);
|
|
5659
|
+
if (string !== replacement) {
|
|
5660
|
+
if (string.length === 0) this.appendRight(index, replacement);
|
|
5661
|
+
else this.overwrite(index, index + string.length, replacement);
|
|
5662
|
+
}
|
|
5499
5663
|
}
|
|
5500
5664
|
return this;
|
|
5501
5665
|
}
|
|
@@ -5512,14 +5676,14 @@ var MagicString = class MagicString {
|
|
|
5512
5676
|
const stringLength = string.length;
|
|
5513
5677
|
if (stringLength === 0) {
|
|
5514
5678
|
for (let index = 0; index <= original.length; index += 1) {
|
|
5515
|
-
const _replacement = typeof replacement === "function" ? replacement("", index, original) : replacement;
|
|
5679
|
+
const _replacement = typeof replacement === "function" ? replacement("", index, original) : expandReplacement(replacement, "", index, original, [], void 0);
|
|
5516
5680
|
if (_replacement !== "") this.appendRight(index, _replacement);
|
|
5517
5681
|
}
|
|
5518
5682
|
return this;
|
|
5519
5683
|
}
|
|
5520
5684
|
for (let index = original.indexOf(string); index !== -1; index = original.indexOf(string, index + stringLength)) {
|
|
5521
5685
|
const previous = original.slice(index, index + stringLength);
|
|
5522
|
-
const _replacement = typeof replacement === "function" ? replacement(previous, index, original) : replacement;
|
|
5686
|
+
const _replacement = typeof replacement === "function" ? replacement(previous, index, original) : expandReplacement(replacement, previous, index, original, [], void 0);
|
|
5523
5687
|
if (previous !== _replacement) this.overwrite(index, index + stringLength, _replacement);
|
|
5524
5688
|
}
|
|
5525
5689
|
return this;
|
|
@@ -5570,15 +5734,17 @@ var Bundle$1 = class Bundle {
|
|
|
5570
5734
|
if (!hasOwnProp.call(source, option)) source[option] = source.content[option];
|
|
5571
5735
|
});
|
|
5572
5736
|
if (source.separator === void 0) source.separator = this.separator;
|
|
5573
|
-
if (source.filename)
|
|
5574
|
-
this.uniqueSourceIndexByFilename
|
|
5575
|
-
|
|
5576
|
-
|
|
5577
|
-
|
|
5578
|
-
|
|
5579
|
-
|
|
5580
|
-
|
|
5581
|
-
|
|
5737
|
+
if (source.filename) {
|
|
5738
|
+
if (!hasOwnProp.call(this.uniqueSourceIndexByFilename, source.filename)) {
|
|
5739
|
+
this.uniqueSourceIndexByFilename[source.filename] = this.uniqueSources.length;
|
|
5740
|
+
this.uniqueSources.push({
|
|
5741
|
+
filename: source.filename,
|
|
5742
|
+
content: source.content.original
|
|
5743
|
+
});
|
|
5744
|
+
} else {
|
|
5745
|
+
const uniqueSource = this.uniqueSources[this.uniqueSourceIndexByFilename[source.filename]];
|
|
5746
|
+
if (source.content.original !== uniqueSource.content) throw new MagicStringError(`duplicate filename "${source.filename}" with different content, use unique filenames`);
|
|
5747
|
+
}
|
|
5582
5748
|
}
|
|
5583
5749
|
this.sources.push(source);
|
|
5584
5750
|
return this;
|
|
@@ -5617,7 +5783,9 @@ var Bundle$1 = class Bundle {
|
|
|
5617
5783
|
const mappings = new Mappings(options.hires);
|
|
5618
5784
|
if (this.intro) mappings.advance(this.intro);
|
|
5619
5785
|
this.sources.forEach((source, i) => {
|
|
5620
|
-
if (i > 0)
|
|
5786
|
+
if (i > 0)
|
|
5787
|
+
/* v8 ignore next -- addSource always normalizes source.separator */
|
|
5788
|
+
mappings.advance(source.separator !== void 0 ? source.separator : this.separator);
|
|
5621
5789
|
const sourceIndex = source.filename ? this.uniqueSourceIndexByFilename[source.filename] : -1;
|
|
5622
5790
|
const magicString = source.content;
|
|
5623
5791
|
const locate = getLocator(magicString.original);
|
|
@@ -5625,9 +5793,10 @@ var Bundle$1 = class Bundle {
|
|
|
5625
5793
|
magicString.firstChunk.eachNext((chunk) => {
|
|
5626
5794
|
const loc = locate(chunk.start);
|
|
5627
5795
|
if (chunk.intro.length) mappings.advance(chunk.intro);
|
|
5628
|
-
if (source.filename)
|
|
5629
|
-
|
|
5630
|
-
|
|
5796
|
+
if (source.filename) {
|
|
5797
|
+
if (chunk.edited) mappings.addEdit(sourceIndex, chunk.content, loc, chunk.storeName ? names.indexOf(chunk.original) : -1);
|
|
5798
|
+
else mappings.addUneditedChunk(sourceIndex, chunk, magicString.original, loc, magicString.sourcemapLocations);
|
|
5799
|
+
} else mappings.advance(chunk.content);
|
|
5631
5800
|
if (chunk.outro.length) mappings.advance(chunk.outro);
|
|
5632
5801
|
});
|
|
5633
5802
|
if (magicString.outro) mappings.advance(magicString.outro);
|
|
@@ -5642,11 +5811,12 @@ var Bundle$1 = class Bundle {
|
|
|
5642
5811
|
return options.file ? getRelativePath(options.file, source.filename) : source.filename;
|
|
5643
5812
|
}),
|
|
5644
5813
|
sourcesContent: this.uniqueSources.map((source) => {
|
|
5645
|
-
return options.includeContent ? source.content : null;
|
|
5814
|
+
return (typeof options.includeContent === "function" ? options.includeContent(source) : options.includeContent) ? source.content : null;
|
|
5646
5815
|
}),
|
|
5647
5816
|
names,
|
|
5648
5817
|
mappings: mappings.raw,
|
|
5649
|
-
x_google_ignoreList
|
|
5818
|
+
x_google_ignoreList,
|
|
5819
|
+
rangeMappings: mappings.rawRangeMappings
|
|
5650
5820
|
};
|
|
5651
5821
|
}
|
|
5652
5822
|
generateMap(options) {
|
|
@@ -5669,6 +5839,7 @@ var Bundle$1 = class Bundle {
|
|
|
5669
5839
|
if (indentStr === "") return this;
|
|
5670
5840
|
let trailingNewline = !this.intro || this.intro.slice(-1) === "\n";
|
|
5671
5841
|
this.sources.forEach((source, i) => {
|
|
5842
|
+
/* v8 ignore next -- addSource always normalizes source.separator */
|
|
5672
5843
|
const separator = source.separator !== void 0 ? source.separator : this.separator;
|
|
5673
5844
|
const indentStart = trailingNewline || i > 0 && /\r?\n$/.test(separator);
|
|
5674
5845
|
source.content.indent(indentStr, {
|
|
@@ -5688,6 +5859,7 @@ var Bundle$1 = class Bundle {
|
|
|
5688
5859
|
}
|
|
5689
5860
|
toString() {
|
|
5690
5861
|
const body = this.sources.map((source, i) => {
|
|
5862
|
+
/* v8 ignore next -- addSource always normalizes source.separator */
|
|
5691
5863
|
const separator = source.separator !== void 0 ? source.separator : this.separator;
|
|
5692
5864
|
return (i > 0 ? separator : "") + source.content.toString();
|
|
5693
5865
|
}).join("");
|
|
@@ -5696,6 +5868,7 @@ var Bundle$1 = class Bundle {
|
|
|
5696
5868
|
isEmpty() {
|
|
5697
5869
|
if (this.intro.length && this.intro.trim()) return false;
|
|
5698
5870
|
if (this.sources.some((source, i) => {
|
|
5871
|
+
/* v8 ignore next -- addSource always normalizes source.separator */
|
|
5699
5872
|
const separator = source.separator !== void 0 ? source.separator : this.separator;
|
|
5700
5873
|
return i > 0 && separator.trim() !== "" || !source.content.isEmpty();
|
|
5701
5874
|
})) return false;
|
|
@@ -5703,8 +5876,9 @@ var Bundle$1 = class Bundle {
|
|
|
5703
5876
|
}
|
|
5704
5877
|
length() {
|
|
5705
5878
|
return this.sources.reduce((length, source, i) => {
|
|
5879
|
+
/* v8 ignore next -- addSource always normalizes source.separator */
|
|
5706
5880
|
const separator = source.separator !== void 0 ? source.separator : this.separator;
|
|
5707
|
-
return length + (i > 0 ? separator.length : 0) + source.content.
|
|
5881
|
+
return length + (i > 0 ? separator.length : 0) + source.content.toString().length;
|
|
5708
5882
|
}, this.intro.length);
|
|
5709
5883
|
}
|
|
5710
5884
|
trimLines() {
|
|
@@ -5787,6 +5961,14 @@ function findLastWhiteSpaceReverse(code, start, end) {
|
|
|
5787
5961
|
}
|
|
5788
5962
|
}
|
|
5789
5963
|
}
|
|
5964
|
+
// A CRLF pair is one line break and must be removed as one. Removing only the
|
|
5965
|
+
// LF leaves the CR, which is still a line terminator, so ASI fires anyway and
|
|
5966
|
+
// the operand after a `return` or `throw` becomes dead code.
|
|
5967
|
+
function getLineBreakStart(code, lineBreakPos) {
|
|
5968
|
+
return lineBreakPos > 0 && code.charCodeAt(lineBreakPos - 1) === 13 /*"\r"*/
|
|
5969
|
+
? lineBreakPos - 1
|
|
5970
|
+
: lineBreakPos;
|
|
5971
|
+
}
|
|
5790
5972
|
// This assumes "code" only contains white-space and comments
|
|
5791
5973
|
// Returns position of line-comment if applicable
|
|
5792
5974
|
function findFirstLineBreakOutsideComment(code) {
|
|
@@ -5795,7 +5977,7 @@ function findFirstLineBreakOutsideComment(code) {
|
|
|
5795
5977
|
while (true) {
|
|
5796
5978
|
start = code.indexOf('/', start);
|
|
5797
5979
|
if (start === -1 || start > lineBreakPos)
|
|
5798
|
-
return [lineBreakPos, lineBreakPos + 1];
|
|
5980
|
+
return [getLineBreakStart(code, lineBreakPos), lineBreakPos + 1];
|
|
5799
5981
|
// With our assumption, '/' always starts a comment. Determine comment type:
|
|
5800
5982
|
charCodeAfterSlash = code.charCodeAt(start + 1);
|
|
5801
5983
|
if (charCodeAfterSlash === 47 /*"/"*/)
|
package/dist/shared/watch-cli.js
CHANGED