rollup 1.27.13 → 1.29.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/CHANGELOG.md +60 -0
- package/README.md +2 -2
- package/dist/bin/rollup +59 -26
- package/dist/rollup.browser.es.js +3 -3
- package/dist/rollup.browser.js +5 -4
- package/dist/rollup.d.ts +44 -6
- package/dist/rollup.es.js +360 -252
- package/dist/rollup.js +356 -290
- package/dist/shared/index.js +52 -8
- package/package.json +16 -16
package/dist/rollup.es.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
2
|
@license
|
|
3
|
-
Rollup.js v1.
|
|
4
|
-
|
|
3
|
+
Rollup.js v1.29.1
|
|
4
|
+
Tue, 21 Jan 2020 06:50:03 GMT - commit 21a1775a019b45bebfc608c8f58f3691080106e5
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
https://github.com/rollup/rollup
|
|
@@ -50,7 +50,7 @@ function __awaiter(thisArg, _arguments, P, generator) {
|
|
|
50
50
|
});
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
var version = "1.
|
|
53
|
+
var version = "1.29.1";
|
|
54
54
|
|
|
55
55
|
var charToInteger = {};
|
|
56
56
|
var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
|
|
@@ -58,30 +58,28 @@ for (var i = 0; i < chars.length; i++) {
|
|
|
58
58
|
charToInteger[chars.charCodeAt(i)] = i;
|
|
59
59
|
}
|
|
60
60
|
function decode(mappings) {
|
|
61
|
-
var generatedCodeColumn = 0; // first field
|
|
62
|
-
var sourceFileIndex = 0; // second field
|
|
63
|
-
var sourceCodeLine = 0; // third field
|
|
64
|
-
var sourceCodeColumn = 0; // fourth field
|
|
65
|
-
var nameIndex = 0; // fifth field
|
|
66
61
|
var decoded = [];
|
|
67
62
|
var line = [];
|
|
68
|
-
var segment = [
|
|
69
|
-
|
|
63
|
+
var segment = [
|
|
64
|
+
0,
|
|
65
|
+
0,
|
|
66
|
+
0,
|
|
67
|
+
0,
|
|
68
|
+
0,
|
|
69
|
+
];
|
|
70
|
+
var j = 0;
|
|
71
|
+
for (var i = 0, shift = 0, value = 0; i < mappings.length; i++) {
|
|
70
72
|
var c = mappings.charCodeAt(i);
|
|
71
73
|
if (c === 44) { // ","
|
|
72
|
-
|
|
73
|
-
line.push(segment);
|
|
74
|
-
segment = [];
|
|
74
|
+
segmentify(line, segment, j);
|
|
75
75
|
j = 0;
|
|
76
76
|
}
|
|
77
77
|
else if (c === 59) { // ";"
|
|
78
|
-
|
|
79
|
-
line.push(segment);
|
|
80
|
-
segment = [];
|
|
78
|
+
segmentify(line, segment, j);
|
|
81
79
|
j = 0;
|
|
82
80
|
decoded.push(line);
|
|
83
81
|
line = [];
|
|
84
|
-
|
|
82
|
+
segment[0] = 0;
|
|
85
83
|
}
|
|
86
84
|
else {
|
|
87
85
|
var integer = charToInteger[c];
|
|
@@ -98,40 +96,33 @@ function decode(mappings) {
|
|
|
98
96
|
var shouldNegate = value & 1;
|
|
99
97
|
value >>>= 1;
|
|
100
98
|
if (shouldNegate) {
|
|
101
|
-
value = -value;
|
|
102
|
-
if (value === 0)
|
|
103
|
-
value = -0x80000000;
|
|
104
|
-
}
|
|
105
|
-
if (j == 0) {
|
|
106
|
-
generatedCodeColumn += value;
|
|
107
|
-
segment.push(generatedCodeColumn);
|
|
108
|
-
}
|
|
109
|
-
else if (j === 1) {
|
|
110
|
-
sourceFileIndex += value;
|
|
111
|
-
segment.push(sourceFileIndex);
|
|
112
|
-
}
|
|
113
|
-
else if (j === 2) {
|
|
114
|
-
sourceCodeLine += value;
|
|
115
|
-
segment.push(sourceCodeLine);
|
|
116
|
-
}
|
|
117
|
-
else if (j === 3) {
|
|
118
|
-
sourceCodeColumn += value;
|
|
119
|
-
segment.push(sourceCodeColumn);
|
|
120
|
-
}
|
|
121
|
-
else if (j === 4) {
|
|
122
|
-
nameIndex += value;
|
|
123
|
-
segment.push(nameIndex);
|
|
99
|
+
value = value === 0 ? -0x80000000 : -value;
|
|
124
100
|
}
|
|
101
|
+
segment[j] += value;
|
|
125
102
|
j++;
|
|
126
103
|
value = shift = 0; // reset
|
|
127
104
|
}
|
|
128
105
|
}
|
|
129
106
|
}
|
|
130
|
-
|
|
131
|
-
line.push(segment);
|
|
107
|
+
segmentify(line, segment, j);
|
|
132
108
|
decoded.push(line);
|
|
133
109
|
return decoded;
|
|
134
110
|
}
|
|
111
|
+
function segmentify(line, segment, j) {
|
|
112
|
+
// This looks ugly, but we're creating specialized arrays with a specific
|
|
113
|
+
// length. This is much faster than creating a new array (which v8 expands to
|
|
114
|
+
// a capacity of 17 after pushing the first item), or slicing out a subarray
|
|
115
|
+
// (which is slow). Length 4 is assumed to be the most frequent, followed by
|
|
116
|
+
// length 5 (since not everything will have an associated name), followed by
|
|
117
|
+
// length 1 (it's probably rare for a source substring to not have an
|
|
118
|
+
// associated segment data).
|
|
119
|
+
if (j === 4)
|
|
120
|
+
line.push([segment[0], segment[1], segment[2], segment[3]]);
|
|
121
|
+
else if (j === 5)
|
|
122
|
+
line.push([segment[0], segment[1], segment[2], segment[3], segment[4]]);
|
|
123
|
+
else if (j === 1)
|
|
124
|
+
line.push([segment[0]]);
|
|
125
|
+
}
|
|
135
126
|
function encode(decoded) {
|
|
136
127
|
var sourceFileIndex = 0; // second field
|
|
137
128
|
var sourceCodeLine = 0; // third field
|
|
@@ -183,6 +174,15 @@ function encodeInteger(num) {
|
|
|
183
174
|
return result;
|
|
184
175
|
}
|
|
185
176
|
|
|
177
|
+
var BitSet = function BitSet(arg) {
|
|
178
|
+
this.bits = arg instanceof BitSet ? arg.bits.slice() : [];
|
|
179
|
+
};
|
|
180
|
+
BitSet.prototype.add = function add(n) {
|
|
181
|
+
this.bits[n >> 5] |= 1 << (n & 31);
|
|
182
|
+
};
|
|
183
|
+
BitSet.prototype.has = function has(n) {
|
|
184
|
+
return !!(this.bits[n >> 5] & (1 << (n & 31)));
|
|
185
|
+
};
|
|
186
186
|
var Chunk = function Chunk(start, end, content) {
|
|
187
187
|
this.start = start;
|
|
188
188
|
this.end = end;
|
|
@@ -425,39 +425,40 @@ Mappings.prototype.addEdit = function addEdit(sourceIndex, content, loc, nameInd
|
|
|
425
425
|
this.pending = null;
|
|
426
426
|
};
|
|
427
427
|
Mappings.prototype.addUneditedChunk = function addUneditedChunk(sourceIndex, chunk, original, loc, sourcemapLocations) {
|
|
428
|
-
var this$1 = this;
|
|
429
428
|
var originalCharIndex = chunk.start;
|
|
430
429
|
var first = true;
|
|
431
430
|
while (originalCharIndex < chunk.end) {
|
|
432
|
-
if (this
|
|
433
|
-
this
|
|
431
|
+
if (this.hires || first || sourcemapLocations.has(originalCharIndex)) {
|
|
432
|
+
this.rawSegments.push([this.generatedCodeColumn, sourceIndex, loc.line, loc.column]);
|
|
434
433
|
}
|
|
435
434
|
if (original[originalCharIndex] === '\n') {
|
|
436
435
|
loc.line += 1;
|
|
437
436
|
loc.column = 0;
|
|
438
|
-
this
|
|
439
|
-
this
|
|
440
|
-
this
|
|
437
|
+
this.generatedCodeLine += 1;
|
|
438
|
+
this.raw[this.generatedCodeLine] = this.rawSegments = [];
|
|
439
|
+
this.generatedCodeColumn = 0;
|
|
440
|
+
first = true;
|
|
441
441
|
}
|
|
442
442
|
else {
|
|
443
443
|
loc.column += 1;
|
|
444
|
-
this
|
|
444
|
+
this.generatedCodeColumn += 1;
|
|
445
|
+
first = false;
|
|
445
446
|
}
|
|
446
447
|
originalCharIndex += 1;
|
|
447
|
-
first = false;
|
|
448
448
|
}
|
|
449
|
-
this.pending =
|
|
449
|
+
this.pending = sourceIndex > 0
|
|
450
|
+
? [this.generatedCodeColumn, sourceIndex, loc.line, loc.column]
|
|
451
|
+
: null;
|
|
450
452
|
};
|
|
451
453
|
Mappings.prototype.advance = function advance(str) {
|
|
452
|
-
var this$1 = this;
|
|
453
454
|
if (!str) {
|
|
454
455
|
return;
|
|
455
456
|
}
|
|
456
457
|
var lines = str.split('\n');
|
|
457
458
|
if (lines.length > 1) {
|
|
458
459
|
for (var i = 0; i < lines.length - 1; i++) {
|
|
459
|
-
this
|
|
460
|
-
this
|
|
460
|
+
this.generatedCodeLine++;
|
|
461
|
+
this.raw[this.generatedCodeLine] = this.rawSegments = [];
|
|
461
462
|
}
|
|
462
463
|
this.generatedCodeColumn = 0;
|
|
463
464
|
}
|
|
@@ -484,7 +485,7 @@ var MagicString = function MagicString(string, options) {
|
|
|
484
485
|
byEnd: { writable: true, value: {} },
|
|
485
486
|
filename: { writable: true, value: options.filename },
|
|
486
487
|
indentExclusionRanges: { writable: true, value: options.indentExclusionRanges },
|
|
487
|
-
sourcemapLocations: { writable: true, value:
|
|
488
|
+
sourcemapLocations: { writable: true, value: new BitSet() },
|
|
488
489
|
storedNames: { writable: true, value: {} },
|
|
489
490
|
indentStr: { writable: true, value: guessIndent(string) }
|
|
490
491
|
});
|
|
@@ -492,7 +493,7 @@ var MagicString = function MagicString(string, options) {
|
|
|
492
493
|
this.byEnd[string.length] = chunk;
|
|
493
494
|
};
|
|
494
495
|
MagicString.prototype.addSourcemapLocation = function addSourcemapLocation(char) {
|
|
495
|
-
this.sourcemapLocations
|
|
496
|
+
this.sourcemapLocations.add(char);
|
|
496
497
|
};
|
|
497
498
|
MagicString.prototype.append = function append(content) {
|
|
498
499
|
if (typeof content !== 'string') {
|
|
@@ -549,9 +550,7 @@ MagicString.prototype.clone = function clone() {
|
|
|
549
550
|
if (this.indentExclusionRanges) {
|
|
550
551
|
cloned.indentExclusionRanges = this.indentExclusionRanges.slice();
|
|
551
552
|
}
|
|
552
|
-
|
|
553
|
-
cloned.sourcemapLocations[loc] = true;
|
|
554
|
-
});
|
|
553
|
+
cloned.sourcemapLocations = new BitSet(this.sourcemapLocations);
|
|
555
554
|
cloned.intro = this.intro;
|
|
556
555
|
cloned.outro = this.outro;
|
|
557
556
|
return cloned;
|
|
@@ -596,7 +595,6 @@ MagicString.prototype.getIndentString = function getIndentString() {
|
|
|
596
595
|
return this.indentStr === null ? '\t' : this.indentStr;
|
|
597
596
|
};
|
|
598
597
|
MagicString.prototype.indent = function indent(indentStr, options) {
|
|
599
|
-
var this$1 = this;
|
|
600
598
|
var pattern = /^[^\r\n]/gm;
|
|
601
599
|
if (isObject(indentStr)) {
|
|
602
600
|
options = indentStr;
|
|
@@ -642,7 +640,7 @@ MagicString.prototype.indent = function indent(indentStr, options) {
|
|
|
642
640
|
charIndex = chunk.start;
|
|
643
641
|
while (charIndex < end) {
|
|
644
642
|
if (!isExcluded[charIndex]) {
|
|
645
|
-
var char = this
|
|
643
|
+
var char = this.original[charIndex];
|
|
646
644
|
if (char === '\n') {
|
|
647
645
|
shouldIndentNextCharacter = true;
|
|
648
646
|
}
|
|
@@ -652,7 +650,7 @@ MagicString.prototype.indent = function indent(indentStr, options) {
|
|
|
652
650
|
chunk.prependRight(indentStr);
|
|
653
651
|
}
|
|
654
652
|
else {
|
|
655
|
-
this
|
|
653
|
+
this._splitChunk(chunk, charIndex);
|
|
656
654
|
chunk = chunk.next;
|
|
657
655
|
chunk.prependRight(indentStr);
|
|
658
656
|
}
|
|
@@ -730,15 +728,14 @@ MagicString.prototype.move = function move(start, end, index) {
|
|
|
730
728
|
return this;
|
|
731
729
|
};
|
|
732
730
|
MagicString.prototype.overwrite = function overwrite(start, end, content, options) {
|
|
733
|
-
var this$1 = this;
|
|
734
731
|
if (typeof content !== 'string') {
|
|
735
732
|
throw new TypeError('replacement content must be a string');
|
|
736
733
|
}
|
|
737
734
|
while (start < 0) {
|
|
738
|
-
start += this
|
|
735
|
+
start += this.original.length;
|
|
739
736
|
}
|
|
740
737
|
while (end < 0) {
|
|
741
|
-
end += this
|
|
738
|
+
end += this.original.length;
|
|
742
739
|
}
|
|
743
740
|
if (end > this.original.length) {
|
|
744
741
|
throw new Error('end is out of bounds');
|
|
@@ -822,12 +819,11 @@ MagicString.prototype.prependRight = function prependRight(index, content) {
|
|
|
822
819
|
return this;
|
|
823
820
|
};
|
|
824
821
|
MagicString.prototype.remove = function remove(start, end) {
|
|
825
|
-
var this$1 = this;
|
|
826
822
|
while (start < 0) {
|
|
827
|
-
start += this
|
|
823
|
+
start += this.original.length;
|
|
828
824
|
}
|
|
829
825
|
while (end < 0) {
|
|
830
|
-
end += this
|
|
826
|
+
end += this.original.length;
|
|
831
827
|
}
|
|
832
828
|
if (start === end) {
|
|
833
829
|
return this;
|
|
@@ -845,7 +841,7 @@ MagicString.prototype.remove = function remove(start, end) {
|
|
|
845
841
|
chunk.intro = '';
|
|
846
842
|
chunk.outro = '';
|
|
847
843
|
chunk.edit('');
|
|
848
|
-
chunk = end > chunk.end ? this
|
|
844
|
+
chunk = end > chunk.end ? this.byStart[chunk.end] : null;
|
|
849
845
|
}
|
|
850
846
|
return this;
|
|
851
847
|
};
|
|
@@ -907,16 +903,15 @@ MagicString.prototype.lastLine = function lastLine() {
|
|
|
907
903
|
return this.intro + lineStr;
|
|
908
904
|
};
|
|
909
905
|
MagicString.prototype.slice = function slice(start, end) {
|
|
910
|
-
var this$1 = this;
|
|
911
906
|
if (start === void 0)
|
|
912
907
|
start = 0;
|
|
913
908
|
if (end === void 0)
|
|
914
909
|
end = this.original.length;
|
|
915
910
|
while (start < 0) {
|
|
916
|
-
start += this
|
|
911
|
+
start += this.original.length;
|
|
917
912
|
}
|
|
918
913
|
while (end < 0) {
|
|
919
|
-
end += this
|
|
914
|
+
end += this.original.length;
|
|
920
915
|
}
|
|
921
916
|
var result = '';
|
|
922
917
|
// find start chunk
|
|
@@ -961,7 +956,6 @@ MagicString.prototype.snip = function snip(start, end) {
|
|
|
961
956
|
return clone;
|
|
962
957
|
};
|
|
963
958
|
MagicString.prototype._split = function _split(index) {
|
|
964
|
-
var this$1 = this;
|
|
965
959
|
if (this.byStart[index] || this.byEnd[index]) {
|
|
966
960
|
return;
|
|
967
961
|
}
|
|
@@ -969,9 +963,9 @@ MagicString.prototype._split = function _split(index) {
|
|
|
969
963
|
var searchForward = index > chunk.end;
|
|
970
964
|
while (chunk) {
|
|
971
965
|
if (chunk.contains(index)) {
|
|
972
|
-
return this
|
|
966
|
+
return this._splitChunk(chunk, index);
|
|
973
967
|
}
|
|
974
|
-
chunk = searchForward ? this
|
|
968
|
+
chunk = searchForward ? this.byStart[chunk.end] : this.byEnd[chunk.start];
|
|
975
969
|
}
|
|
976
970
|
};
|
|
977
971
|
MagicString.prototype._splitChunk = function _splitChunk(chunk, index) {
|
|
@@ -1025,7 +1019,6 @@ MagicString.prototype.trim = function trim(charType) {
|
|
|
1025
1019
|
return this.trimStart(charType).trimEnd(charType);
|
|
1026
1020
|
};
|
|
1027
1021
|
MagicString.prototype.trimEndAborted = function trimEndAborted(charType) {
|
|
1028
|
-
var this$1 = this;
|
|
1029
1022
|
var rx = new RegExp((charType || '\\s') + '+$');
|
|
1030
1023
|
this.outro = this.outro.replace(rx, '');
|
|
1031
1024
|
if (this.outro.length) {
|
|
@@ -1037,12 +1030,12 @@ MagicString.prototype.trimEndAborted = function trimEndAborted(charType) {
|
|
|
1037
1030
|
var aborted = chunk.trimEnd(rx);
|
|
1038
1031
|
// if chunk was trimmed, we have a new lastChunk
|
|
1039
1032
|
if (chunk.end !== end) {
|
|
1040
|
-
if (this
|
|
1041
|
-
this
|
|
1033
|
+
if (this.lastChunk === chunk) {
|
|
1034
|
+
this.lastChunk = chunk.next;
|
|
1042
1035
|
}
|
|
1043
|
-
this
|
|
1044
|
-
this
|
|
1045
|
-
this
|
|
1036
|
+
this.byEnd[chunk.end] = chunk;
|
|
1037
|
+
this.byStart[chunk.next.start] = chunk.next;
|
|
1038
|
+
this.byEnd[chunk.next.end] = chunk.next;
|
|
1046
1039
|
}
|
|
1047
1040
|
if (aborted) {
|
|
1048
1041
|
return true;
|
|
@@ -1056,7 +1049,6 @@ MagicString.prototype.trimEnd = function trimEnd(charType) {
|
|
|
1056
1049
|
return this;
|
|
1057
1050
|
};
|
|
1058
1051
|
MagicString.prototype.trimStartAborted = function trimStartAborted(charType) {
|
|
1059
|
-
var this$1 = this;
|
|
1060
1052
|
var rx = new RegExp('^' + (charType || '\\s') + '+');
|
|
1061
1053
|
this.intro = this.intro.replace(rx, '');
|
|
1062
1054
|
if (this.intro.length) {
|
|
@@ -1068,12 +1060,12 @@ MagicString.prototype.trimStartAborted = function trimStartAborted(charType) {
|
|
|
1068
1060
|
var aborted = chunk.trimStart(rx);
|
|
1069
1061
|
if (chunk.end !== end) {
|
|
1070
1062
|
// special case...
|
|
1071
|
-
if (chunk === this
|
|
1072
|
-
this
|
|
1063
|
+
if (chunk === this.lastChunk) {
|
|
1064
|
+
this.lastChunk = chunk.next;
|
|
1073
1065
|
}
|
|
1074
|
-
this
|
|
1075
|
-
this
|
|
1076
|
-
this
|
|
1066
|
+
this.byEnd[chunk.end] = chunk;
|
|
1067
|
+
this.byStart[chunk.next.start] = chunk.next;
|
|
1068
|
+
this.byEnd[chunk.next.end] = chunk.next;
|
|
1077
1069
|
}
|
|
1078
1070
|
if (aborted) {
|
|
1079
1071
|
return true;
|
|
@@ -1294,14 +1286,13 @@ Bundle.prototype.trim = function trim(charType) {
|
|
|
1294
1286
|
return this.trimStart(charType).trimEnd(charType);
|
|
1295
1287
|
};
|
|
1296
1288
|
Bundle.prototype.trimStart = function trimStart(charType) {
|
|
1297
|
-
var this$1 = this;
|
|
1298
1289
|
var rx = new RegExp('^' + (charType || '\\s') + '+');
|
|
1299
1290
|
this.intro = this.intro.replace(rx, '');
|
|
1300
1291
|
if (!this.intro) {
|
|
1301
1292
|
var source;
|
|
1302
1293
|
var i = 0;
|
|
1303
1294
|
do {
|
|
1304
|
-
source = this
|
|
1295
|
+
source = this.sources[i++];
|
|
1305
1296
|
if (!source) {
|
|
1306
1297
|
break;
|
|
1307
1298
|
}
|
|
@@ -1310,14 +1301,13 @@ Bundle.prototype.trimStart = function trimStart(charType) {
|
|
|
1310
1301
|
return this;
|
|
1311
1302
|
};
|
|
1312
1303
|
Bundle.prototype.trimEnd = function trimEnd(charType) {
|
|
1313
|
-
var this$1 = this;
|
|
1314
1304
|
var rx = new RegExp((charType || '\\s') + '+$');
|
|
1315
1305
|
var source;
|
|
1316
1306
|
var i = this.sources.length - 1;
|
|
1317
1307
|
do {
|
|
1318
|
-
source = this
|
|
1308
|
+
source = this.sources[i--];
|
|
1319
1309
|
if (!source) {
|
|
1320
|
-
this
|
|
1310
|
+
this.intro = this.intro.replace(rx, '');
|
|
1321
1311
|
break;
|
|
1322
1312
|
}
|
|
1323
1313
|
} while (!source.content.trimEndAborted(charType));
|
|
@@ -2610,7 +2600,7 @@ class Variable {
|
|
|
2610
2600
|
}
|
|
2611
2601
|
getName() {
|
|
2612
2602
|
const name = this.renderName || this.name;
|
|
2613
|
-
return this.renderBaseName ? `${this.renderBaseName}
|
|
2603
|
+
return this.renderBaseName ? `${this.renderBaseName}${getPropertyAccess(name)}` : name;
|
|
2614
2604
|
}
|
|
2615
2605
|
getReturnExpressionWhenCalledAtPath(_path, _recursionTracker, _origin) {
|
|
2616
2606
|
return UNKNOWN_EXPRESSION;
|
|
@@ -2650,6 +2640,9 @@ class Variable {
|
|
|
2650
2640
|
return this.name;
|
|
2651
2641
|
}
|
|
2652
2642
|
}
|
|
2643
|
+
const getPropertyAccess = (name) => {
|
|
2644
|
+
return /^(?!\d)[\w$]+$/.test(name) ? `.${name}` : `[${JSON.stringify(name)}]`;
|
|
2645
|
+
};
|
|
2653
2646
|
|
|
2654
2647
|
class ExternalVariable extends Variable {
|
|
2655
2648
|
constructor(module, name) {
|
|
@@ -2922,8 +2915,7 @@ class LocalVariable extends Variable {
|
|
|
2922
2915
|
if (trackedExpressions.has(this))
|
|
2923
2916
|
return false;
|
|
2924
2917
|
trackedExpressions.add(this);
|
|
2925
|
-
return (this.init &&
|
|
2926
|
-
this.init.hasEffectsWhenCalledAtPath(path, callOptions, context));
|
|
2918
|
+
return (this.init && this.init.hasEffectsWhenCalledAtPath(path, callOptions, context));
|
|
2927
2919
|
}
|
|
2928
2920
|
include(context) {
|
|
2929
2921
|
if (!this.included) {
|
|
@@ -4504,7 +4496,7 @@ class Identifier$1 extends NodeBase {
|
|
|
4504
4496
|
}
|
|
4505
4497
|
}
|
|
4506
4498
|
disallowImportReassignment() {
|
|
4507
|
-
this.context.error({
|
|
4499
|
+
return this.context.error({
|
|
4508
4500
|
code: 'ILLEGAL_REASSIGNMENT',
|
|
4509
4501
|
message: `Illegal reassignment to import '${this.name}'`
|
|
4510
4502
|
}, this.start);
|
|
@@ -4836,7 +4828,7 @@ class ExportShimVariable extends Variable {
|
|
|
4836
4828
|
}
|
|
4837
4829
|
|
|
4838
4830
|
class NamespaceVariable extends Variable {
|
|
4839
|
-
constructor(context) {
|
|
4831
|
+
constructor(context, syntheticNamedExports) {
|
|
4840
4832
|
super(context.getModuleName());
|
|
4841
4833
|
this.memberVariables = Object.create(null);
|
|
4842
4834
|
this.containsExternalNamespace = false;
|
|
@@ -4844,6 +4836,7 @@ class NamespaceVariable extends Variable {
|
|
|
4844
4836
|
this.references = [];
|
|
4845
4837
|
this.context = context;
|
|
4846
4838
|
this.module = context.module;
|
|
4839
|
+
this.syntheticNamedExports = syntheticNamedExports;
|
|
4847
4840
|
}
|
|
4848
4841
|
addReference(identifier) {
|
|
4849
4842
|
this.references.push(identifier);
|
|
@@ -4861,11 +4854,11 @@ class NamespaceVariable extends Variable {
|
|
|
4861
4854
|
include(context) {
|
|
4862
4855
|
if (!this.included) {
|
|
4863
4856
|
if (this.containsExternalNamespace) {
|
|
4864
|
-
this.context.error({
|
|
4857
|
+
return this.context.error({
|
|
4865
4858
|
code: 'NAMESPACE_CANNOT_CONTAIN_EXTERNAL',
|
|
4866
4859
|
id: this.module.id,
|
|
4867
4860
|
message: `Cannot create an explicit namespace object for module "${this.context.getModuleName()}" because it contains a reexported external namespace`
|
|
4868
|
-
}
|
|
4861
|
+
});
|
|
4869
4862
|
}
|
|
4870
4863
|
this.included = true;
|
|
4871
4864
|
for (const identifier of this.references) {
|
|
@@ -4908,9 +4901,14 @@ class NamespaceVariable extends Variable {
|
|
|
4908
4901
|
members.unshift(`${t}[Symbol.toStringTag]:${_}'Module'`);
|
|
4909
4902
|
}
|
|
4910
4903
|
const name = this.getName();
|
|
4911
|
-
|
|
4912
|
-
|
|
4913
|
-
|
|
4904
|
+
let output = `{${n}${members.join(`,${n}`)}${n}}`;
|
|
4905
|
+
if (this.syntheticNamedExports) {
|
|
4906
|
+
output = `/*#__PURE__*/Object.assign(${output}, ${this.module.getDefaultExport().getName()})`;
|
|
4907
|
+
}
|
|
4908
|
+
if (options.freeze) {
|
|
4909
|
+
output = `/*#__PURE__*/Object.freeze(${output})`;
|
|
4910
|
+
}
|
|
4911
|
+
output = `${options.varOrConst} ${name}${_}=${_}${output};`;
|
|
4914
4912
|
if (options.format === 'system' && this.exportName) {
|
|
4915
4913
|
output += `${n}exports('${this.exportName}',${_}${name});`;
|
|
4916
4914
|
}
|
|
@@ -5443,6 +5441,8 @@ var Errors;
|
|
|
5443
5441
|
Errors["UNRESOLVED_ENTRY"] = "UNRESOLVED_ENTRY";
|
|
5444
5442
|
Errors["UNRESOLVED_IMPORT"] = "UNRESOLVED_IMPORT";
|
|
5445
5443
|
Errors["VALIDATION_ERROR"] = "VALIDATION_ERROR";
|
|
5444
|
+
Errors["EXTERNAL_SYNTHETIC_EXPORTS"] = "EXTERNAL_SYNTHETIC_EXPORTS";
|
|
5445
|
+
Errors["SYNTHETIC_NAMED_EXPORTS_NEED_DEFAULT"] = "SYNTHETIC_NAMED_EXPORTS_NEED_DEFAULT";
|
|
5446
5446
|
})(Errors || (Errors = {}));
|
|
5447
5447
|
function errAssetNotFinalisedForFileName(name) {
|
|
5448
5448
|
return {
|
|
@@ -5595,6 +5595,14 @@ function errUnresolvedImportTreatedAsExternal(source, importer) {
|
|
|
5595
5595
|
url: 'https://rollupjs.org/guide/en/#warning-treating-module-as-external-dependency'
|
|
5596
5596
|
};
|
|
5597
5597
|
}
|
|
5598
|
+
function errExternalSyntheticExports(source, importer) {
|
|
5599
|
+
return {
|
|
5600
|
+
code: Errors.EXTERNAL_SYNTHETIC_EXPORTS,
|
|
5601
|
+
importer: relativeId(importer),
|
|
5602
|
+
message: `External '${source}' can not have 'syntheticNamedExports' enabled.`,
|
|
5603
|
+
source
|
|
5604
|
+
};
|
|
5605
|
+
}
|
|
5598
5606
|
function errFailedValidation(message) {
|
|
5599
5607
|
return {
|
|
5600
5608
|
code: Errors.VALIDATION_ERROR,
|
|
@@ -5665,7 +5673,7 @@ function iife(magicString, { dependencies, exports, hasExports, indentString: t,
|
|
|
5665
5673
|
const isNamespaced = name && name.indexOf('.') !== -1;
|
|
5666
5674
|
const useVariableAssignment = !extend && !isNamespaced;
|
|
5667
5675
|
if (name && useVariableAssignment && !isLegal(name)) {
|
|
5668
|
-
error({
|
|
5676
|
+
return error({
|
|
5669
5677
|
code: 'ILLEGAL_IDENTIFIER_AS_NAME',
|
|
5670
5678
|
message: `Given name "${name}" is not a legal JS identifier. If you need this, you can try "output.extend: true".`
|
|
5671
5679
|
});
|
|
@@ -5697,8 +5705,7 @@ function iife(magicString, { dependencies, exports, hasExports, indentString: t,
|
|
|
5697
5705
|
`${_}=${_}${wrapperIntro}`;
|
|
5698
5706
|
}
|
|
5699
5707
|
if (isNamespaced && hasExports) {
|
|
5700
|
-
wrapperIntro =
|
|
5701
|
-
setupNamespace(name, 'this', options.globals, options.compact) + wrapperIntro;
|
|
5708
|
+
wrapperIntro = setupNamespace(name, 'this', options.globals, options.compact) + wrapperIntro;
|
|
5702
5709
|
}
|
|
5703
5710
|
let wrapperOutro = `${n}${n}}(${deps.join(`,${_}`)}));`;
|
|
5704
5711
|
if (!extend && namedExportsMode && hasExports) {
|
|
@@ -5878,7 +5885,7 @@ function umd(magicString, { dependencies, exports, hasExports, indentString: t,
|
|
|
5878
5885
|
const factoryVar = options.compact ? 'f' : 'factory';
|
|
5879
5886
|
const globalVar = options.compact ? 'g' : 'global';
|
|
5880
5887
|
if (hasExports && !options.name) {
|
|
5881
|
-
error({
|
|
5888
|
+
return error({
|
|
5882
5889
|
code: 'INVALID_OPTION',
|
|
5883
5890
|
message: 'You must supply "output.name" for UMD bundles.'
|
|
5884
5891
|
});
|
|
@@ -6212,13 +6219,13 @@ function getSystemExportStatement(exportedVariables) {
|
|
|
6212
6219
|
}
|
|
6213
6220
|
|
|
6214
6221
|
class AssignmentExpression extends NodeBase {
|
|
6215
|
-
|
|
6216
|
-
super
|
|
6217
|
-
this.
|
|
6218
|
-
// We cannot propagate mutations of the new binding to the old binding with certainty
|
|
6219
|
-
this.right.deoptimizePath(UNKNOWN_PATH);
|
|
6222
|
+
constructor() {
|
|
6223
|
+
super(...arguments);
|
|
6224
|
+
this.deoptimized = false;
|
|
6220
6225
|
}
|
|
6221
6226
|
hasEffects(context) {
|
|
6227
|
+
if (!this.deoptimized)
|
|
6228
|
+
this.applyDeoptimizations();
|
|
6222
6229
|
return (this.right.hasEffects(context) ||
|
|
6223
6230
|
this.left.hasEffects(context) ||
|
|
6224
6231
|
this.left.hasEffectsWhenAssignedAtPath(EMPTY_PATH, context));
|
|
@@ -6226,6 +6233,13 @@ class AssignmentExpression extends NodeBase {
|
|
|
6226
6233
|
hasEffectsWhenAccessedAtPath(path, context) {
|
|
6227
6234
|
return path.length > 0 && this.right.hasEffectsWhenAccessedAtPath(path, context);
|
|
6228
6235
|
}
|
|
6236
|
+
include(context, includeChildrenRecursively) {
|
|
6237
|
+
if (!this.deoptimized)
|
|
6238
|
+
this.applyDeoptimizations();
|
|
6239
|
+
this.included = true;
|
|
6240
|
+
this.left.include(context, includeChildrenRecursively);
|
|
6241
|
+
this.right.include(context, includeChildrenRecursively);
|
|
6242
|
+
}
|
|
6229
6243
|
render(code, options) {
|
|
6230
6244
|
this.left.render(code, options);
|
|
6231
6245
|
this.right.render(code, options);
|
|
@@ -6248,6 +6262,11 @@ class AssignmentExpression extends NodeBase {
|
|
|
6248
6262
|
}
|
|
6249
6263
|
}
|
|
6250
6264
|
}
|
|
6265
|
+
applyDeoptimizations() {
|
|
6266
|
+
this.deoptimized = true;
|
|
6267
|
+
this.left.deoptimizePath(EMPTY_PATH);
|
|
6268
|
+
this.right.deoptimizePath(UNKNOWN_PATH);
|
|
6269
|
+
}
|
|
6251
6270
|
}
|
|
6252
6271
|
|
|
6253
6272
|
class AssignmentPattern extends NodeBase {
|
|
@@ -6629,7 +6648,7 @@ class MemberExpression extends NodeBase {
|
|
|
6629
6648
|
disallowNamespaceReassignment() {
|
|
6630
6649
|
if (this.object instanceof Identifier$1 &&
|
|
6631
6650
|
this.scope.findVariable(this.object.name).isNamespace) {
|
|
6632
|
-
this.context.error({
|
|
6651
|
+
return this.context.error({
|
|
6633
6652
|
code: 'ILLEGAL_NAMESPACE_REASSIGNMENT',
|
|
6634
6653
|
message: `Illegal reassignment to import '${this.object.name}'`
|
|
6635
6654
|
}, this.start);
|
|
@@ -6682,7 +6701,7 @@ class CallExpression$1 extends NodeBase {
|
|
|
6682
6701
|
if (this.callee instanceof Identifier$1) {
|
|
6683
6702
|
const variable = this.scope.findVariable(this.callee.name);
|
|
6684
6703
|
if (variable.isNamespace) {
|
|
6685
|
-
this.context.error({
|
|
6704
|
+
return this.context.error({
|
|
6686
6705
|
code: 'CANNOT_CALL_NAMESPACE',
|
|
6687
6706
|
message: `Cannot call a namespace ('${this.callee.name}')`
|
|
6688
6707
|
}, this.start);
|
|
@@ -7050,8 +7069,8 @@ class ConditionalExpression extends NodeBase {
|
|
|
7050
7069
|
include(context, includeChildrenRecursively) {
|
|
7051
7070
|
this.included = true;
|
|
7052
7071
|
if (includeChildrenRecursively ||
|
|
7053
|
-
this.
|
|
7054
|
-
this.
|
|
7072
|
+
this.test.shouldBeIncluded(context) ||
|
|
7073
|
+
this.usedBranch === null) {
|
|
7055
7074
|
this.test.include(context, includeChildrenRecursively);
|
|
7056
7075
|
this.consequent.include(context, includeChildrenRecursively);
|
|
7057
7076
|
this.alternate.include(context, includeChildrenRecursively);
|
|
@@ -7301,19 +7320,21 @@ class ForStatement extends NodeBase {
|
|
|
7301
7320
|
class FunctionExpression$1 extends FunctionNode {
|
|
7302
7321
|
}
|
|
7303
7322
|
|
|
7323
|
+
const unset = Symbol('unset');
|
|
7304
7324
|
class IfStatement extends NodeBase {
|
|
7305
|
-
|
|
7306
|
-
super
|
|
7307
|
-
|
|
7308
|
-
this.testValue = this.test.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, this);
|
|
7325
|
+
constructor() {
|
|
7326
|
+
super(...arguments);
|
|
7327
|
+
this.testValue = unset;
|
|
7309
7328
|
}
|
|
7310
7329
|
deoptimizeCache() {
|
|
7311
7330
|
this.testValue = UnknownValue;
|
|
7312
7331
|
}
|
|
7313
7332
|
hasEffects(context) {
|
|
7314
|
-
if (this.test.hasEffects(context))
|
|
7333
|
+
if (this.test.hasEffects(context)) {
|
|
7315
7334
|
return true;
|
|
7316
|
-
|
|
7335
|
+
}
|
|
7336
|
+
const testValue = this.getTestValue();
|
|
7337
|
+
if (testValue === UnknownValue) {
|
|
7317
7338
|
const { brokenFlow } = context;
|
|
7318
7339
|
if (this.consequent.hasEffects(context))
|
|
7319
7340
|
return true;
|
|
@@ -7327,7 +7348,7 @@ class IfStatement extends NodeBase {
|
|
|
7327
7348
|
context.brokenFlow < consequentBrokenFlow ? context.brokenFlow : consequentBrokenFlow;
|
|
7328
7349
|
return false;
|
|
7329
7350
|
}
|
|
7330
|
-
return
|
|
7351
|
+
return testValue
|
|
7331
7352
|
? this.consequent.hasEffects(context)
|
|
7332
7353
|
: this.alternate !== null && this.alternate.hasEffects(context);
|
|
7333
7354
|
}
|
|
@@ -7336,22 +7357,22 @@ class IfStatement extends NodeBase {
|
|
|
7336
7357
|
if (includeChildrenRecursively) {
|
|
7337
7358
|
this.includeRecursively(includeChildrenRecursively, context);
|
|
7338
7359
|
}
|
|
7339
|
-
else if (this.testValue === UnknownValue) {
|
|
7340
|
-
this.includeUnknownTest(context);
|
|
7341
|
-
}
|
|
7342
7360
|
else {
|
|
7343
|
-
this.
|
|
7361
|
+
const testValue = this.getTestValue();
|
|
7362
|
+
if (testValue === UnknownValue) {
|
|
7363
|
+
this.includeUnknownTest(context);
|
|
7364
|
+
}
|
|
7365
|
+
else {
|
|
7366
|
+
this.includeKnownTest(context, testValue);
|
|
7367
|
+
}
|
|
7344
7368
|
}
|
|
7345
7369
|
}
|
|
7346
7370
|
render(code, options) {
|
|
7347
7371
|
// Note that unknown test values are always included
|
|
7372
|
+
const testValue = this.getTestValue();
|
|
7348
7373
|
if (!this.test.included &&
|
|
7349
|
-
(this.
|
|
7350
|
-
|
|
7351
|
-
: !this.consequent.included)) {
|
|
7352
|
-
const singleRetainedBranch = (this.testValue
|
|
7353
|
-
? this.consequent
|
|
7354
|
-
: this.alternate);
|
|
7374
|
+
(testValue ? this.alternate === null || !this.alternate.included : !this.consequent.included)) {
|
|
7375
|
+
const singleRetainedBranch = (testValue ? this.consequent : this.alternate);
|
|
7355
7376
|
code.remove(this.start, singleRetainedBranch.start);
|
|
7356
7377
|
code.remove(singleRetainedBranch.end, this.end);
|
|
7357
7378
|
removeAnnotations(this, code);
|
|
@@ -7362,7 +7383,7 @@ class IfStatement extends NodeBase {
|
|
|
7362
7383
|
this.test.render(code, options);
|
|
7363
7384
|
}
|
|
7364
7385
|
else {
|
|
7365
|
-
code.overwrite(this.test.start, this.test.end,
|
|
7386
|
+
code.overwrite(this.test.start, this.test.end, testValue ? 'true' : 'false');
|
|
7366
7387
|
}
|
|
7367
7388
|
if (this.consequent.included) {
|
|
7368
7389
|
this.consequent.render(code, options);
|
|
@@ -7380,14 +7401,20 @@ class IfStatement extends NodeBase {
|
|
|
7380
7401
|
}
|
|
7381
7402
|
}
|
|
7382
7403
|
}
|
|
7383
|
-
|
|
7404
|
+
getTestValue() {
|
|
7405
|
+
if (this.testValue === unset) {
|
|
7406
|
+
return (this.testValue = this.test.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, this));
|
|
7407
|
+
}
|
|
7408
|
+
return this.testValue;
|
|
7409
|
+
}
|
|
7410
|
+
includeKnownTest(context, testValue) {
|
|
7384
7411
|
if (this.test.shouldBeIncluded(context)) {
|
|
7385
7412
|
this.test.include(context, false);
|
|
7386
7413
|
}
|
|
7387
|
-
if (
|
|
7414
|
+
if (testValue && this.consequent.shouldBeIncluded(context)) {
|
|
7388
7415
|
this.consequent.include(context, false);
|
|
7389
7416
|
}
|
|
7390
|
-
if (this.alternate !== null && !
|
|
7417
|
+
if (this.alternate !== null && !testValue && this.alternate.shouldBeIncluded(context)) {
|
|
7391
7418
|
this.alternate.include(context, false);
|
|
7392
7419
|
}
|
|
7393
7420
|
}
|
|
@@ -7667,8 +7694,8 @@ class LogicalExpression extends NodeBase {
|
|
|
7667
7694
|
include(context, includeChildrenRecursively) {
|
|
7668
7695
|
this.included = true;
|
|
7669
7696
|
if (includeChildrenRecursively ||
|
|
7670
|
-
this.usedBranch ===
|
|
7671
|
-
this.
|
|
7697
|
+
(this.usedBranch === this.right && this.left.shouldBeIncluded(context)) ||
|
|
7698
|
+
this.usedBranch === null) {
|
|
7672
7699
|
this.left.include(context, includeChildrenRecursively);
|
|
7673
7700
|
this.right.include(context, includeChildrenRecursively);
|
|
7674
7701
|
}
|
|
@@ -7802,7 +7829,7 @@ function addJsExtensionIfNecessary(file, preserveSymlinks) {
|
|
|
7802
7829
|
function createResolveId(preserveSymlinks) {
|
|
7803
7830
|
return function (source, importer) {
|
|
7804
7831
|
if (typeof process === 'undefined') {
|
|
7805
|
-
error({
|
|
7832
|
+
return error({
|
|
7806
7833
|
code: 'MISSING_PROCESS',
|
|
7807
7834
|
message: `It looks like you're using Rollup in a non-Node.js environment. This means you must supply a plugin with custom resolveId and load functions`,
|
|
7808
7835
|
url: 'https://rollupjs.org/guide/en/#a-simple-example'
|
|
@@ -8386,8 +8413,7 @@ class Property$1 extends NodeBase {
|
|
|
8386
8413
|
return false;
|
|
8387
8414
|
trackedExpressions.add(this);
|
|
8388
8415
|
return (this.value.hasEffectsWhenCalledAtPath(EMPTY_PATH, this.accessorCallOptions, context) ||
|
|
8389
|
-
(path.length > 0 &&
|
|
8390
|
-
this.returnExpression.hasEffectsWhenAccessedAtPath(path, context)));
|
|
8416
|
+
(path.length > 0 && this.returnExpression.hasEffectsWhenAccessedAtPath(path, context)));
|
|
8391
8417
|
}
|
|
8392
8418
|
return this.value.hasEffectsWhenAccessedAtPath(path, context);
|
|
8393
8419
|
}
|
|
@@ -8642,14 +8668,15 @@ class TaggedTemplateExpression extends NodeBase {
|
|
|
8642
8668
|
bind() {
|
|
8643
8669
|
super.bind();
|
|
8644
8670
|
if (this.tag.type === Identifier) {
|
|
8645
|
-
const
|
|
8671
|
+
const name = this.tag.name;
|
|
8672
|
+
const variable = this.scope.findVariable(name);
|
|
8646
8673
|
if (variable.isNamespace) {
|
|
8647
|
-
this.context.error({
|
|
8674
|
+
return this.context.error({
|
|
8648
8675
|
code: 'CANNOT_CALL_NAMESPACE',
|
|
8649
|
-
message: `Cannot call a namespace ('${
|
|
8676
|
+
message: `Cannot call a namespace ('${name}')`
|
|
8650
8677
|
}, this.start);
|
|
8651
8678
|
}
|
|
8652
|
-
if (
|
|
8679
|
+
if (name === 'eval') {
|
|
8653
8680
|
this.context.warn({
|
|
8654
8681
|
code: 'EVAL',
|
|
8655
8682
|
message: `Use of eval is strongly discouraged, as it poses security risks and may cause issues with minification`,
|
|
@@ -9022,8 +9049,7 @@ class VariableDeclaration extends NodeBase {
|
|
|
9022
9049
|
node.id.addExportedVariables(systemPatternExports);
|
|
9023
9050
|
}
|
|
9024
9051
|
else if (node.id.variable.exportName) {
|
|
9025
|
-
code.prependLeft(code.original.indexOf('=', node.id.end) + 1, ` exports('${node.id.variable.safeExportName ||
|
|
9026
|
-
node.id.variable.exportName}',`);
|
|
9052
|
+
code.prependLeft(code.original.indexOf('=', node.id.end) + 1, ` exports('${node.id.variable.safeExportName || node.id.variable.exportName}',`);
|
|
9027
9053
|
nextSeparatorString += ')';
|
|
9028
9054
|
}
|
|
9029
9055
|
}
|
|
@@ -9188,6 +9214,22 @@ const nodeConstructors = {
|
|
|
9188
9214
|
YieldExpression
|
|
9189
9215
|
};
|
|
9190
9216
|
|
|
9217
|
+
class SyntheticNamedExportVariableVariable extends Variable {
|
|
9218
|
+
constructor(context, name, defaultVariable) {
|
|
9219
|
+
super(name);
|
|
9220
|
+
this.context = context;
|
|
9221
|
+
this.module = context.module;
|
|
9222
|
+
this.defaultVariable = defaultVariable;
|
|
9223
|
+
this.setRenderNames(defaultVariable.getName(), name);
|
|
9224
|
+
}
|
|
9225
|
+
include(context) {
|
|
9226
|
+
if (!this.included) {
|
|
9227
|
+
this.included = true;
|
|
9228
|
+
this.context.includeVariable(context, this.defaultVariable);
|
|
9229
|
+
}
|
|
9230
|
+
}
|
|
9231
|
+
}
|
|
9232
|
+
|
|
9191
9233
|
function getOriginalLocation(sourcemapChain, location) {
|
|
9192
9234
|
// This cast is guaranteed. If it were a missing Map, it wouldn't have a mappings.
|
|
9193
9235
|
const filteredSourcemapChain = sourcemapChain.filter(sourcemap => sourcemap.mappings);
|
|
@@ -9645,12 +9687,12 @@ function tryParse(module, Parser, acornOptions) {
|
|
|
9645
9687
|
catch (err) {
|
|
9646
9688
|
let message = err.message.replace(/ \(\d+:\d+\)$/, '');
|
|
9647
9689
|
if (module.id.endsWith('.json')) {
|
|
9648
|
-
message += ' (Note that you need rollup
|
|
9690
|
+
message += ' (Note that you need @rollup/plugin-json to import JSON files)';
|
|
9649
9691
|
}
|
|
9650
9692
|
else if (!module.id.endsWith('.js')) {
|
|
9651
9693
|
message += ' (Note that you need plugins to import files that are not JavaScript)';
|
|
9652
9694
|
}
|
|
9653
|
-
module.error({
|
|
9695
|
+
return module.error({
|
|
9654
9696
|
code: 'PARSE_ERROR',
|
|
9655
9697
|
message,
|
|
9656
9698
|
parserError: err
|
|
@@ -9658,7 +9700,7 @@ function tryParse(module, Parser, acornOptions) {
|
|
|
9658
9700
|
}
|
|
9659
9701
|
}
|
|
9660
9702
|
function handleMissingExport(exportName, importingModule, importedModule, importerStart) {
|
|
9661
|
-
importingModule.error({
|
|
9703
|
+
return importingModule.error({
|
|
9662
9704
|
code: 'MISSING_EXPORT',
|
|
9663
9705
|
message: `'${exportName}' is not exported by ${relativeId(importedModule)}`,
|
|
9664
9706
|
url: `https://rollupjs.org/guide/en/#error-name-is-not-exported-by-module`
|
|
@@ -9668,8 +9710,21 @@ const MISSING_EXPORT_SHIM_DESCRIPTION = {
|
|
|
9668
9710
|
identifier: null,
|
|
9669
9711
|
localName: MISSING_EXPORT_SHIM_VARIABLE
|
|
9670
9712
|
};
|
|
9713
|
+
function getVariableForExportNameRecursive(target, name, isExportAllSearch, searchedNamesAndModules = new Map()) {
|
|
9714
|
+
const searchedModules = searchedNamesAndModules.get(name);
|
|
9715
|
+
if (searchedModules) {
|
|
9716
|
+
if (searchedModules.has(target)) {
|
|
9717
|
+
return null;
|
|
9718
|
+
}
|
|
9719
|
+
searchedModules.add(target);
|
|
9720
|
+
}
|
|
9721
|
+
else {
|
|
9722
|
+
searchedNamesAndModules.set(name, new Set([target]));
|
|
9723
|
+
}
|
|
9724
|
+
return target.getVariableForExportName(name, isExportAllSearch, searchedNamesAndModules);
|
|
9725
|
+
}
|
|
9671
9726
|
class Module {
|
|
9672
|
-
constructor(graph, id, moduleSideEffects, isEntry) {
|
|
9727
|
+
constructor(graph, id, moduleSideEffects, syntheticNamedExports, isEntry) {
|
|
9673
9728
|
this.chunk = null;
|
|
9674
9729
|
this.chunkFileNames = new Set();
|
|
9675
9730
|
this.chunkName = null;
|
|
@@ -9697,7 +9752,9 @@ class Module {
|
|
|
9697
9752
|
this.userChunkNames = new Set();
|
|
9698
9753
|
this.usesTopLevelAwait = false;
|
|
9699
9754
|
this.allExportNames = null;
|
|
9755
|
+
this.defaultExport = null;
|
|
9700
9756
|
this.namespaceVariable = null;
|
|
9757
|
+
this.syntheticExports = new Map();
|
|
9701
9758
|
this.transformDependencies = [];
|
|
9702
9759
|
this.transitiveReexports = null;
|
|
9703
9760
|
this.id = id;
|
|
@@ -9705,6 +9762,7 @@ class Module {
|
|
|
9705
9762
|
this.excludeFromSourcemap = /\0/.test(id);
|
|
9706
9763
|
this.context = graph.getModuleContext(id);
|
|
9707
9764
|
this.moduleSideEffects = moduleSideEffects;
|
|
9765
|
+
this.syntheticNamedExports = syntheticNamedExports;
|
|
9708
9766
|
this.isEntryPoint = isEntry;
|
|
9709
9767
|
}
|
|
9710
9768
|
basename() {
|
|
@@ -9716,7 +9774,7 @@ class Module {
|
|
|
9716
9774
|
this.ast.bind();
|
|
9717
9775
|
}
|
|
9718
9776
|
error(props, pos) {
|
|
9719
|
-
if (pos
|
|
9777
|
+
if (typeof pos === 'number') {
|
|
9720
9778
|
props.pos = pos;
|
|
9721
9779
|
let location = locate(this.code, pos, { offsetLine: 1 });
|
|
9722
9780
|
try {
|
|
@@ -9732,7 +9790,7 @@ class Module {
|
|
|
9732
9790
|
},
|
|
9733
9791
|
message: `Error when using sourcemap for reporting an error: ${e.message}`,
|
|
9734
9792
|
pos
|
|
9735
|
-
}
|
|
9793
|
+
});
|
|
9736
9794
|
}
|
|
9737
9795
|
props.loc = {
|
|
9738
9796
|
column: location.column,
|
|
@@ -9741,7 +9799,7 @@ class Module {
|
|
|
9741
9799
|
};
|
|
9742
9800
|
props.frame = getCodeFrame(this.originalCode, location.line, location.column);
|
|
9743
9801
|
}
|
|
9744
|
-
error(props);
|
|
9802
|
+
return error(props);
|
|
9745
9803
|
}
|
|
9746
9804
|
getAllExportNames() {
|
|
9747
9805
|
if (this.allExportNames) {
|
|
@@ -9766,6 +9824,20 @@ class Module {
|
|
|
9766
9824
|
}
|
|
9767
9825
|
return allExportNames;
|
|
9768
9826
|
}
|
|
9827
|
+
getDefaultExport() {
|
|
9828
|
+
if (this.defaultExport === null) {
|
|
9829
|
+
this.defaultExport = undefined;
|
|
9830
|
+
this.defaultExport = this.getVariableForExportName('default');
|
|
9831
|
+
}
|
|
9832
|
+
if (!this.defaultExport) {
|
|
9833
|
+
return error({
|
|
9834
|
+
code: Errors.SYNTHETIC_NAMED_EXPORTS_NEED_DEFAULT,
|
|
9835
|
+
id: this.id,
|
|
9836
|
+
message: `Modules with 'syntheticNamedExports' need a default export.`
|
|
9837
|
+
});
|
|
9838
|
+
}
|
|
9839
|
+
return this.defaultExport;
|
|
9840
|
+
}
|
|
9769
9841
|
getDynamicImportExpressions() {
|
|
9770
9842
|
return this.dynamicImports.map(({ node }) => {
|
|
9771
9843
|
const importArgument = node.source;
|
|
@@ -9803,7 +9875,7 @@ class Module {
|
|
|
9803
9875
|
}
|
|
9804
9876
|
getOrCreateNamespace() {
|
|
9805
9877
|
if (!this.namespaceVariable) {
|
|
9806
|
-
this.namespaceVariable = new NamespaceVariable(this.astContext);
|
|
9878
|
+
this.namespaceVariable = new NamespaceVariable(this.astContext, this.syntheticNamedExports);
|
|
9807
9879
|
this.namespaceVariable.initialise();
|
|
9808
9880
|
}
|
|
9809
9881
|
return this.namespaceVariable;
|
|
@@ -9846,7 +9918,7 @@ class Module {
|
|
|
9846
9918
|
.concat(this.getExports())
|
|
9847
9919
|
.map((exportName) => this.getVariableForExportName(exportName).module));
|
|
9848
9920
|
}
|
|
9849
|
-
getVariableForExportName(name, isExportAllSearch) {
|
|
9921
|
+
getVariableForExportName(name, isExportAllSearch, searchedNamesAndModules) {
|
|
9850
9922
|
if (name[0] === '*') {
|
|
9851
9923
|
if (name.length === 1) {
|
|
9852
9924
|
return this.getOrCreateNamespace();
|
|
@@ -9860,9 +9932,9 @@ class Module {
|
|
|
9860
9932
|
// export { foo } from './other'
|
|
9861
9933
|
const reexportDeclaration = this.reexportDescriptions[name];
|
|
9862
9934
|
if (reexportDeclaration) {
|
|
9863
|
-
const declaration = reexportDeclaration.module
|
|
9935
|
+
const declaration = getVariableForExportNameRecursive(reexportDeclaration.module, reexportDeclaration.localName, false, searchedNamesAndModules);
|
|
9864
9936
|
if (!declaration) {
|
|
9865
|
-
handleMissingExport(reexportDeclaration.localName, this, reexportDeclaration.module.id, reexportDeclaration.start);
|
|
9937
|
+
return handleMissingExport(reexportDeclaration.localName, this, reexportDeclaration.module.id, reexportDeclaration.start);
|
|
9866
9938
|
}
|
|
9867
9939
|
return declaration;
|
|
9868
9940
|
}
|
|
@@ -9876,18 +9948,30 @@ class Module {
|
|
|
9876
9948
|
}
|
|
9877
9949
|
if (name !== 'default') {
|
|
9878
9950
|
for (const module of this.exportAllModules) {
|
|
9879
|
-
const declaration = module
|
|
9951
|
+
const declaration = getVariableForExportNameRecursive(module, name, true, searchedNamesAndModules);
|
|
9880
9952
|
if (declaration)
|
|
9881
9953
|
return declaration;
|
|
9882
9954
|
}
|
|
9883
9955
|
}
|
|
9884
9956
|
// we don't want to create shims when we are just
|
|
9885
9957
|
// probing export * modules for exports
|
|
9886
|
-
if (
|
|
9887
|
-
this.
|
|
9888
|
-
|
|
9958
|
+
if (!isExportAllSearch) {
|
|
9959
|
+
if (this.syntheticNamedExports) {
|
|
9960
|
+
let syntheticExport = this.syntheticExports.get(name);
|
|
9961
|
+
if (!syntheticExport) {
|
|
9962
|
+
const defaultExport = this.getDefaultExport();
|
|
9963
|
+
syntheticExport = new SyntheticNamedExportVariableVariable(this.astContext, name, defaultExport);
|
|
9964
|
+
this.syntheticExports.set(name, syntheticExport);
|
|
9965
|
+
return syntheticExport;
|
|
9966
|
+
}
|
|
9967
|
+
return syntheticExport;
|
|
9968
|
+
}
|
|
9969
|
+
if (this.graph.shimMissingExports) {
|
|
9970
|
+
this.shimMissingExport(name);
|
|
9971
|
+
return this.exportShimVariable;
|
|
9972
|
+
}
|
|
9889
9973
|
}
|
|
9890
|
-
return
|
|
9974
|
+
return null;
|
|
9891
9975
|
}
|
|
9892
9976
|
include() {
|
|
9893
9977
|
const context = createInclusionContext();
|
|
@@ -9954,7 +10038,7 @@ class Module {
|
|
|
9954
10038
|
this.usesTopLevelAwait = this.astContext.usesTopLevelAwait;
|
|
9955
10039
|
return magicString;
|
|
9956
10040
|
}
|
|
9957
|
-
setSource({ ast, code, customTransformCache, moduleSideEffects, originalCode, originalSourcemap, resolvedIds, sourcemapChain, transformDependencies, transformFiles }) {
|
|
10041
|
+
setSource({ ast, code, customTransformCache, moduleSideEffects, originalCode, originalSourcemap, resolvedIds, sourcemapChain, syntheticNamedExports, transformDependencies, transformFiles }) {
|
|
9958
10042
|
this.code = code;
|
|
9959
10043
|
this.originalCode = originalCode;
|
|
9960
10044
|
this.originalSourcemap = originalSourcemap;
|
|
@@ -9967,6 +10051,9 @@ class Module {
|
|
|
9967
10051
|
if (typeof moduleSideEffects === 'boolean') {
|
|
9968
10052
|
this.moduleSideEffects = moduleSideEffects;
|
|
9969
10053
|
}
|
|
10054
|
+
if (typeof syntheticNamedExports === 'boolean') {
|
|
10055
|
+
this.syntheticNamedExports = syntheticNamedExports;
|
|
10056
|
+
}
|
|
9970
10057
|
timeStart('generate ast', 3);
|
|
9971
10058
|
this.esTreeAst = ast || tryParse(this, this.graph.acornParser, this.graph.acornOptions);
|
|
9972
10059
|
markPureCallExpressions(this.comments, this.esTreeAst);
|
|
@@ -9986,8 +10073,7 @@ class Module {
|
|
|
9986
10073
|
addExport: this.addExport.bind(this),
|
|
9987
10074
|
addImport: this.addImport.bind(this),
|
|
9988
10075
|
addImportMeta: this.addImportMeta.bind(this),
|
|
9989
|
-
annotations: (this.graph.treeshakingOptions &&
|
|
9990
|
-
this.graph.treeshakingOptions.annotations),
|
|
10076
|
+
annotations: (this.graph.treeshakingOptions && this.graph.treeshakingOptions.annotations),
|
|
9991
10077
|
code,
|
|
9992
10078
|
deoptimizationTracker: this.graph.deoptimizationTracker,
|
|
9993
10079
|
error: this.error.bind(this),
|
|
@@ -10034,6 +10120,7 @@ class Module {
|
|
|
10034
10120
|
originalSourcemap: this.originalSourcemap,
|
|
10035
10121
|
resolvedIds: this.resolvedIds,
|
|
10036
10122
|
sourcemapChain: this.sourcemapChain,
|
|
10123
|
+
syntheticNamedExports: this.syntheticNamedExports,
|
|
10037
10124
|
transformDependencies: this.transformDependencies,
|
|
10038
10125
|
transformFiles: this.transformFiles
|
|
10039
10126
|
};
|
|
@@ -10051,14 +10138,14 @@ class Module {
|
|
|
10051
10138
|
}
|
|
10052
10139
|
const declaration = otherModule.getVariableForExportName(importDeclaration.name);
|
|
10053
10140
|
if (!declaration) {
|
|
10054
|
-
handleMissingExport(importDeclaration.name, this, otherModule.id, importDeclaration.start);
|
|
10141
|
+
return handleMissingExport(importDeclaration.name, this, otherModule.id, importDeclaration.start);
|
|
10055
10142
|
}
|
|
10056
10143
|
return declaration;
|
|
10057
10144
|
}
|
|
10058
10145
|
return null;
|
|
10059
10146
|
}
|
|
10060
10147
|
warn(warning, pos) {
|
|
10061
|
-
if (pos
|
|
10148
|
+
if (typeof pos === 'number') {
|
|
10062
10149
|
warning.pos = pos;
|
|
10063
10150
|
const { line, column } = locate(this.code, pos, { offsetLine: 1 }); // TODO trace sourcemaps, cf. error()
|
|
10064
10151
|
warning.loc = { file: this.id, line, column };
|
|
@@ -10130,7 +10217,7 @@ class Module {
|
|
|
10130
10217
|
for (const specifier of node.specifiers) {
|
|
10131
10218
|
const localName = specifier.local.name;
|
|
10132
10219
|
if (this.importDescriptions[localName]) {
|
|
10133
|
-
this.error({
|
|
10220
|
+
return this.error({
|
|
10134
10221
|
code: 'DUPLICATE_IMPORT',
|
|
10135
10222
|
message: `Duplicated import '${localName}'`
|
|
10136
10223
|
}, specifier.start);
|
|
@@ -10142,7 +10229,12 @@ class Module {
|
|
|
10142
10229
|
: isNamespace
|
|
10143
10230
|
? '*'
|
|
10144
10231
|
: specifier.imported.name;
|
|
10145
|
-
this.importDescriptions[localName] = {
|
|
10232
|
+
this.importDescriptions[localName] = {
|
|
10233
|
+
module: null,
|
|
10234
|
+
name,
|
|
10235
|
+
source,
|
|
10236
|
+
start: specifier.start
|
|
10237
|
+
};
|
|
10146
10238
|
}
|
|
10147
10239
|
}
|
|
10148
10240
|
addImportMeta(node) {
|
|
@@ -10235,7 +10327,7 @@ class Link {
|
|
|
10235
10327
|
}
|
|
10236
10328
|
else if (traced.source.content != null &&
|
|
10237
10329
|
sourcesContent[sourceIndex] !== traced.source.content) {
|
|
10238
|
-
error({
|
|
10330
|
+
return error({
|
|
10239
10331
|
message: `Multiple conflicting contents for sourcemap source ${traced.source.filename}`
|
|
10240
10332
|
});
|
|
10241
10333
|
}
|
|
@@ -10608,12 +10700,13 @@ function renderNamePattern(pattern, patternName, replacements) {
|
|
|
10608
10700
|
});
|
|
10609
10701
|
}
|
|
10610
10702
|
function makeUnique(name, existingNames) {
|
|
10611
|
-
|
|
10703
|
+
const existingNamesLowercase = new Set(Object.keys(existingNames).map(key => key.toLowerCase()));
|
|
10704
|
+
if (!existingNamesLowercase.has(name.toLocaleLowerCase()))
|
|
10612
10705
|
return name;
|
|
10613
10706
|
const ext = extname(name);
|
|
10614
10707
|
name = name.substr(0, name.length - ext.length);
|
|
10615
10708
|
let uniqueName, uniqueIndex = 1;
|
|
10616
|
-
while (
|
|
10709
|
+
while (existingNamesLowercase.has((uniqueName = name + ++uniqueIndex + ext).toLowerCase()))
|
|
10617
10710
|
;
|
|
10618
10711
|
return uniqueName;
|
|
10619
10712
|
}
|
|
@@ -11107,7 +11200,7 @@ class Chunk$1 {
|
|
|
11107
11200
|
}
|
|
11108
11201
|
}
|
|
11109
11202
|
if (usesTopLevelAwait && format !== 'es' && format !== 'system') {
|
|
11110
|
-
error({
|
|
11203
|
+
return error({
|
|
11111
11204
|
code: 'INVALID_TLA_FORMAT',
|
|
11112
11205
|
message: `Module format ${format} does not support top-level await. Use the "es" or "system" output formats rather.`
|
|
11113
11206
|
});
|
|
@@ -11880,6 +11973,7 @@ function transform(graph, source, module) {
|
|
|
11880
11973
|
const emittedFiles = [];
|
|
11881
11974
|
let customTransformCache = false;
|
|
11882
11975
|
let moduleSideEffects = null;
|
|
11976
|
+
let syntheticNamedExports = null;
|
|
11883
11977
|
let trackedPluginCache;
|
|
11884
11978
|
let curPlugin;
|
|
11885
11979
|
const curSource = source.code;
|
|
@@ -11921,6 +12015,9 @@ function transform(graph, source, module) {
|
|
|
11921
12015
|
if (typeof result.moduleSideEffects === 'boolean') {
|
|
11922
12016
|
moduleSideEffects = result.moduleSideEffects;
|
|
11923
12017
|
}
|
|
12018
|
+
if (typeof result.syntheticNamedExports === 'boolean') {
|
|
12019
|
+
syntheticNamedExports = result.syntheticNamedExports;
|
|
12020
|
+
}
|
|
11924
12021
|
}
|
|
11925
12022
|
else {
|
|
11926
12023
|
return code;
|
|
@@ -11981,7 +12078,7 @@ function transform(graph, source, module) {
|
|
|
11981
12078
|
pluginContext.setAssetSource(assetReferenceId, source);
|
|
11982
12079
|
if (!customTransformCache && !setAssetSourceErr) {
|
|
11983
12080
|
try {
|
|
11984
|
-
this.error({
|
|
12081
|
+
return this.error({
|
|
11985
12082
|
code: 'INVALID_SETASSETSOURCE',
|
|
11986
12083
|
message: `setAssetSource cannot be called in transform for caching reasons. Use emitFile with a source, or call setAssetSource in another hook.`
|
|
11987
12084
|
});
|
|
@@ -12016,6 +12113,7 @@ function transform(graph, source, module) {
|
|
|
12016
12113
|
originalCode,
|
|
12017
12114
|
originalSourcemap,
|
|
12018
12115
|
sourcemapChain,
|
|
12116
|
+
syntheticNamedExports,
|
|
12019
12117
|
transformDependencies
|
|
12020
12118
|
};
|
|
12021
12119
|
});
|
|
@@ -12072,7 +12170,7 @@ class ModuleLoader {
|
|
|
12072
12170
|
? resolveIdResult.id
|
|
12073
12171
|
: resolveIdResult;
|
|
12074
12172
|
if (typeof id === 'string') {
|
|
12075
|
-
return this.fetchModule(id, undefined, true, isEntry);
|
|
12173
|
+
return this.fetchModule(id, undefined, true, false, isEntry);
|
|
12076
12174
|
}
|
|
12077
12175
|
return error(errUnresolvedEntry(unresolvedId));
|
|
12078
12176
|
});
|
|
@@ -12145,7 +12243,7 @@ class ModuleLoader {
|
|
|
12145
12243
|
}
|
|
12146
12244
|
addModuleToManualChunk(alias, module) {
|
|
12147
12245
|
if (module.manualChunkAlias !== null && module.manualChunkAlias !== alias) {
|
|
12148
|
-
error(errCannotAssignModuleToChunk(module.id, alias, module.manualChunkAlias));
|
|
12246
|
+
return error(errCannotAssignModuleToChunk(module.id, alias, module.manualChunkAlias));
|
|
12149
12247
|
}
|
|
12150
12248
|
module.manualChunkAlias = alias;
|
|
12151
12249
|
if (!this.manualChunkModules[alias]) {
|
|
@@ -12173,7 +12271,7 @@ class ModuleLoader {
|
|
|
12173
12271
|
...Array.from(module.sources).map((source) => __awaiter(this, void 0, void 0, function* () {
|
|
12174
12272
|
return this.fetchResolvedDependency(source, module.id, (module.resolvedIds[source] =
|
|
12175
12273
|
module.resolvedIds[source] ||
|
|
12176
|
-
this.
|
|
12274
|
+
this.handleResolveId(yield this.resolveId(source, module.id), source, module.id)));
|
|
12177
12275
|
})),
|
|
12178
12276
|
...module.getDynamicImportExpressions().map((specifier, index) => this.resolveDynamicImport(module, specifier, module.id).then(resolvedId => {
|
|
12179
12277
|
if (resolvedId === null)
|
|
@@ -12189,13 +12287,13 @@ class ModuleLoader {
|
|
|
12189
12287
|
}))
|
|
12190
12288
|
]);
|
|
12191
12289
|
}
|
|
12192
|
-
fetchModule(id, importer, moduleSideEffects, isEntry) {
|
|
12290
|
+
fetchModule(id, importer, moduleSideEffects, syntheticNamedExports, isEntry) {
|
|
12193
12291
|
const existingModule = this.modulesById.get(id);
|
|
12194
12292
|
if (existingModule instanceof Module) {
|
|
12195
12293
|
existingModule.isEntryPoint = existingModule.isEntryPoint || isEntry;
|
|
12196
12294
|
return Promise.resolve(existingModule);
|
|
12197
12295
|
}
|
|
12198
|
-
const module = new Module(this.graph, id, moduleSideEffects, isEntry);
|
|
12296
|
+
const module = new Module(this.graph, id, moduleSideEffects, syntheticNamedExports, isEntry);
|
|
12199
12297
|
this.modulesById.set(id, module);
|
|
12200
12298
|
this.graph.watchFiles[id] = true;
|
|
12201
12299
|
const manualChunkAlias = this.getManualChunk(id);
|
|
@@ -12235,6 +12333,9 @@ class ModuleLoader {
|
|
|
12235
12333
|
if (typeof sourceDescription.moduleSideEffects === 'boolean') {
|
|
12236
12334
|
module.moduleSideEffects = sourceDescription.moduleSideEffects;
|
|
12237
12335
|
}
|
|
12336
|
+
if (typeof sourceDescription.syntheticNamedExports === 'boolean') {
|
|
12337
|
+
module.syntheticNamedExports = sourceDescription.syntheticNamedExports;
|
|
12338
|
+
}
|
|
12238
12339
|
return transform(this.graph, sourceDescription, module);
|
|
12239
12340
|
})
|
|
12240
12341
|
.then((source) => {
|
|
@@ -12276,27 +12377,34 @@ class ModuleLoader {
|
|
|
12276
12377
|
return Promise.resolve(externalModule);
|
|
12277
12378
|
}
|
|
12278
12379
|
else {
|
|
12279
|
-
return this.fetchModule(resolvedId.id, importer, resolvedId.moduleSideEffects, false);
|
|
12380
|
+
return this.fetchModule(resolvedId.id, importer, resolvedId.moduleSideEffects, resolvedId.syntheticNamedExports, false);
|
|
12280
12381
|
}
|
|
12281
12382
|
}
|
|
12282
|
-
|
|
12383
|
+
handleResolveId(resolvedId, source, importer) {
|
|
12283
12384
|
if (resolvedId === null) {
|
|
12284
12385
|
if (isRelative(source)) {
|
|
12285
|
-
error(errUnresolvedImport(source, importer));
|
|
12386
|
+
return error(errUnresolvedImport(source, importer));
|
|
12286
12387
|
}
|
|
12287
12388
|
this.graph.warn(errUnresolvedImportTreatedAsExternal(source, importer));
|
|
12288
12389
|
return {
|
|
12289
12390
|
external: true,
|
|
12290
12391
|
id: source,
|
|
12291
|
-
moduleSideEffects: this.hasModuleSideEffects(source, true)
|
|
12392
|
+
moduleSideEffects: this.hasModuleSideEffects(source, true),
|
|
12393
|
+
syntheticNamedExports: false
|
|
12292
12394
|
};
|
|
12293
12395
|
}
|
|
12396
|
+
else {
|
|
12397
|
+
if (resolvedId.external && resolvedId.syntheticNamedExports) {
|
|
12398
|
+
this.graph.warn(errExternalSyntheticExports(source, importer));
|
|
12399
|
+
}
|
|
12400
|
+
}
|
|
12294
12401
|
return resolvedId;
|
|
12295
12402
|
}
|
|
12296
12403
|
normalizeResolveIdResult(resolveIdResult, importer, source) {
|
|
12297
12404
|
let id = '';
|
|
12298
12405
|
let external = false;
|
|
12299
12406
|
let moduleSideEffects = null;
|
|
12407
|
+
let syntheticNamedExports = false;
|
|
12300
12408
|
if (resolveIdResult) {
|
|
12301
12409
|
if (typeof resolveIdResult === 'object') {
|
|
12302
12410
|
id = resolveIdResult.id;
|
|
@@ -12306,6 +12414,9 @@ class ModuleLoader {
|
|
|
12306
12414
|
if (typeof resolveIdResult.moduleSideEffects === 'boolean') {
|
|
12307
12415
|
moduleSideEffects = resolveIdResult.moduleSideEffects;
|
|
12308
12416
|
}
|
|
12417
|
+
if (typeof resolveIdResult.syntheticNamedExports === 'boolean') {
|
|
12418
|
+
syntheticNamedExports = resolveIdResult.syntheticNamedExports;
|
|
12419
|
+
}
|
|
12309
12420
|
}
|
|
12310
12421
|
else {
|
|
12311
12422
|
if (this.isExternal(resolveIdResult, importer, true)) {
|
|
@@ -12326,7 +12437,8 @@ class ModuleLoader {
|
|
|
12326
12437
|
id,
|
|
12327
12438
|
moduleSideEffects: typeof moduleSideEffects === 'boolean'
|
|
12328
12439
|
? moduleSideEffects
|
|
12329
|
-
: this.hasModuleSideEffects(id, external)
|
|
12440
|
+
: this.hasModuleSideEffects(id, external),
|
|
12441
|
+
syntheticNamedExports
|
|
12330
12442
|
};
|
|
12331
12443
|
}
|
|
12332
12444
|
resolveDynamicImport(module, specifier, importer) {
|
|
@@ -12348,9 +12460,9 @@ class ModuleLoader {
|
|
|
12348
12460
|
if (resolution == null) {
|
|
12349
12461
|
return (module.resolvedIds[specifier] =
|
|
12350
12462
|
module.resolvedIds[specifier] ||
|
|
12351
|
-
this.
|
|
12463
|
+
this.handleResolveId(yield this.resolveId(specifier, module.id), specifier, module.id));
|
|
12352
12464
|
}
|
|
12353
|
-
return this.
|
|
12465
|
+
return this.handleResolveId(this.normalizeResolveIdResult(resolution, importer, specifier), specifier, importer);
|
|
12354
12466
|
});
|
|
12355
12467
|
}
|
|
12356
12468
|
}
|
|
@@ -12512,7 +12624,7 @@ class FileEmitter {
|
|
|
12512
12624
|
this.assertAssetsFinalized = () => {
|
|
12513
12625
|
for (const [referenceId, emittedFile] of this.filesByReferenceId.entries()) {
|
|
12514
12626
|
if (emittedFile.type === 'asset' && typeof emittedFile.fileName !== 'string')
|
|
12515
|
-
error(errNoAssetSourceSet(emittedFile.name || referenceId));
|
|
12627
|
+
return error(errNoAssetSourceSet(emittedFile.name || referenceId));
|
|
12516
12628
|
}
|
|
12517
12629
|
};
|
|
12518
12630
|
this.emitFile = (emittedFile) => {
|
|
@@ -12619,7 +12731,7 @@ class FileEmitter {
|
|
|
12619
12731
|
}
|
|
12620
12732
|
emitChunk(emittedChunk) {
|
|
12621
12733
|
if (this.graph.phase > BuildPhase.LOAD_AND_PARSE) {
|
|
12622
|
-
error(errInvalidRollupPhaseForChunkEmission());
|
|
12734
|
+
return error(errInvalidRollupPhaseForChunkEmission());
|
|
12623
12735
|
}
|
|
12624
12736
|
if (typeof emittedChunk.id !== 'string') {
|
|
12625
12737
|
return error(errFailedValidation(`Emitted chunks need to have a valid string id, received "${emittedChunk.id}"`));
|
|
@@ -12718,8 +12830,9 @@ function getPluginContexts(pluginCache, graph, fileEmitter, watcher) {
|
|
|
12718
12830
|
}
|
|
12719
12831
|
const context = {
|
|
12720
12832
|
addWatchFile(id) {
|
|
12721
|
-
if (graph.phase >= BuildPhase.GENERATE)
|
|
12722
|
-
this.error(errInvalidRollupPhaseForAddWatchFile());
|
|
12833
|
+
if (graph.phase >= BuildPhase.GENERATE) {
|
|
12834
|
+
return this.error(errInvalidRollupPhaseForAddWatchFile());
|
|
12835
|
+
}
|
|
12723
12836
|
graph.watchFiles[id] = true;
|
|
12724
12837
|
},
|
|
12725
12838
|
cache: cacheInstance,
|
|
@@ -12927,7 +13040,7 @@ class PluginDriver {
|
|
|
12927
13040
|
if (typeof hook !== 'function') {
|
|
12928
13041
|
if (permitValues)
|
|
12929
13042
|
return hook;
|
|
12930
|
-
error({
|
|
13043
|
+
return error({
|
|
12931
13044
|
code: 'INVALID_PLUGIN_HOOK',
|
|
12932
13045
|
message: `Error running plugin hook ${hookName} for ${plugin.name}, expected a function hook.`
|
|
12933
13046
|
});
|
|
@@ -12949,7 +13062,7 @@ class PluginDriver {
|
|
|
12949
13062
|
try {
|
|
12950
13063
|
// permit values allows values to be returned instead of a functional hook
|
|
12951
13064
|
if (typeof hook !== 'function') {
|
|
12952
|
-
error({
|
|
13065
|
+
return error({
|
|
12953
13066
|
code: 'INVALID_PLUGIN_HOOK',
|
|
12954
13067
|
message: `Error running plugin hook ${hookName} for ${plugin.name}, expected a function hook.`
|
|
12955
13068
|
});
|
|
@@ -13014,22 +13127,23 @@ class Graph {
|
|
|
13014
13127
|
this.strictDeprecations = options.strictDeprecations;
|
|
13015
13128
|
this.cacheExpiry = options.experimentalCacheExpiry;
|
|
13016
13129
|
if (options.treeshake !== false) {
|
|
13017
|
-
this.treeshakingOptions =
|
|
13018
|
-
|
|
13019
|
-
|
|
13020
|
-
|
|
13021
|
-
|
|
13022
|
-
|
|
13023
|
-
|
|
13024
|
-
|
|
13025
|
-
|
|
13026
|
-
|
|
13027
|
-
|
|
13028
|
-
|
|
13029
|
-
|
|
13030
|
-
|
|
13031
|
-
|
|
13032
|
-
|
|
13130
|
+
this.treeshakingOptions =
|
|
13131
|
+
options.treeshake && options.treeshake !== true
|
|
13132
|
+
? {
|
|
13133
|
+
annotations: options.treeshake.annotations !== false,
|
|
13134
|
+
moduleSideEffects: options.treeshake.moduleSideEffects,
|
|
13135
|
+
propertyReadSideEffects: options.treeshake.propertyReadSideEffects !== false,
|
|
13136
|
+
pureExternalModules: options.treeshake.pureExternalModules,
|
|
13137
|
+
tryCatchDeoptimization: options.treeshake.tryCatchDeoptimization !== false,
|
|
13138
|
+
unknownGlobalSideEffects: options.treeshake.unknownGlobalSideEffects !== false
|
|
13139
|
+
}
|
|
13140
|
+
: {
|
|
13141
|
+
annotations: true,
|
|
13142
|
+
moduleSideEffects: true,
|
|
13143
|
+
propertyReadSideEffects: true,
|
|
13144
|
+
tryCatchDeoptimization: true,
|
|
13145
|
+
unknownGlobalSideEffects: true
|
|
13146
|
+
};
|
|
13033
13147
|
if (typeof this.treeshakingOptions.pureExternalModules !== 'undefined') {
|
|
13034
13148
|
this.warnDeprecation(`The "treeshake.pureExternalModules" option is deprecated. The "treeshake.moduleSideEffects" option should be used instead. "treeshake.pureExternalModules: true" is equivalent to "treeshake.moduleSideEffects: 'no-external'"`, false);
|
|
13035
13149
|
}
|
|
@@ -13063,9 +13177,7 @@ class Graph {
|
|
|
13063
13177
|
this.acornOptions = options.acorn ? Object.assign({}, options.acorn) : {};
|
|
13064
13178
|
const acornPluginsToInject = [];
|
|
13065
13179
|
acornPluginsToInject.push(acornImportMeta, acornExportNsFrom);
|
|
13066
|
-
|
|
13067
|
-
this.acornOptions.allowAwaitOutsideFunction = true;
|
|
13068
|
-
}
|
|
13180
|
+
this.acornOptions.allowAwaitOutsideFunction = true;
|
|
13069
13181
|
const acornInjectPlugins = options.acornInjectPlugins;
|
|
13070
13182
|
acornPluginsToInject.push(...(Array.isArray(acornInjectPlugins)
|
|
13071
13183
|
? acornInjectPlugins
|
|
@@ -13073,11 +13185,7 @@ class Graph {
|
|
|
13073
13185
|
? [acornInjectPlugins]
|
|
13074
13186
|
: []));
|
|
13075
13187
|
this.acornParser = Parser.extend(...acornPluginsToInject);
|
|
13076
|
-
this.moduleLoader = new ModuleLoader(this, this.moduleById, this.pluginDriver, options.external, (typeof options.manualChunks === 'function' && options.manualChunks), (this.treeshakingOptions
|
|
13077
|
-
? this.treeshakingOptions.moduleSideEffects
|
|
13078
|
-
: null), (this.treeshakingOptions
|
|
13079
|
-
? this.treeshakingOptions.pureExternalModules
|
|
13080
|
-
: false));
|
|
13188
|
+
this.moduleLoader = new ModuleLoader(this, this.moduleById, this.pluginDriver, options.external, (typeof options.manualChunks === 'function' && options.manualChunks), (this.treeshakingOptions ? this.treeshakingOptions.moduleSideEffects : null), (this.treeshakingOptions ? this.treeshakingOptions.pureExternalModules : false));
|
|
13081
13189
|
}
|
|
13082
13190
|
build(entryModules, manualChunks, inlineDynamicImports) {
|
|
13083
13191
|
// Phase 1 – discovery. We load the entry module and find which
|
|
@@ -13302,7 +13410,7 @@ function createAddons(options, outputPluginDriver) {
|
|
|
13302
13410
|
return { intro, outro, banner, footer };
|
|
13303
13411
|
})
|
|
13304
13412
|
.catch((err) => {
|
|
13305
|
-
error({
|
|
13413
|
+
return error({
|
|
13306
13414
|
code: 'ADDON_ERROR',
|
|
13307
13415
|
message: `Could not retrieve ${err.hook}. Check configuration of plugin ${err.plugin}.
|
|
13308
13416
|
\tError Message: ${err.message}`
|
|
@@ -13356,11 +13464,11 @@ function getExportMode(chunk, { exports: exportMode, name, format }, facadeModul
|
|
|
13356
13464
|
const exportKeys = chunk.getExportNames();
|
|
13357
13465
|
if (exportMode === 'default') {
|
|
13358
13466
|
if (exportKeys.length !== 1 || exportKeys[0] !== 'default') {
|
|
13359
|
-
error(errIncompatibleExportOptionValue('default', exportKeys, facadeModuleId));
|
|
13467
|
+
return error(errIncompatibleExportOptionValue('default', exportKeys, facadeModuleId));
|
|
13360
13468
|
}
|
|
13361
13469
|
}
|
|
13362
13470
|
else if (exportMode === 'none' && exportKeys.length) {
|
|
13363
|
-
error(errIncompatibleExportOptionValue('none', exportKeys, facadeModuleId));
|
|
13471
|
+
return error(errIncompatibleExportOptionValue('none', exportKeys, facadeModuleId));
|
|
13364
13472
|
}
|
|
13365
13473
|
if (!exportMode || exportMode === 'auto') {
|
|
13366
13474
|
if (exportKeys.length === 0) {
|
|
@@ -13401,6 +13509,15 @@ const getObjectOption = (config, command, name) => {
|
|
|
13401
13509
|
}
|
|
13402
13510
|
return configOption;
|
|
13403
13511
|
};
|
|
13512
|
+
function ensureArray(items) {
|
|
13513
|
+
if (Array.isArray(items)) {
|
|
13514
|
+
return items.filter(Boolean);
|
|
13515
|
+
}
|
|
13516
|
+
if (items) {
|
|
13517
|
+
return [items];
|
|
13518
|
+
}
|
|
13519
|
+
return [];
|
|
13520
|
+
}
|
|
13404
13521
|
const defaultOnWarn = warning => {
|
|
13405
13522
|
if (typeof warning === 'string') {
|
|
13406
13523
|
console.warn(warning);
|
|
@@ -13453,7 +13570,7 @@ function mergeOptions({ config = {}, command: rawCommandOptions = {}, defaultOnW
|
|
|
13453
13570
|
const validOutputOptions = Object.keys(outputOptions[0]);
|
|
13454
13571
|
addUnknownOptionErrors(unknownOptionErrors, outputOptions.reduce((allKeys, options) => allKeys.concat(Object.keys(options)), []), validOutputOptions, 'output option');
|
|
13455
13572
|
const validCliOutputOptions = validOutputOptions.filter(option => option !== 'sourcemapPathTransform');
|
|
13456
|
-
addUnknownOptionErrors(unknownOptionErrors, Object.keys(command), validInputOptions.concat(validCliOutputOptions, Object.keys(commandAliases), 'config', 'environment', 'silent'), 'CLI flag', /^_|output|(config.*)$/);
|
|
13573
|
+
addUnknownOptionErrors(unknownOptionErrors, Object.keys(command), validInputOptions.concat(validCliOutputOptions, Object.keys(commandAliases), 'config', 'environment', 'silent', 'stdin'), 'CLI flag', /^_|output|(config.*)$/);
|
|
13457
13574
|
return {
|
|
13458
13575
|
inputOptions,
|
|
13459
13576
|
optionError: unknownOptionErrors.length > 0 ? unknownOptionErrors.join('\n') : null,
|
|
@@ -13493,7 +13610,6 @@ function getInputOptions(config, command = { external: [], globals: undefined },
|
|
|
13493
13610
|
context: getOption('context'),
|
|
13494
13611
|
experimentalCacheExpiry: getOption('experimentalCacheExpiry', 10),
|
|
13495
13612
|
experimentalOptimizeChunks: getOption('experimentalOptimizeChunks'),
|
|
13496
|
-
experimentalTopLevelAwait: getOption('experimentalTopLevelAwait'),
|
|
13497
13613
|
external: getExternal(config, command),
|
|
13498
13614
|
inlineDynamicImports: getOption('inlineDynamicImports', false),
|
|
13499
13615
|
input: getOption('input', []),
|
|
@@ -13501,7 +13617,7 @@ function getInputOptions(config, command = { external: [], globals: undefined },
|
|
|
13501
13617
|
moduleContext: config.moduleContext,
|
|
13502
13618
|
onwarn: getOnWarn(config, defaultOnWarnHandler),
|
|
13503
13619
|
perf: getOption('perf', false),
|
|
13504
|
-
plugins: config.plugins,
|
|
13620
|
+
plugins: ensureArray(config.plugins),
|
|
13505
13621
|
preserveModules: getOption('preserveModules'),
|
|
13506
13622
|
preserveSymlinks: getOption('preserveSymlinks'),
|
|
13507
13623
|
shimMissingExports: getOption('shimMissingExports'),
|
|
@@ -13519,6 +13635,7 @@ function getOutputOptions(config, command = {}) {
|
|
|
13519
13635
|
let format = getOption('format');
|
|
13520
13636
|
// Handle format aliases
|
|
13521
13637
|
switch (format) {
|
|
13638
|
+
case undefined:
|
|
13522
13639
|
case 'esm':
|
|
13523
13640
|
case 'module':
|
|
13524
13641
|
format = 'es';
|
|
@@ -13541,7 +13658,7 @@ function getOutputOptions(config, command = {}) {
|
|
|
13541
13658
|
externalLiveBindings: getOption('externalLiveBindings', true),
|
|
13542
13659
|
file: getOption('file'),
|
|
13543
13660
|
footer: getOption('footer'),
|
|
13544
|
-
format
|
|
13661
|
+
format,
|
|
13545
13662
|
freeze: getOption('freeze', true),
|
|
13546
13663
|
globals: getOption('globals'),
|
|
13547
13664
|
indent: getOption('indent', true),
|
|
@@ -13552,7 +13669,7 @@ function getOutputOptions(config, command = {}) {
|
|
|
13552
13669
|
noConflict: getOption('noConflict'),
|
|
13553
13670
|
outro: getOption('outro'),
|
|
13554
13671
|
paths: getOption('paths'),
|
|
13555
|
-
plugins: config.plugins,
|
|
13672
|
+
plugins: ensureArray(config.plugins),
|
|
13556
13673
|
preferConst: getOption('preferConst'),
|
|
13557
13674
|
sourcemap: getOption('sourcemap'),
|
|
13558
13675
|
sourcemapExcludeSources: getOption('sourcemapExcludeSources'),
|
|
@@ -13564,19 +13681,19 @@ function getOutputOptions(config, command = {}) {
|
|
|
13564
13681
|
|
|
13565
13682
|
function checkOutputOptions(options) {
|
|
13566
13683
|
if (options.format === 'es6') {
|
|
13567
|
-
error(errDeprecation({
|
|
13684
|
+
return error(errDeprecation({
|
|
13568
13685
|
message: 'The "es6" output format is deprecated – use "esm" instead',
|
|
13569
13686
|
url: `https://rollupjs.org/guide/en/#output-format`
|
|
13570
13687
|
}));
|
|
13571
13688
|
}
|
|
13572
13689
|
if (['amd', 'cjs', 'system', 'es', 'iife', 'umd'].indexOf(options.format) < 0) {
|
|
13573
|
-
error({
|
|
13690
|
+
return error({
|
|
13574
13691
|
message: `You must specify "output.format", which can be one of "amd", "cjs", "system", "esm", "iife" or "umd".`,
|
|
13575
13692
|
url: `https://rollupjs.org/guide/en/#output-format`
|
|
13576
13693
|
});
|
|
13577
13694
|
}
|
|
13578
13695
|
if (options.exports && !['default', 'named', 'none', 'auto'].includes(options.exports)) {
|
|
13579
|
-
error(errInvalidExportOptionValue(options.exports));
|
|
13696
|
+
return error(errInvalidExportOptionValue(options.exports));
|
|
13580
13697
|
}
|
|
13581
13698
|
}
|
|
13582
13699
|
function getAbsoluteEntryModulePaths(chunks) {
|
|
@@ -13600,15 +13717,6 @@ function applyOptionHook(inputOptions, plugin) {
|
|
|
13600
13717
|
return plugin.options.call({ meta: { rollupVersion: version } }, inputOptions) || inputOptions;
|
|
13601
13718
|
return inputOptions;
|
|
13602
13719
|
}
|
|
13603
|
-
function ensureArray(items) {
|
|
13604
|
-
if (Array.isArray(items)) {
|
|
13605
|
-
return items.filter(Boolean);
|
|
13606
|
-
}
|
|
13607
|
-
if (items) {
|
|
13608
|
-
return [items];
|
|
13609
|
-
}
|
|
13610
|
-
return [];
|
|
13611
|
-
}
|
|
13612
13720
|
function normalizePlugins(rawPlugins, anonymousPrefix) {
|
|
13613
13721
|
const plugins = ensureArray(rawPlugins);
|
|
13614
13722
|
for (let pluginIndex = 0; pluginIndex < plugins.length; pluginIndex++) {
|
|
@@ -13628,39 +13736,39 @@ function getInputOptions$1(rawInputOptions) {
|
|
|
13628
13736
|
});
|
|
13629
13737
|
if (optionError)
|
|
13630
13738
|
inputOptions.onwarn({ message: optionError, code: 'UNKNOWN_OPTION' });
|
|
13631
|
-
inputOptions =
|
|
13739
|
+
inputOptions = inputOptions.plugins.reduce(applyOptionHook, inputOptions);
|
|
13632
13740
|
inputOptions.plugins = normalizePlugins(inputOptions.plugins, ANONYMOUS_PLUGIN_PREFIX);
|
|
13633
13741
|
if (inputOptions.inlineDynamicImports) {
|
|
13634
13742
|
if (inputOptions.preserveModules)
|
|
13635
|
-
error({
|
|
13743
|
+
return error({
|
|
13636
13744
|
code: 'INVALID_OPTION',
|
|
13637
13745
|
message: `"preserveModules" does not support the "inlineDynamicImports" option.`
|
|
13638
13746
|
});
|
|
13639
13747
|
if (inputOptions.manualChunks)
|
|
13640
|
-
error({
|
|
13748
|
+
return error({
|
|
13641
13749
|
code: 'INVALID_OPTION',
|
|
13642
13750
|
message: '"manualChunks" option is not supported for "inlineDynamicImports".'
|
|
13643
13751
|
});
|
|
13644
13752
|
if (inputOptions.experimentalOptimizeChunks)
|
|
13645
|
-
error({
|
|
13753
|
+
return error({
|
|
13646
13754
|
code: 'INVALID_OPTION',
|
|
13647
13755
|
message: '"experimentalOptimizeChunks" option is not supported for "inlineDynamicImports".'
|
|
13648
13756
|
});
|
|
13649
13757
|
if ((inputOptions.input instanceof Array && inputOptions.input.length > 1) ||
|
|
13650
13758
|
(typeof inputOptions.input === 'object' && Object.keys(inputOptions.input).length > 1))
|
|
13651
|
-
error({
|
|
13759
|
+
return error({
|
|
13652
13760
|
code: 'INVALID_OPTION',
|
|
13653
13761
|
message: 'Multiple inputs are not supported for "inlineDynamicImports".'
|
|
13654
13762
|
});
|
|
13655
13763
|
}
|
|
13656
13764
|
else if (inputOptions.preserveModules) {
|
|
13657
13765
|
if (inputOptions.manualChunks)
|
|
13658
|
-
error({
|
|
13766
|
+
return error({
|
|
13659
13767
|
code: 'INVALID_OPTION',
|
|
13660
13768
|
message: '"preserveModules" does not support the "manualChunks" option.'
|
|
13661
13769
|
});
|
|
13662
13770
|
if (inputOptions.experimentalOptimizeChunks)
|
|
13663
|
-
error({
|
|
13771
|
+
return error({
|
|
13664
13772
|
code: 'INVALID_OPTION',
|
|
13665
13773
|
message: '"preserveModules" does not support the "experimentalOptimizeChunks" option.'
|
|
13666
13774
|
});
|
|
@@ -13803,7 +13911,7 @@ function rollup(rawInputOptions) {
|
|
|
13803
13911
|
write: ((rawOutputOptions) => {
|
|
13804
13912
|
const { outputOptions, outputPluginDriver } = getOutputOptionsAndPluginDriver(rawOutputOptions);
|
|
13805
13913
|
if (!outputOptions.dir && !outputOptions.file) {
|
|
13806
|
-
error({
|
|
13914
|
+
return error({
|
|
13807
13915
|
code: 'MISSING_OPTION',
|
|
13808
13916
|
message: 'You must specify "output.file" or "output.dir" for the build.'
|
|
13809
13917
|
});
|
|
@@ -13820,12 +13928,12 @@ function rollup(rawInputOptions) {
|
|
|
13820
13928
|
}
|
|
13821
13929
|
if (chunkCount > 1) {
|
|
13822
13930
|
if (outputOptions.sourcemapFile)
|
|
13823
|
-
error({
|
|
13931
|
+
return error({
|
|
13824
13932
|
code: 'INVALID_OPTION',
|
|
13825
13933
|
message: '"output.sourcemapFile" is only supported for single-file builds.'
|
|
13826
13934
|
});
|
|
13827
13935
|
if (typeof outputOptions.file === 'string')
|
|
13828
|
-
error({
|
|
13936
|
+
return error({
|
|
13829
13937
|
code: 'INVALID_OPTION',
|
|
13830
13938
|
message: 'When building multiple chunks, the "output.dir" option must be used, not "output.file".' +
|
|
13831
13939
|
(typeof inputOptions.input !== 'string' ||
|
|
@@ -13923,30 +14031,30 @@ function normalizeOutputOptions(inputOptions, rawOutputOptions, hasMultipleChunk
|
|
|
13923
14031
|
checkOutputOptions(outputOptions);
|
|
13924
14032
|
if (typeof outputOptions.file === 'string') {
|
|
13925
14033
|
if (typeof outputOptions.dir === 'string')
|
|
13926
|
-
error({
|
|
14034
|
+
return error({
|
|
13927
14035
|
code: 'INVALID_OPTION',
|
|
13928
14036
|
message: 'You must set either "output.file" for a single-file build or "output.dir" when generating multiple chunks.'
|
|
13929
14037
|
});
|
|
13930
14038
|
if (inputOptions.preserveModules) {
|
|
13931
|
-
error({
|
|
14039
|
+
return error({
|
|
13932
14040
|
code: 'INVALID_OPTION',
|
|
13933
14041
|
message: 'You must set "output.dir" instead of "output.file" when using the "preserveModules" option.'
|
|
13934
14042
|
});
|
|
13935
14043
|
}
|
|
13936
14044
|
if (typeof inputOptions.input === 'object' && !Array.isArray(inputOptions.input))
|
|
13937
|
-
error({
|
|
14045
|
+
return error({
|
|
13938
14046
|
code: 'INVALID_OPTION',
|
|
13939
14047
|
message: 'You must set "output.dir" instead of "output.file" when providing named inputs.'
|
|
13940
14048
|
});
|
|
13941
14049
|
}
|
|
13942
14050
|
if (hasMultipleChunks) {
|
|
13943
14051
|
if (outputOptions.format === 'umd' || outputOptions.format === 'iife')
|
|
13944
|
-
error({
|
|
14052
|
+
return error({
|
|
13945
14053
|
code: 'INVALID_OPTION',
|
|
13946
14054
|
message: 'UMD and IIFE output formats are not supported for code-splitting builds.'
|
|
13947
14055
|
});
|
|
13948
14056
|
if (typeof outputOptions.file === 'string')
|
|
13949
|
-
error({
|
|
14057
|
+
return error({
|
|
13950
14058
|
code: 'INVALID_OPTION',
|
|
13951
14059
|
message: 'You must set "output.dir" instead of "output.file" when generating multiple chunks.'
|
|
13952
14060
|
});
|