@rollup/wasm-node 4.63.3 → 4.63.4
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 +351 -81
- 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/native.js +3 -0
- 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 +351 -81
- package/dist/shared/watch-cli.js +2 -2
- package/dist/shared/watch.js +2 -2
- package/dist/wasm-node/bindings_wasm_bg.wasm +0 -0
- package/package.json +5 -5
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.4
|
|
4
|
+
Sat, 19 Sep 2026 06:35:38 GMT - commit ba78d5752a1e1ff4ff4af3a8bffab7691d822f7d
|
|
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.4";
|
|
46
46
|
const package_ = {
|
|
47
47
|
version: version};
|
|
48
48
|
|
|
@@ -3805,7 +3805,7 @@ class PluginDriver {
|
|
|
3805
3805
|
/**
|
|
3806
3806
|
* Run a sync plugin hook and return the result.
|
|
3807
3807
|
* @param hookName Name of the plugin hook. Must be in `PluginHooks`.
|
|
3808
|
-
* @param
|
|
3808
|
+
* @param parameters Arguments passed to the plugin hook.
|
|
3809
3809
|
* @param plugin The actual plugin
|
|
3810
3810
|
* @param replaceContext When passed, the plugin context can be overridden.
|
|
3811
3811
|
*/
|
|
@@ -4225,11 +4225,11 @@ function handleError(error, recover = false) {
|
|
|
4225
4225
|
var comma = ",".charCodeAt(0);
|
|
4226
4226
|
var semicolon = ";".charCodeAt(0);
|
|
4227
4227
|
var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
4228
|
-
var intToChar = new Uint8Array(64);
|
|
4228
|
+
var intToChar$1 = new Uint8Array(64);
|
|
4229
4229
|
var charToInt = new Uint8Array(128);
|
|
4230
4230
|
for (let i = 0; i < chars.length; i++) {
|
|
4231
4231
|
const c = chars.charCodeAt(i);
|
|
4232
|
-
intToChar[i] = c;
|
|
4232
|
+
intToChar$1[i] = c;
|
|
4233
4233
|
charToInt[c] = i;
|
|
4234
4234
|
}
|
|
4235
4235
|
function decodeInteger(reader) {
|
|
@@ -4252,7 +4252,7 @@ function encodeInteger(builder, num) {
|
|
|
4252
4252
|
let clamped = num & 31;
|
|
4253
4253
|
num >>>= 5;
|
|
4254
4254
|
if (num > 0) clamped |= 32;
|
|
4255
|
-
builder.write(intToChar[clamped]);
|
|
4255
|
+
builder.write(intToChar$1[clamped]);
|
|
4256
4256
|
} while (num > 0);
|
|
4257
4257
|
}
|
|
4258
4258
|
function encodeSign(num) {
|
|
@@ -4589,7 +4589,7 @@ var SourceMap = class {
|
|
|
4589
4589
|
this.sources = properties.sources;
|
|
4590
4590
|
this.sourcesContent = properties.sourcesContent;
|
|
4591
4591
|
this.names = properties.names;
|
|
4592
|
-
this.mappings = encode(properties.mappings);
|
|
4592
|
+
this.mappings = typeof properties.mappings === "string" ? properties.mappings : encode(properties.mappings);
|
|
4593
4593
|
if (typeof properties.x_google_ignoreList !== "undefined") this.x_google_ignoreList = properties.x_google_ignoreList;
|
|
4594
4594
|
if (typeof properties.debugId !== "undefined") this.debugId = properties.debugId;
|
|
4595
4595
|
if (typeof properties.rangeMappings !== "undefined") {
|
|
@@ -4671,6 +4671,94 @@ const toString = Object.prototype.toString;
|
|
|
4671
4671
|
function isObject(thing) {
|
|
4672
4672
|
return toString.call(thing) === "[object Object]";
|
|
4673
4673
|
}
|
|
4674
|
+
const BASE64_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
4675
|
+
const intToChar = /* #__PURE__ */ (() => {
|
|
4676
|
+
const chars = /* @__PURE__ */ new Uint8Array(64);
|
|
4677
|
+
for (let i = 0; i < 64; i++) chars[i] = BASE64_CHARS.charCodeAt(i);
|
|
4678
|
+
return chars;
|
|
4679
|
+
})();
|
|
4680
|
+
const COMMA = 44;
|
|
4681
|
+
const SEMICOLON = 59;
|
|
4682
|
+
const BUFFER_SIZE = 16384;
|
|
4683
|
+
const FLUSH_THRESHOLD = 16348;
|
|
4684
|
+
const scratch = /* #__PURE__ */ new Uint8Array(BUFFER_SIZE);
|
|
4685
|
+
function writeVlq(pos, num) {
|
|
4686
|
+
num = num < 0 ? -num << 1 | 1 : num << 1;
|
|
4687
|
+
do {
|
|
4688
|
+
let clamped = num & 31;
|
|
4689
|
+
num >>>= 5;
|
|
4690
|
+
if (num > 0) clamped |= 32;
|
|
4691
|
+
scratch[pos++] = intToChar[clamped];
|
|
4692
|
+
} while (num > 0);
|
|
4693
|
+
return pos;
|
|
4694
|
+
}
|
|
4695
|
+
const decoder = /* #__PURE__ */ new TextDecoder();
|
|
4696
|
+
var MappingsEncoder = class {
|
|
4697
|
+
constructor() {
|
|
4698
|
+
this.out = "";
|
|
4699
|
+
this.pos = 0;
|
|
4700
|
+
this.lines = [];
|
|
4701
|
+
this.buffered = 0;
|
|
4702
|
+
this.needsComma = false;
|
|
4703
|
+
this.prevGenColumn = 0;
|
|
4704
|
+
this.prevSourceIndex = 0;
|
|
4705
|
+
this.prevSourceLine = 0;
|
|
4706
|
+
this.prevSourceColumn = 0;
|
|
4707
|
+
this.prevNameIndex = 0;
|
|
4708
|
+
}
|
|
4709
|
+
endLine(segments) {
|
|
4710
|
+
this.lines.push(segments);
|
|
4711
|
+
this.buffered += segments.length + 1;
|
|
4712
|
+
if (this.buffered >= 4096) this.drain(null);
|
|
4713
|
+
}
|
|
4714
|
+
segments(segments) {
|
|
4715
|
+
this.drain(segments);
|
|
4716
|
+
}
|
|
4717
|
+
finish(segments) {
|
|
4718
|
+
this.drain(segments);
|
|
4719
|
+
this.flush();
|
|
4720
|
+
return this.out;
|
|
4721
|
+
}
|
|
4722
|
+
drain(trailing) {
|
|
4723
|
+
const lines = this.lines;
|
|
4724
|
+
const lineCount = lines.length;
|
|
4725
|
+
for (let l = 0; l <= lineCount; l++) {
|
|
4726
|
+
const line = l < lineCount ? lines[l] : trailing;
|
|
4727
|
+
if (line === null) break;
|
|
4728
|
+
for (let i = 0; i < line.length; i++) {
|
|
4729
|
+
if (this.pos > FLUSH_THRESHOLD) this.flush();
|
|
4730
|
+
const segment = line[i];
|
|
4731
|
+
if (this.needsComma) scratch[this.pos++] = COMMA;
|
|
4732
|
+
this.needsComma = true;
|
|
4733
|
+
this.pos = writeVlq(this.pos, segment[0] - this.prevGenColumn);
|
|
4734
|
+
this.prevGenColumn = segment[0];
|
|
4735
|
+
this.pos = writeVlq(this.pos, segment[1] - this.prevSourceIndex);
|
|
4736
|
+
this.prevSourceIndex = segment[1];
|
|
4737
|
+
this.pos = writeVlq(this.pos, segment[2] - this.prevSourceLine);
|
|
4738
|
+
this.prevSourceLine = segment[2];
|
|
4739
|
+
this.pos = writeVlq(this.pos, segment[3] - this.prevSourceColumn);
|
|
4740
|
+
this.prevSourceColumn = segment[3];
|
|
4741
|
+
if (segment.length === 5) {
|
|
4742
|
+
this.pos = writeVlq(this.pos, segment[4] - this.prevNameIndex);
|
|
4743
|
+
this.prevNameIndex = segment[4];
|
|
4744
|
+
}
|
|
4745
|
+
}
|
|
4746
|
+
if (l < lineCount) {
|
|
4747
|
+
if (this.pos > FLUSH_THRESHOLD) this.flush();
|
|
4748
|
+
scratch[this.pos++] = SEMICOLON;
|
|
4749
|
+
this.needsComma = false;
|
|
4750
|
+
this.prevGenColumn = 0;
|
|
4751
|
+
}
|
|
4752
|
+
}
|
|
4753
|
+
lines.length = 0;
|
|
4754
|
+
this.buffered = 0;
|
|
4755
|
+
this.flush();
|
|
4756
|
+
}
|
|
4757
|
+
flush() {
|
|
4758
|
+
this.out += decoder.decode(scratch.subarray(0, this.pos));
|
|
4759
|
+
this.pos = 0;
|
|
4760
|
+
}
|
|
4761
|
+
};
|
|
4674
4762
|
//#endregion
|
|
4675
4763
|
//#region src/utils/Mappings.ts
|
|
4676
4764
|
const NEWLINE_CHAR$1 = 10;
|
|
@@ -4678,7 +4766,7 @@ function isWordCode(code) {
|
|
|
4678
4766
|
return code >= 97 && code <= 122 || code >= 65 && code <= 90 || code >= 48 && code <= 57 || code === 95;
|
|
4679
4767
|
}
|
|
4680
4768
|
var Mappings = class {
|
|
4681
|
-
constructor(hires) {
|
|
4769
|
+
constructor(hires, encoder = null) {
|
|
4682
4770
|
this.hires = hires;
|
|
4683
4771
|
this.generatedCodeLine = 0;
|
|
4684
4772
|
this.generatedCodeColumn = 0;
|
|
@@ -4686,10 +4774,21 @@ var Mappings = class {
|
|
|
4686
4774
|
this.rawSegments = this.raw[this.generatedCodeLine] = [];
|
|
4687
4775
|
this.rawRangeMappings = [];
|
|
4688
4776
|
this.rawRangeMappingsIndices = this.rawRangeMappings[this.generatedCodeLine] = [];
|
|
4689
|
-
this.
|
|
4777
|
+
this.encoder = encoder;
|
|
4778
|
+
}
|
|
4779
|
+
nextLine() {
|
|
4780
|
+
if (this.encoder === null) {
|
|
4781
|
+
this.generatedCodeLine += 1;
|
|
4782
|
+
this.raw[this.generatedCodeLine] = this.rawSegments = [];
|
|
4783
|
+
} else {
|
|
4784
|
+
this.encoder.endLine(this.rawSegments);
|
|
4785
|
+
this.rawSegments = [];
|
|
4786
|
+
this.generatedCodeLine += 1;
|
|
4787
|
+
}
|
|
4788
|
+
this.generatedCodeColumn = 0;
|
|
4789
|
+
this.rawRangeMappings[this.generatedCodeLine] = this.rawRangeMappingsIndices = [];
|
|
4690
4790
|
}
|
|
4691
4791
|
addEdit(sourceIndex, content, loc, nameIndex) {
|
|
4692
|
-
/* v8 ignore else -- `pending` is never assigned a truthy value */
|
|
4693
4792
|
if (content.length) {
|
|
4694
4793
|
const contentLengthMinusOne = content.length - 1;
|
|
4695
4794
|
let contentLineEnd = content.indexOf("\n", 0);
|
|
@@ -4703,10 +4802,7 @@ var Mappings = class {
|
|
|
4703
4802
|
];
|
|
4704
4803
|
if (nameIndex >= 0) segment.push(nameIndex);
|
|
4705
4804
|
this.rawSegments.push(segment);
|
|
4706
|
-
this.
|
|
4707
|
-
this.raw[this.generatedCodeLine] = this.rawSegments = [];
|
|
4708
|
-
this.rawRangeMappings[this.generatedCodeLine] = this.rawRangeMappingsIndices = [];
|
|
4709
|
-
this.generatedCodeColumn = 0;
|
|
4805
|
+
this.nextLine();
|
|
4710
4806
|
previousContentLineEnd = contentLineEnd;
|
|
4711
4807
|
contentLineEnd = content.indexOf("\n", contentLineEnd + 1);
|
|
4712
4808
|
}
|
|
@@ -4719,11 +4815,7 @@ var Mappings = class {
|
|
|
4719
4815
|
if (nameIndex >= 0) segment.push(nameIndex);
|
|
4720
4816
|
this.rawSegments.push(segment);
|
|
4721
4817
|
this.advance(content.slice(previousContentLineEnd + 1));
|
|
4722
|
-
} else if (this.pending) {
|
|
4723
|
-
this.rawSegments.push(this.pending);
|
|
4724
|
-
this.advance(content);
|
|
4725
4818
|
}
|
|
4726
|
-
this.pending = null;
|
|
4727
4819
|
}
|
|
4728
4820
|
addUneditedChunk(sourceIndex, chunk, original, loc, sourcemapLocations) {
|
|
4729
4821
|
const end = chunk.end;
|
|
@@ -4731,8 +4823,13 @@ var Mappings = class {
|
|
|
4731
4823
|
if (this.hires) {
|
|
4732
4824
|
const boundary = this.hires === "boundary";
|
|
4733
4825
|
const experimentalRange = this.hires === "experimental-range";
|
|
4826
|
+
const encoder = experimentalRange ? null : this.encoder;
|
|
4734
4827
|
let charInHiresBoundary = false;
|
|
4735
4828
|
while (i < end) {
|
|
4829
|
+
if (encoder !== null && this.rawSegments.length >= 4096) {
|
|
4830
|
+
encoder.segments(this.rawSegments);
|
|
4831
|
+
this.rawSegments.length = 0;
|
|
4832
|
+
}
|
|
4736
4833
|
if (experimentalRange && i + 1 >= end) this.rawSegments.push([
|
|
4737
4834
|
this.generatedCodeColumn,
|
|
4738
4835
|
sourceIndex,
|
|
@@ -4743,10 +4840,7 @@ var Mappings = class {
|
|
|
4743
4840
|
if (code === NEWLINE_CHAR$1) {
|
|
4744
4841
|
loc.line += 1;
|
|
4745
4842
|
loc.column = 0;
|
|
4746
|
-
this.
|
|
4747
|
-
this.raw[this.generatedCodeLine] = this.rawSegments = [];
|
|
4748
|
-
this.rawRangeMappings[this.generatedCodeLine] = this.rawRangeMappingsIndices = [];
|
|
4749
|
-
this.generatedCodeColumn = 0;
|
|
4843
|
+
this.nextLine();
|
|
4750
4844
|
charInHiresBoundary = false;
|
|
4751
4845
|
} else {
|
|
4752
4846
|
if (boundary) {
|
|
@@ -4827,26 +4921,15 @@ var Mappings = class {
|
|
|
4827
4921
|
if (newline === end) break;
|
|
4828
4922
|
loc.line += 1;
|
|
4829
4923
|
loc.column = 0;
|
|
4830
|
-
this.
|
|
4831
|
-
this.raw[this.generatedCodeLine] = this.rawSegments = [];
|
|
4832
|
-
this.rawRangeMappings[this.generatedCodeLine] = this.rawRangeMappingsIndices = [];
|
|
4833
|
-
this.generatedCodeColumn = 0;
|
|
4924
|
+
this.nextLine();
|
|
4834
4925
|
i = newline + 1;
|
|
4835
4926
|
}
|
|
4836
4927
|
}
|
|
4837
|
-
this.pending = null;
|
|
4838
4928
|
}
|
|
4839
4929
|
advance(str) {
|
|
4840
4930
|
if (!str) return;
|
|
4841
4931
|
const lastNewline = str.lastIndexOf("\n");
|
|
4842
|
-
|
|
4843
|
-
for (let i = str.indexOf("\n"); i !== -1; i = str.indexOf("\n", i + 1)) {
|
|
4844
|
-
this.generatedCodeLine++;
|
|
4845
|
-
this.raw[this.generatedCodeLine] = this.rawSegments = [];
|
|
4846
|
-
this.rawRangeMappings[this.generatedCodeLine] = this.rawRangeMappingsIndices = [];
|
|
4847
|
-
}
|
|
4848
|
-
this.generatedCodeColumn = 0;
|
|
4849
|
-
}
|
|
4932
|
+
for (let i = str.indexOf("\n"); i !== -1; i = str.indexOf("\n", i + 1)) this.nextLine();
|
|
4850
4933
|
this.generatedCodeColumn += str.length - lastNewline - 1;
|
|
4851
4934
|
}
|
|
4852
4935
|
};
|
|
@@ -5067,9 +5150,32 @@ var MagicString = class MagicString {
|
|
|
5067
5150
|
*/
|
|
5068
5151
|
generateDecodedMap(options) {
|
|
5069
5152
|
options = options || {};
|
|
5153
|
+
const mappings = new Mappings(options.hires);
|
|
5154
|
+
const names = this._generateMappings(mappings);
|
|
5155
|
+
return {
|
|
5156
|
+
...this._mapProperties(options, names),
|
|
5157
|
+
mappings: mappings.raw,
|
|
5158
|
+
rangeMappings: mappings.rawRangeMappings
|
|
5159
|
+
};
|
|
5160
|
+
}
|
|
5161
|
+
/**
|
|
5162
|
+
* Generates a version 3 sourcemap.
|
|
5163
|
+
*/
|
|
5164
|
+
generateMap(options) {
|
|
5165
|
+
options = options || {};
|
|
5166
|
+
const encoder = new MappingsEncoder();
|
|
5167
|
+
const mappings = new Mappings(options.hires, encoder);
|
|
5168
|
+
const names = this._generateMappings(mappings);
|
|
5169
|
+
return new SourceMap({
|
|
5170
|
+
...this._mapProperties(options, names),
|
|
5171
|
+
mappings: encoder.finish(mappings.rawSegments),
|
|
5172
|
+
rangeMappings: mappings.rawRangeMappings
|
|
5173
|
+
});
|
|
5174
|
+
}
|
|
5175
|
+
/** @internal */
|
|
5176
|
+
_generateMappings(mappings) {
|
|
5070
5177
|
const sourceIndex = 0;
|
|
5071
5178
|
const names = Object.keys(this.storedNames);
|
|
5072
|
-
const mappings = new Mappings(options.hires);
|
|
5073
5179
|
const locate = getLocator(this.original);
|
|
5074
5180
|
if (this.intro) mappings.advance(this.intro);
|
|
5075
5181
|
this.firstChunk.eachNext((chunk) => {
|
|
@@ -5080,22 +5186,18 @@ var MagicString = class MagicString {
|
|
|
5080
5186
|
if (chunk.outro.length) mappings.advance(chunk.outro);
|
|
5081
5187
|
});
|
|
5082
5188
|
if (this.outro) mappings.advance(this.outro);
|
|
5189
|
+
return names;
|
|
5190
|
+
}
|
|
5191
|
+
/** @internal */
|
|
5192
|
+
_mapProperties(options, names) {
|
|
5083
5193
|
return {
|
|
5084
5194
|
file: options.file ? options.file.split(/[/\\]/).pop() : void 0,
|
|
5085
5195
|
sources: [options.source ? getRelativePath(options.file || "", options.source) : options.file || ""],
|
|
5086
5196
|
sourcesContent: options.includeContent ? [this.original] : void 0,
|
|
5087
5197
|
names,
|
|
5088
|
-
|
|
5089
|
-
x_google_ignoreList: this.ignoreList ? [sourceIndex] : void 0,
|
|
5090
|
-
rangeMappings: mappings.rawRangeMappings
|
|
5198
|
+
x_google_ignoreList: this.ignoreList ? [0] : void 0
|
|
5091
5199
|
};
|
|
5092
5200
|
}
|
|
5093
|
-
/**
|
|
5094
|
-
* Generates a version 3 sourcemap.
|
|
5095
|
-
*/
|
|
5096
|
-
generateMap(options) {
|
|
5097
|
-
return new SourceMap(this.generateDecodedMap(options));
|
|
5098
|
-
}
|
|
5099
5201
|
/** @internal */
|
|
5100
5202
|
_ensureindentStr() {
|
|
5101
5203
|
if (this.indentStr === void 0) this.indentStr = guessIndent(this.original);
|
|
@@ -5208,8 +5310,14 @@ var MagicString = class MagicString {
|
|
|
5208
5310
|
}
|
|
5209
5311
|
/**
|
|
5210
5312
|
* Moves the characters from `start` and `end` to `index`.
|
|
5313
|
+
*
|
|
5314
|
+
* `affinity` controls where the range is anchored at `index`. With the
|
|
5315
|
+
* default `'right'`, it is inserted before the content that starts at `index`;
|
|
5316
|
+
* with `'left'`, it is inserted after the content that ends at `index`. The
|
|
5317
|
+
* two differ only when other content has already been moved to that boundary,
|
|
5318
|
+
* mirroring the `appendLeft`/`appendRight` distinction.
|
|
5211
5319
|
*/
|
|
5212
|
-
move(start, end, index) {
|
|
5320
|
+
move(start, end, index, affinity = "right") {
|
|
5213
5321
|
start = start + this.offset;
|
|
5214
5322
|
end = end + this.offset;
|
|
5215
5323
|
index = index + this.offset;
|
|
@@ -5229,9 +5337,27 @@ var MagicString = class MagicString {
|
|
|
5229
5337
|
}
|
|
5230
5338
|
const oldLeft = first.previous;
|
|
5231
5339
|
const oldRight = last.next;
|
|
5232
|
-
|
|
5233
|
-
|
|
5234
|
-
|
|
5340
|
+
let newLeft;
|
|
5341
|
+
let newRight;
|
|
5342
|
+
if (affinity === "left") {
|
|
5343
|
+
newLeft = this.byEnd.get(index) ?? null;
|
|
5344
|
+
if (!newLeft) {
|
|
5345
|
+
if (first === this.firstChunk) return this;
|
|
5346
|
+
newRight = this.firstChunk;
|
|
5347
|
+
} else {
|
|
5348
|
+
if (newLeft.next === first) return this;
|
|
5349
|
+
newRight = newLeft.next;
|
|
5350
|
+
}
|
|
5351
|
+
} else {
|
|
5352
|
+
newRight = this.byStart.get(index) ?? null;
|
|
5353
|
+
if (!newRight) {
|
|
5354
|
+
if (last === this.lastChunk) return this;
|
|
5355
|
+
newLeft = this.lastChunk;
|
|
5356
|
+
} else {
|
|
5357
|
+
if (newRight.previous === last) return this;
|
|
5358
|
+
newLeft = newRight.previous;
|
|
5359
|
+
}
|
|
5360
|
+
}
|
|
5235
5361
|
if (oldLeft) oldLeft.next = oldRight;
|
|
5236
5362
|
if (oldRight) oldRight.previous = oldLeft;
|
|
5237
5363
|
if (newLeft) newLeft.next = first;
|
|
@@ -5356,6 +5482,9 @@ var MagicString = class MagicString {
|
|
|
5356
5482
|
}
|
|
5357
5483
|
/**
|
|
5358
5484
|
* Removes the characters from `start` to `end` (of the original string, **not** the generated string).
|
|
5485
|
+
* Content appended or prepended at positions strictly inside the range is removed with it, while
|
|
5486
|
+
* content attached at `start` or `end` is preserved — use `s.overwrite(start, end, '')` to remove
|
|
5487
|
+
* the range including its edge inserts.
|
|
5359
5488
|
* Removing the same content twice, or making removals that partially overlap, will cause an error.
|
|
5360
5489
|
*/
|
|
5361
5490
|
remove(start, end) {
|
|
@@ -5372,9 +5501,9 @@ var MagicString = class MagicString {
|
|
|
5372
5501
|
this._split(end);
|
|
5373
5502
|
let chunk = this.byStart.get(start);
|
|
5374
5503
|
while (chunk) {
|
|
5375
|
-
chunk.intro = "";
|
|
5376
|
-
chunk.outro = "";
|
|
5377
|
-
chunk.edit("");
|
|
5504
|
+
if (chunk.start > start) chunk.intro = "";
|
|
5505
|
+
if (chunk.end < end) chunk.outro = "";
|
|
5506
|
+
chunk.edit("", false, true);
|
|
5378
5507
|
chunk = end > chunk.end ? this.byStart.get(chunk.end) : null;
|
|
5379
5508
|
}
|
|
5380
5509
|
return this;
|
|
@@ -5454,12 +5583,13 @@ var MagicString = class MagicString {
|
|
|
5454
5583
|
let result = "";
|
|
5455
5584
|
let chunk = this.firstChunk;
|
|
5456
5585
|
while (chunk && (chunk.start > start || chunk.end <= start)) {
|
|
5457
|
-
if (chunk.start < end && chunk.end >= end) return result;
|
|
5586
|
+
if (chunk.start < end && chunk.end >= end || end === 0 && chunk.start === 0) return result;
|
|
5458
5587
|
chunk = chunk.next;
|
|
5459
5588
|
}
|
|
5460
5589
|
if (chunk && chunk.edited && chunk.start !== start) throw new MagicStringError(`cannot use edited character ${start} as slice start anchor`);
|
|
5461
5590
|
const startChunk = chunk;
|
|
5462
5591
|
while (chunk) {
|
|
5592
|
+
if (end === 0 && chunk.start === 0) break;
|
|
5463
5593
|
if (chunk.intro && (startChunk !== chunk || chunk.start === start)) result += chunk.intro;
|
|
5464
5594
|
const containsEnd = chunk.start < end && chunk.end >= end;
|
|
5465
5595
|
if (containsEnd && chunk.edited && chunk.end !== end) throw new MagicStringError(`cannot use edited character ${end} as slice end anchor`);
|
|
@@ -5572,7 +5702,8 @@ var MagicString = class MagicString {
|
|
|
5572
5702
|
if (aborted) return true;
|
|
5573
5703
|
chunk = chunk.previous;
|
|
5574
5704
|
} while (chunk);
|
|
5575
|
-
|
|
5705
|
+
this.intro = this.intro.replace(rx, "");
|
|
5706
|
+
return this.intro.length > 0;
|
|
5576
5707
|
}
|
|
5577
5708
|
/**
|
|
5578
5709
|
* Trims content matching `charType` (defaults to `\s`, i.e. whitespace) from the end.
|
|
@@ -5599,7 +5730,8 @@ var MagicString = class MagicString {
|
|
|
5599
5730
|
if (aborted) return true;
|
|
5600
5731
|
chunk = chunk.next;
|
|
5601
5732
|
} while (chunk);
|
|
5602
|
-
|
|
5733
|
+
this.outro = this.outro.replace(rx, "");
|
|
5734
|
+
return this.outro.length > 0;
|
|
5603
5735
|
}
|
|
5604
5736
|
/**
|
|
5605
5737
|
* Trims content matching `charType` (defaults to `\s`, i.e. whitespace) from the start.
|
|
@@ -5626,6 +5758,22 @@ var MagicString = class MagicString {
|
|
|
5626
5758
|
}
|
|
5627
5759
|
return outputIndex !== this.original.length;
|
|
5628
5760
|
}
|
|
5761
|
+
/**
|
|
5762
|
+
* Whether the original range [start, end) has had any of its characters
|
|
5763
|
+
* removed. `replace`/`replaceAll` search `original`, so a match can land on
|
|
5764
|
+
* text that is no longer in the output - overwriting it would resurrect the
|
|
5765
|
+
* removed characters, so such matches are skipped instead.
|
|
5766
|
+
*
|
|
5767
|
+
* @internal
|
|
5768
|
+
*/
|
|
5769
|
+
_hasRemovedContent(start, end) {
|
|
5770
|
+
let chunk = this.firstChunk;
|
|
5771
|
+
while (chunk) {
|
|
5772
|
+
if (chunk.content === "" && chunk.start < end && chunk.end > start) return true;
|
|
5773
|
+
chunk = chunk.next;
|
|
5774
|
+
}
|
|
5775
|
+
return false;
|
|
5776
|
+
}
|
|
5629
5777
|
/** @internal */
|
|
5630
5778
|
_replaceRegexp(searchValue, replacement) {
|
|
5631
5779
|
function getReplacement(match, str) {
|
|
@@ -5634,32 +5782,42 @@ var MagicString = class MagicString {
|
|
|
5634
5782
|
}
|
|
5635
5783
|
const replaceMatch = (match) => {
|
|
5636
5784
|
/* v8 ignore next 2 -- `match.index` is always defined for matches from `matchAll` */
|
|
5637
|
-
if (match.index == null) return;
|
|
5785
|
+
if (match.index == null) return false;
|
|
5786
|
+
if (this._hasRemovedContent(match.index, match.index + match[0].length)) return false;
|
|
5638
5787
|
const replacement = getReplacement(match, this.original);
|
|
5639
|
-
if (replacement === match[0]) return;
|
|
5788
|
+
if (replacement === match[0]) return true;
|
|
5640
5789
|
if (match[0].length === 0) this.appendRight(match.index, replacement);
|
|
5641
5790
|
else this.overwrite(match.index, match.index + match[0].length, replacement);
|
|
5791
|
+
return true;
|
|
5642
5792
|
};
|
|
5643
5793
|
if (searchValue.global) {
|
|
5644
5794
|
searchValue.lastIndex = 0;
|
|
5645
5795
|
for (const match of this.original.matchAll(searchValue)) replaceMatch(match);
|
|
5646
5796
|
} else {
|
|
5647
5797
|
const match = this.original.match(searchValue);
|
|
5648
|
-
if (match
|
|
5798
|
+
if (match && !replaceMatch(match)) {
|
|
5799
|
+
const global = new RegExp(searchValue.source, `${searchValue.flags}g`);
|
|
5800
|
+
for (const next of this.original.matchAll(global)) if (replaceMatch(next)) break;
|
|
5801
|
+
}
|
|
5649
5802
|
}
|
|
5650
5803
|
return this;
|
|
5651
5804
|
}
|
|
5652
5805
|
/** @internal */
|
|
5653
5806
|
_replaceString(string, replacement) {
|
|
5654
5807
|
const { original } = this;
|
|
5655
|
-
|
|
5656
|
-
|
|
5808
|
+
let index = original.indexOf(string);
|
|
5809
|
+
while (index !== -1) {
|
|
5810
|
+
if (this._hasRemovedContent(index, index + string.length)) {
|
|
5811
|
+
index = original.indexOf(string, index + string.length);
|
|
5812
|
+
continue;
|
|
5813
|
+
}
|
|
5657
5814
|
if (typeof replacement === "function") replacement = replacement(string, index, original);
|
|
5658
5815
|
else replacement = expandReplacement(replacement, string, index, original, [], void 0);
|
|
5659
5816
|
if (string !== replacement) {
|
|
5660
5817
|
if (string.length === 0) this.appendRight(index, replacement);
|
|
5661
5818
|
else this.overwrite(index, index + string.length, replacement);
|
|
5662
5819
|
}
|
|
5820
|
+
break;
|
|
5663
5821
|
}
|
|
5664
5822
|
return this;
|
|
5665
5823
|
}
|
|
@@ -5682,6 +5840,7 @@ var MagicString = class MagicString {
|
|
|
5682
5840
|
return this;
|
|
5683
5841
|
}
|
|
5684
5842
|
for (let index = original.indexOf(string); index !== -1; index = original.indexOf(string, index + stringLength)) {
|
|
5843
|
+
if (this._hasRemovedContent(index, index + stringLength)) continue;
|
|
5685
5844
|
const previous = original.slice(index, index + stringLength);
|
|
5686
5845
|
const _replacement = typeof replacement === "function" ? replacement(previous, index, original) : expandReplacement(replacement, previous, index, original, [], void 0);
|
|
5687
5846
|
if (previous !== _replacement) this.overwrite(index, index + stringLength, _replacement);
|
|
@@ -5772,7 +5931,103 @@ var Bundle$1 = class Bundle {
|
|
|
5772
5931
|
});
|
|
5773
5932
|
return bundle;
|
|
5774
5933
|
}
|
|
5934
|
+
/**
|
|
5935
|
+
* Flattens the bundle into a single `MagicString`, so the concatenated result can be
|
|
5936
|
+
* processed further with the full `MagicString` API. The returned string's `original`
|
|
5937
|
+
* is the concatenation of every source's `original`, and all existing edits, inserts,
|
|
5938
|
+
* intros, outros and separators are preserved as inserted content, so its `toString()`
|
|
5939
|
+
* equals the bundle's `toString()` and its sourcemap maps back to that combined original.
|
|
5940
|
+
*
|
|
5941
|
+
* Because a `MagicString` maps to a single source, per-source `filename`s are not carried
|
|
5942
|
+
* over; generate the bundle's map before flattening if you need the multi-source mapping.
|
|
5943
|
+
*/
|
|
5944
|
+
toMagicString() {
|
|
5945
|
+
const combined = new MagicString(this.sources.map((source) => source.content.original).join(""));
|
|
5946
|
+
let offset = 0;
|
|
5947
|
+
let pending = this.intro;
|
|
5948
|
+
let first = null;
|
|
5949
|
+
let last = null;
|
|
5950
|
+
const byStart = /* @__PURE__ */ new Map();
|
|
5951
|
+
const byEnd = /* @__PURE__ */ new Map();
|
|
5952
|
+
let hasMovedChunks = false;
|
|
5953
|
+
this.sources.forEach((source, i) => {
|
|
5954
|
+
const magicString = source.content;
|
|
5955
|
+
const separator = i > 0 ? source.separator !== void 0 ? source.separator : this.separator : "";
|
|
5956
|
+
if (magicString.original.length === 0) {
|
|
5957
|
+
pending += separator + magicString.toString();
|
|
5958
|
+
return;
|
|
5959
|
+
}
|
|
5960
|
+
pending += separator + magicString.intro;
|
|
5961
|
+
let sourceFirst = null;
|
|
5962
|
+
let previous = null;
|
|
5963
|
+
let originalChunk = magicString.firstChunk;
|
|
5964
|
+
while (originalChunk) {
|
|
5965
|
+
const chunk = originalChunk.clone();
|
|
5966
|
+
chunk.start += offset;
|
|
5967
|
+
chunk.end += offset;
|
|
5968
|
+
chunk.previous = previous;
|
|
5969
|
+
chunk.next = null;
|
|
5970
|
+
if (previous) previous.next = chunk;
|
|
5971
|
+
byStart.set(chunk.start, chunk);
|
|
5972
|
+
byEnd.set(chunk.end, chunk);
|
|
5973
|
+
sourceFirst ??= chunk;
|
|
5974
|
+
previous = chunk;
|
|
5975
|
+
originalChunk = originalChunk.next;
|
|
5976
|
+
}
|
|
5977
|
+
const sourceLast = previous;
|
|
5978
|
+
sourceFirst.intro = pending + sourceFirst.intro;
|
|
5979
|
+
pending = "";
|
|
5980
|
+
sourceLast.outro += magicString.outro;
|
|
5981
|
+
if (last) {
|
|
5982
|
+
last.next = sourceFirst;
|
|
5983
|
+
sourceFirst.previous = last;
|
|
5984
|
+
} else first = sourceFirst;
|
|
5985
|
+
last = sourceLast;
|
|
5986
|
+
for (let index = 0; index < magicString.original.length; index += 1) if (magicString.sourcemapLocations.has(index)) combined.sourcemapLocations.add(index + offset);
|
|
5987
|
+
Object.keys(magicString.storedNames).forEach((name) => {
|
|
5988
|
+
Object.defineProperty(combined.storedNames, name, {
|
|
5989
|
+
writable: true,
|
|
5990
|
+
value: true,
|
|
5991
|
+
enumerable: true
|
|
5992
|
+
});
|
|
5993
|
+
});
|
|
5994
|
+
if (magicString.hasMovedChunks) hasMovedChunks = true;
|
|
5995
|
+
offset += magicString.original.length;
|
|
5996
|
+
});
|
|
5997
|
+
if (!first) {
|
|
5998
|
+
combined.intro = pending;
|
|
5999
|
+
return combined;
|
|
6000
|
+
}
|
|
6001
|
+
if (pending) last.outro += pending;
|
|
6002
|
+
combined.firstChunk = first;
|
|
6003
|
+
combined.lastChunk = last;
|
|
6004
|
+
combined.lastSearchedChunk = first;
|
|
6005
|
+
combined.byStart = byStart;
|
|
6006
|
+
combined.byEnd = byEnd;
|
|
6007
|
+
combined.hasMovedChunks = hasMovedChunks;
|
|
6008
|
+
return combined;
|
|
6009
|
+
}
|
|
5775
6010
|
generateDecodedMap(options = {}) {
|
|
6011
|
+
const mappings = new Mappings(options.hires);
|
|
6012
|
+
const { names, x_google_ignoreList } = this._generateMappings(mappings);
|
|
6013
|
+
return {
|
|
6014
|
+
...this._mapProperties(options, names, x_google_ignoreList),
|
|
6015
|
+
mappings: mappings.raw,
|
|
6016
|
+
rangeMappings: mappings.rawRangeMappings
|
|
6017
|
+
};
|
|
6018
|
+
}
|
|
6019
|
+
generateMap(options = {}) {
|
|
6020
|
+
const encoder = new MappingsEncoder();
|
|
6021
|
+
const mappings = new Mappings(options.hires, encoder);
|
|
6022
|
+
const { names, x_google_ignoreList } = this._generateMappings(mappings);
|
|
6023
|
+
return new SourceMap({
|
|
6024
|
+
...this._mapProperties(options, names, x_google_ignoreList),
|
|
6025
|
+
mappings: encoder.finish(mappings.rawSegments),
|
|
6026
|
+
rangeMappings: mappings.rawRangeMappings
|
|
6027
|
+
});
|
|
6028
|
+
}
|
|
6029
|
+
/** @internal */
|
|
6030
|
+
_generateMappings(mappings) {
|
|
5776
6031
|
const names = [];
|
|
5777
6032
|
let x_google_ignoreList;
|
|
5778
6033
|
this.sources.forEach((source) => {
|
|
@@ -5780,7 +6035,6 @@ var Bundle$1 = class Bundle {
|
|
|
5780
6035
|
if (!names.includes(name)) names.push(name);
|
|
5781
6036
|
});
|
|
5782
6037
|
});
|
|
5783
|
-
const mappings = new Mappings(options.hires);
|
|
5784
6038
|
if (this.intro) mappings.advance(this.intro);
|
|
5785
6039
|
this.sources.forEach((source, i) => {
|
|
5786
6040
|
if (i > 0)
|
|
@@ -5805,6 +6059,13 @@ var Bundle$1 = class Bundle {
|
|
|
5805
6059
|
x_google_ignoreList.push(sourceIndex);
|
|
5806
6060
|
}
|
|
5807
6061
|
});
|
|
6062
|
+
return {
|
|
6063
|
+
names,
|
|
6064
|
+
x_google_ignoreList
|
|
6065
|
+
};
|
|
6066
|
+
}
|
|
6067
|
+
/** @internal */
|
|
6068
|
+
_mapProperties(options, names, x_google_ignoreList) {
|
|
5808
6069
|
return {
|
|
5809
6070
|
file: options.file ? options.file.split(/[/\\]/).pop() : void 0,
|
|
5810
6071
|
sources: this.uniqueSources.map((source) => {
|
|
@@ -5814,14 +6075,9 @@ var Bundle$1 = class Bundle {
|
|
|
5814
6075
|
return (typeof options.includeContent === "function" ? options.includeContent(source) : options.includeContent) ? source.content : null;
|
|
5815
6076
|
}),
|
|
5816
6077
|
names,
|
|
5817
|
-
|
|
5818
|
-
x_google_ignoreList,
|
|
5819
|
-
rangeMappings: mappings.rawRangeMappings
|
|
6078
|
+
x_google_ignoreList
|
|
5820
6079
|
};
|
|
5821
6080
|
}
|
|
5822
|
-
generateMap(options) {
|
|
5823
|
-
return new SourceMap(this.generateDecodedMap(options));
|
|
5824
|
-
}
|
|
5825
6081
|
getIndentString() {
|
|
5826
6082
|
const indentStringCounts = {};
|
|
5827
6083
|
this.sources.forEach((source) => {
|
|
@@ -12327,7 +12583,7 @@ function formatAttributes(attributes, { getObject }) {
|
|
|
12327
12583
|
if (!attributes) {
|
|
12328
12584
|
return null;
|
|
12329
12585
|
}
|
|
12330
|
-
const assertionEntries = Object.entries(attributes).map(([key, value]) => [key,
|
|
12586
|
+
const assertionEntries = Object.entries(attributes).map(([key, value]) => [key, JSON.stringify(value)]);
|
|
12331
12587
|
if (assertionEntries.length > 0) {
|
|
12332
12588
|
return getObject(assertionEntries, { lineBreakIndent: null });
|
|
12333
12589
|
}
|
|
@@ -19461,7 +19717,7 @@ class Module {
|
|
|
19461
19717
|
}
|
|
19462
19718
|
return null;
|
|
19463
19719
|
}
|
|
19464
|
-
updateOptions({ meta, moduleSideEffects, syntheticNamedExports }) {
|
|
19720
|
+
updateOptions({ meta, moduleSideEffects, syntheticNamedExports }, { replaceExistingMeta = false } = parseAst_js.EMPTY_OBJECT) {
|
|
19465
19721
|
if (moduleSideEffects != null) {
|
|
19466
19722
|
this.info.moduleSideEffects = moduleSideEffects;
|
|
19467
19723
|
}
|
|
@@ -19469,6 +19725,11 @@ class Module {
|
|
|
19469
19725
|
this.info.syntheticNamedExports = syntheticNamedExports;
|
|
19470
19726
|
}
|
|
19471
19727
|
if (meta != null) {
|
|
19728
|
+
if (replaceExistingMeta) {
|
|
19729
|
+
for (const key of Object.keys(this.info.meta)) {
|
|
19730
|
+
delete this.info.meta[key];
|
|
19731
|
+
}
|
|
19732
|
+
}
|
|
19472
19733
|
Object.assign(this.info.meta, meta);
|
|
19473
19734
|
}
|
|
19474
19735
|
}
|
|
@@ -23173,8 +23434,14 @@ class ModuleLoader {
|
|
|
23173
23434
|
const cachedModule = this.graph.cachedModules.get(id);
|
|
23174
23435
|
if (cachedModule &&
|
|
23175
23436
|
!cachedModule.customTransformCache &&
|
|
23176
|
-
cachedModule.originalCode === sourceDescription.code
|
|
23177
|
-
|
|
23437
|
+
cachedModule.originalCode === sourceDescription.code) {
|
|
23438
|
+
const originalModuleOptions = {
|
|
23439
|
+
meta: { ...module.info.meta },
|
|
23440
|
+
moduleSideEffects: module.info.moduleSideEffects,
|
|
23441
|
+
syntheticNamedExports: module.info.syntheticNamedExports
|
|
23442
|
+
};
|
|
23443
|
+
module.updateOptions(cachedModule);
|
|
23444
|
+
if (await this.pluginDriver.hookFirst('shouldTransformCachedModule', [
|
|
23178
23445
|
{
|
|
23179
23446
|
ast: cachedModule.ast,
|
|
23180
23447
|
attributes: cachedModule.attributes,
|
|
@@ -23185,17 +23452,20 @@ class ModuleLoader {
|
|
|
23185
23452
|
resolvedSources: cachedModule.resolvedIds,
|
|
23186
23453
|
syntheticNamedExports: cachedModule.syntheticNamedExports
|
|
23187
23454
|
}
|
|
23188
|
-
]))
|
|
23189
|
-
|
|
23190
|
-
|
|
23191
|
-
|
|
23455
|
+
])) {
|
|
23456
|
+
module.updateOptions(originalModuleOptions, { replaceExistingMeta: true });
|
|
23457
|
+
}
|
|
23458
|
+
else {
|
|
23459
|
+
if (cachedModule.transformFiles) {
|
|
23460
|
+
for (const emittedFile of cachedModule.transformFiles)
|
|
23461
|
+
this.pluginDriver.emitFile(emittedFile);
|
|
23462
|
+
}
|
|
23463
|
+
await module.setSource(cachedModule);
|
|
23464
|
+
return;
|
|
23192
23465
|
}
|
|
23193
|
-
await module.setSource(cachedModule);
|
|
23194
|
-
}
|
|
23195
|
-
else {
|
|
23196
|
-
module.updateOptions(sourceDescription);
|
|
23197
|
-
await module.setSource(await transform(sourceDescription, module, this.pluginDriver, this.options));
|
|
23198
23466
|
}
|
|
23467
|
+
module.updateOptions(sourceDescription);
|
|
23468
|
+
await module.setSource(await transform(sourceDescription, module, this.pluginDriver, this.options));
|
|
23199
23469
|
}
|
|
23200
23470
|
async awaitLoadModulesPromise() {
|
|
23201
23471
|
let startingPromise;
|