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.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
|
|
@@ -21,69 +21,34 @@ var crypto = require('crypto');
|
|
|
21
21
|
var events = require('events');
|
|
22
22
|
require('module');
|
|
23
23
|
|
|
24
|
-
/*! *****************************************************************************
|
|
25
|
-
Copyright (c) Microsoft Corporation. All rights reserved.
|
|
26
|
-
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
27
|
-
this file except in compliance with the License. You may obtain a copy of the
|
|
28
|
-
License at http://www.apache.org/licenses/LICENSE-2.0
|
|
29
|
-
|
|
30
|
-
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
31
|
-
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
|
32
|
-
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
|
33
|
-
MERCHANTABLITY OR NON-INFRINGEMENT.
|
|
34
|
-
|
|
35
|
-
See the Apache Version 2.0 License for specific language governing permissions
|
|
36
|
-
and limitations under the License.
|
|
37
|
-
***************************************************************************** */
|
|
38
|
-
function __awaiter(thisArg, _arguments, P, generator) {
|
|
39
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
40
|
-
function fulfilled(value) { try {
|
|
41
|
-
step(generator.next(value));
|
|
42
|
-
}
|
|
43
|
-
catch (e) {
|
|
44
|
-
reject(e);
|
|
45
|
-
} }
|
|
46
|
-
function rejected(value) { try {
|
|
47
|
-
step(generator["throw"](value));
|
|
48
|
-
}
|
|
49
|
-
catch (e) {
|
|
50
|
-
reject(e);
|
|
51
|
-
} }
|
|
52
|
-
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
|
53
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
|
|
57
24
|
var charToInteger = {};
|
|
58
25
|
var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
|
|
59
26
|
for (var i = 0; i < chars.length; i++) {
|
|
60
27
|
charToInteger[chars.charCodeAt(i)] = i;
|
|
61
28
|
}
|
|
62
29
|
function decode(mappings) {
|
|
63
|
-
var generatedCodeColumn = 0; // first field
|
|
64
|
-
var sourceFileIndex = 0; // second field
|
|
65
|
-
var sourceCodeLine = 0; // third field
|
|
66
|
-
var sourceCodeColumn = 0; // fourth field
|
|
67
|
-
var nameIndex = 0; // fifth field
|
|
68
30
|
var decoded = [];
|
|
69
31
|
var line = [];
|
|
70
|
-
var segment = [
|
|
71
|
-
|
|
32
|
+
var segment = [
|
|
33
|
+
0,
|
|
34
|
+
0,
|
|
35
|
+
0,
|
|
36
|
+
0,
|
|
37
|
+
0,
|
|
38
|
+
];
|
|
39
|
+
var j = 0;
|
|
40
|
+
for (var i = 0, shift = 0, value = 0; i < mappings.length; i++) {
|
|
72
41
|
var c = mappings.charCodeAt(i);
|
|
73
42
|
if (c === 44) { // ","
|
|
74
|
-
|
|
75
|
-
line.push(segment);
|
|
76
|
-
segment = [];
|
|
43
|
+
segmentify(line, segment, j);
|
|
77
44
|
j = 0;
|
|
78
45
|
}
|
|
79
46
|
else if (c === 59) { // ";"
|
|
80
|
-
|
|
81
|
-
line.push(segment);
|
|
82
|
-
segment = [];
|
|
47
|
+
segmentify(line, segment, j);
|
|
83
48
|
j = 0;
|
|
84
49
|
decoded.push(line);
|
|
85
50
|
line = [];
|
|
86
|
-
|
|
51
|
+
segment[0] = 0;
|
|
87
52
|
}
|
|
88
53
|
else {
|
|
89
54
|
var integer = charToInteger[c];
|
|
@@ -100,40 +65,33 @@ function decode(mappings) {
|
|
|
100
65
|
var shouldNegate = value & 1;
|
|
101
66
|
value >>>= 1;
|
|
102
67
|
if (shouldNegate) {
|
|
103
|
-
value = -value;
|
|
104
|
-
if (value === 0)
|
|
105
|
-
value = -0x80000000;
|
|
106
|
-
}
|
|
107
|
-
if (j == 0) {
|
|
108
|
-
generatedCodeColumn += value;
|
|
109
|
-
segment.push(generatedCodeColumn);
|
|
110
|
-
}
|
|
111
|
-
else if (j === 1) {
|
|
112
|
-
sourceFileIndex += value;
|
|
113
|
-
segment.push(sourceFileIndex);
|
|
114
|
-
}
|
|
115
|
-
else if (j === 2) {
|
|
116
|
-
sourceCodeLine += value;
|
|
117
|
-
segment.push(sourceCodeLine);
|
|
118
|
-
}
|
|
119
|
-
else if (j === 3) {
|
|
120
|
-
sourceCodeColumn += value;
|
|
121
|
-
segment.push(sourceCodeColumn);
|
|
122
|
-
}
|
|
123
|
-
else if (j === 4) {
|
|
124
|
-
nameIndex += value;
|
|
125
|
-
segment.push(nameIndex);
|
|
68
|
+
value = value === 0 ? -0x80000000 : -value;
|
|
126
69
|
}
|
|
70
|
+
segment[j] += value;
|
|
127
71
|
j++;
|
|
128
72
|
value = shift = 0; // reset
|
|
129
73
|
}
|
|
130
74
|
}
|
|
131
75
|
}
|
|
132
|
-
|
|
133
|
-
line.push(segment);
|
|
76
|
+
segmentify(line, segment, j);
|
|
134
77
|
decoded.push(line);
|
|
135
78
|
return decoded;
|
|
136
79
|
}
|
|
80
|
+
function segmentify(line, segment, j) {
|
|
81
|
+
// This looks ugly, but we're creating specialized arrays with a specific
|
|
82
|
+
// length. This is much faster than creating a new array (which v8 expands to
|
|
83
|
+
// a capacity of 17 after pushing the first item), or slicing out a subarray
|
|
84
|
+
// (which is slow). Length 4 is assumed to be the most frequent, followed by
|
|
85
|
+
// length 5 (since not everything will have an associated name), followed by
|
|
86
|
+
// length 1 (it's probably rare for a source substring to not have an
|
|
87
|
+
// associated segment data).
|
|
88
|
+
if (j === 4)
|
|
89
|
+
line.push([segment[0], segment[1], segment[2], segment[3]]);
|
|
90
|
+
else if (j === 5)
|
|
91
|
+
line.push([segment[0], segment[1], segment[2], segment[3], segment[4]]);
|
|
92
|
+
else if (j === 1)
|
|
93
|
+
line.push([segment[0]]);
|
|
94
|
+
}
|
|
137
95
|
function encode(decoded) {
|
|
138
96
|
var sourceFileIndex = 0; // second field
|
|
139
97
|
var sourceCodeLine = 0; // third field
|
|
@@ -185,6 +143,15 @@ function encodeInteger(num) {
|
|
|
185
143
|
return result;
|
|
186
144
|
}
|
|
187
145
|
|
|
146
|
+
var BitSet = function BitSet(arg) {
|
|
147
|
+
this.bits = arg instanceof BitSet ? arg.bits.slice() : [];
|
|
148
|
+
};
|
|
149
|
+
BitSet.prototype.add = function add(n) {
|
|
150
|
+
this.bits[n >> 5] |= 1 << (n & 31);
|
|
151
|
+
};
|
|
152
|
+
BitSet.prototype.has = function has(n) {
|
|
153
|
+
return !!(this.bits[n >> 5] & (1 << (n & 31)));
|
|
154
|
+
};
|
|
188
155
|
var Chunk = function Chunk(start, end, content) {
|
|
189
156
|
this.start = start;
|
|
190
157
|
this.end = end;
|
|
@@ -427,39 +394,40 @@ Mappings.prototype.addEdit = function addEdit(sourceIndex, content, loc, nameInd
|
|
|
427
394
|
this.pending = null;
|
|
428
395
|
};
|
|
429
396
|
Mappings.prototype.addUneditedChunk = function addUneditedChunk(sourceIndex, chunk, original, loc, sourcemapLocations) {
|
|
430
|
-
var this$1 = this;
|
|
431
397
|
var originalCharIndex = chunk.start;
|
|
432
398
|
var first = true;
|
|
433
399
|
while (originalCharIndex < chunk.end) {
|
|
434
|
-
if (this
|
|
435
|
-
this
|
|
400
|
+
if (this.hires || first || sourcemapLocations.has(originalCharIndex)) {
|
|
401
|
+
this.rawSegments.push([this.generatedCodeColumn, sourceIndex, loc.line, loc.column]);
|
|
436
402
|
}
|
|
437
403
|
if (original[originalCharIndex] === '\n') {
|
|
438
404
|
loc.line += 1;
|
|
439
405
|
loc.column = 0;
|
|
440
|
-
this
|
|
441
|
-
this
|
|
442
|
-
this
|
|
406
|
+
this.generatedCodeLine += 1;
|
|
407
|
+
this.raw[this.generatedCodeLine] = this.rawSegments = [];
|
|
408
|
+
this.generatedCodeColumn = 0;
|
|
409
|
+
first = true;
|
|
443
410
|
}
|
|
444
411
|
else {
|
|
445
412
|
loc.column += 1;
|
|
446
|
-
this
|
|
413
|
+
this.generatedCodeColumn += 1;
|
|
414
|
+
first = false;
|
|
447
415
|
}
|
|
448
416
|
originalCharIndex += 1;
|
|
449
|
-
first = false;
|
|
450
417
|
}
|
|
451
|
-
this.pending =
|
|
418
|
+
this.pending = sourceIndex > 0
|
|
419
|
+
? [this.generatedCodeColumn, sourceIndex, loc.line, loc.column]
|
|
420
|
+
: null;
|
|
452
421
|
};
|
|
453
422
|
Mappings.prototype.advance = function advance(str) {
|
|
454
|
-
var this$1 = this;
|
|
455
423
|
if (!str) {
|
|
456
424
|
return;
|
|
457
425
|
}
|
|
458
426
|
var lines = str.split('\n');
|
|
459
427
|
if (lines.length > 1) {
|
|
460
428
|
for (var i = 0; i < lines.length - 1; i++) {
|
|
461
|
-
this
|
|
462
|
-
this
|
|
429
|
+
this.generatedCodeLine++;
|
|
430
|
+
this.raw[this.generatedCodeLine] = this.rawSegments = [];
|
|
463
431
|
}
|
|
464
432
|
this.generatedCodeColumn = 0;
|
|
465
433
|
}
|
|
@@ -486,7 +454,7 @@ var MagicString = function MagicString(string, options) {
|
|
|
486
454
|
byEnd: { writable: true, value: {} },
|
|
487
455
|
filename: { writable: true, value: options.filename },
|
|
488
456
|
indentExclusionRanges: { writable: true, value: options.indentExclusionRanges },
|
|
489
|
-
sourcemapLocations: { writable: true, value:
|
|
457
|
+
sourcemapLocations: { writable: true, value: new BitSet() },
|
|
490
458
|
storedNames: { writable: true, value: {} },
|
|
491
459
|
indentStr: { writable: true, value: guessIndent(string) }
|
|
492
460
|
});
|
|
@@ -494,7 +462,7 @@ var MagicString = function MagicString(string, options) {
|
|
|
494
462
|
this.byEnd[string.length] = chunk;
|
|
495
463
|
};
|
|
496
464
|
MagicString.prototype.addSourcemapLocation = function addSourcemapLocation(char) {
|
|
497
|
-
this.sourcemapLocations
|
|
465
|
+
this.sourcemapLocations.add(char);
|
|
498
466
|
};
|
|
499
467
|
MagicString.prototype.append = function append(content) {
|
|
500
468
|
if (typeof content !== 'string') {
|
|
@@ -551,9 +519,7 @@ MagicString.prototype.clone = function clone() {
|
|
|
551
519
|
if (this.indentExclusionRanges) {
|
|
552
520
|
cloned.indentExclusionRanges = this.indentExclusionRanges.slice();
|
|
553
521
|
}
|
|
554
|
-
|
|
555
|
-
cloned.sourcemapLocations[loc] = true;
|
|
556
|
-
});
|
|
522
|
+
cloned.sourcemapLocations = new BitSet(this.sourcemapLocations);
|
|
557
523
|
cloned.intro = this.intro;
|
|
558
524
|
cloned.outro = this.outro;
|
|
559
525
|
return cloned;
|
|
@@ -598,7 +564,6 @@ MagicString.prototype.getIndentString = function getIndentString() {
|
|
|
598
564
|
return this.indentStr === null ? '\t' : this.indentStr;
|
|
599
565
|
};
|
|
600
566
|
MagicString.prototype.indent = function indent(indentStr, options) {
|
|
601
|
-
var this$1 = this;
|
|
602
567
|
var pattern = /^[^\r\n]/gm;
|
|
603
568
|
if (isObject(indentStr)) {
|
|
604
569
|
options = indentStr;
|
|
@@ -644,7 +609,7 @@ MagicString.prototype.indent = function indent(indentStr, options) {
|
|
|
644
609
|
charIndex = chunk.start;
|
|
645
610
|
while (charIndex < end) {
|
|
646
611
|
if (!isExcluded[charIndex]) {
|
|
647
|
-
var char = this
|
|
612
|
+
var char = this.original[charIndex];
|
|
648
613
|
if (char === '\n') {
|
|
649
614
|
shouldIndentNextCharacter = true;
|
|
650
615
|
}
|
|
@@ -654,7 +619,7 @@ MagicString.prototype.indent = function indent(indentStr, options) {
|
|
|
654
619
|
chunk.prependRight(indentStr);
|
|
655
620
|
}
|
|
656
621
|
else {
|
|
657
|
-
this
|
|
622
|
+
this._splitChunk(chunk, charIndex);
|
|
658
623
|
chunk = chunk.next;
|
|
659
624
|
chunk.prependRight(indentStr);
|
|
660
625
|
}
|
|
@@ -732,15 +697,14 @@ MagicString.prototype.move = function move(start, end, index) {
|
|
|
732
697
|
return this;
|
|
733
698
|
};
|
|
734
699
|
MagicString.prototype.overwrite = function overwrite(start, end, content, options) {
|
|
735
|
-
var this$1 = this;
|
|
736
700
|
if (typeof content !== 'string') {
|
|
737
701
|
throw new TypeError('replacement content must be a string');
|
|
738
702
|
}
|
|
739
703
|
while (start < 0) {
|
|
740
|
-
start += this
|
|
704
|
+
start += this.original.length;
|
|
741
705
|
}
|
|
742
706
|
while (end < 0) {
|
|
743
|
-
end += this
|
|
707
|
+
end += this.original.length;
|
|
744
708
|
}
|
|
745
709
|
if (end > this.original.length) {
|
|
746
710
|
throw new Error('end is out of bounds');
|
|
@@ -824,12 +788,11 @@ MagicString.prototype.prependRight = function prependRight(index, content) {
|
|
|
824
788
|
return this;
|
|
825
789
|
};
|
|
826
790
|
MagicString.prototype.remove = function remove(start, end) {
|
|
827
|
-
var this$1 = this;
|
|
828
791
|
while (start < 0) {
|
|
829
|
-
start += this
|
|
792
|
+
start += this.original.length;
|
|
830
793
|
}
|
|
831
794
|
while (end < 0) {
|
|
832
|
-
end += this
|
|
795
|
+
end += this.original.length;
|
|
833
796
|
}
|
|
834
797
|
if (start === end) {
|
|
835
798
|
return this;
|
|
@@ -847,7 +810,7 @@ MagicString.prototype.remove = function remove(start, end) {
|
|
|
847
810
|
chunk.intro = '';
|
|
848
811
|
chunk.outro = '';
|
|
849
812
|
chunk.edit('');
|
|
850
|
-
chunk = end > chunk.end ? this
|
|
813
|
+
chunk = end > chunk.end ? this.byStart[chunk.end] : null;
|
|
851
814
|
}
|
|
852
815
|
return this;
|
|
853
816
|
};
|
|
@@ -909,16 +872,15 @@ MagicString.prototype.lastLine = function lastLine() {
|
|
|
909
872
|
return this.intro + lineStr;
|
|
910
873
|
};
|
|
911
874
|
MagicString.prototype.slice = function slice(start, end) {
|
|
912
|
-
var this$1 = this;
|
|
913
875
|
if (start === void 0)
|
|
914
876
|
start = 0;
|
|
915
877
|
if (end === void 0)
|
|
916
878
|
end = this.original.length;
|
|
917
879
|
while (start < 0) {
|
|
918
|
-
start += this
|
|
880
|
+
start += this.original.length;
|
|
919
881
|
}
|
|
920
882
|
while (end < 0) {
|
|
921
|
-
end += this
|
|
883
|
+
end += this.original.length;
|
|
922
884
|
}
|
|
923
885
|
var result = '';
|
|
924
886
|
// find start chunk
|
|
@@ -963,7 +925,6 @@ MagicString.prototype.snip = function snip(start, end) {
|
|
|
963
925
|
return clone;
|
|
964
926
|
};
|
|
965
927
|
MagicString.prototype._split = function _split(index) {
|
|
966
|
-
var this$1 = this;
|
|
967
928
|
if (this.byStart[index] || this.byEnd[index]) {
|
|
968
929
|
return;
|
|
969
930
|
}
|
|
@@ -971,9 +932,9 @@ MagicString.prototype._split = function _split(index) {
|
|
|
971
932
|
var searchForward = index > chunk.end;
|
|
972
933
|
while (chunk) {
|
|
973
934
|
if (chunk.contains(index)) {
|
|
974
|
-
return this
|
|
935
|
+
return this._splitChunk(chunk, index);
|
|
975
936
|
}
|
|
976
|
-
chunk = searchForward ? this
|
|
937
|
+
chunk = searchForward ? this.byStart[chunk.end] : this.byEnd[chunk.start];
|
|
977
938
|
}
|
|
978
939
|
};
|
|
979
940
|
MagicString.prototype._splitChunk = function _splitChunk(chunk, index) {
|
|
@@ -1027,7 +988,6 @@ MagicString.prototype.trim = function trim(charType) {
|
|
|
1027
988
|
return this.trimStart(charType).trimEnd(charType);
|
|
1028
989
|
};
|
|
1029
990
|
MagicString.prototype.trimEndAborted = function trimEndAborted(charType) {
|
|
1030
|
-
var this$1 = this;
|
|
1031
991
|
var rx = new RegExp((charType || '\\s') + '+$');
|
|
1032
992
|
this.outro = this.outro.replace(rx, '');
|
|
1033
993
|
if (this.outro.length) {
|
|
@@ -1039,12 +999,12 @@ MagicString.prototype.trimEndAborted = function trimEndAborted(charType) {
|
|
|
1039
999
|
var aborted = chunk.trimEnd(rx);
|
|
1040
1000
|
// if chunk was trimmed, we have a new lastChunk
|
|
1041
1001
|
if (chunk.end !== end) {
|
|
1042
|
-
if (this
|
|
1043
|
-
this
|
|
1002
|
+
if (this.lastChunk === chunk) {
|
|
1003
|
+
this.lastChunk = chunk.next;
|
|
1044
1004
|
}
|
|
1045
|
-
this
|
|
1046
|
-
this
|
|
1047
|
-
this
|
|
1005
|
+
this.byEnd[chunk.end] = chunk;
|
|
1006
|
+
this.byStart[chunk.next.start] = chunk.next;
|
|
1007
|
+
this.byEnd[chunk.next.end] = chunk.next;
|
|
1048
1008
|
}
|
|
1049
1009
|
if (aborted) {
|
|
1050
1010
|
return true;
|
|
@@ -1058,7 +1018,6 @@ MagicString.prototype.trimEnd = function trimEnd(charType) {
|
|
|
1058
1018
|
return this;
|
|
1059
1019
|
};
|
|
1060
1020
|
MagicString.prototype.trimStartAborted = function trimStartAborted(charType) {
|
|
1061
|
-
var this$1 = this;
|
|
1062
1021
|
var rx = new RegExp('^' + (charType || '\\s') + '+');
|
|
1063
1022
|
this.intro = this.intro.replace(rx, '');
|
|
1064
1023
|
if (this.intro.length) {
|
|
@@ -1070,12 +1029,12 @@ MagicString.prototype.trimStartAborted = function trimStartAborted(charType) {
|
|
|
1070
1029
|
var aborted = chunk.trimStart(rx);
|
|
1071
1030
|
if (chunk.end !== end) {
|
|
1072
1031
|
// special case...
|
|
1073
|
-
if (chunk === this
|
|
1074
|
-
this
|
|
1032
|
+
if (chunk === this.lastChunk) {
|
|
1033
|
+
this.lastChunk = chunk.next;
|
|
1075
1034
|
}
|
|
1076
|
-
this
|
|
1077
|
-
this
|
|
1078
|
-
this
|
|
1035
|
+
this.byEnd[chunk.end] = chunk;
|
|
1036
|
+
this.byStart[chunk.next.start] = chunk.next;
|
|
1037
|
+
this.byEnd[chunk.next.end] = chunk.next;
|
|
1079
1038
|
}
|
|
1080
1039
|
if (aborted) {
|
|
1081
1040
|
return true;
|
|
@@ -1296,14 +1255,13 @@ Bundle.prototype.trim = function trim(charType) {
|
|
|
1296
1255
|
return this.trimStart(charType).trimEnd(charType);
|
|
1297
1256
|
};
|
|
1298
1257
|
Bundle.prototype.trimStart = function trimStart(charType) {
|
|
1299
|
-
var this$1 = this;
|
|
1300
1258
|
var rx = new RegExp('^' + (charType || '\\s') + '+');
|
|
1301
1259
|
this.intro = this.intro.replace(rx, '');
|
|
1302
1260
|
if (!this.intro) {
|
|
1303
1261
|
var source;
|
|
1304
1262
|
var i = 0;
|
|
1305
1263
|
do {
|
|
1306
|
-
source = this
|
|
1264
|
+
source = this.sources[i++];
|
|
1307
1265
|
if (!source) {
|
|
1308
1266
|
break;
|
|
1309
1267
|
}
|
|
@@ -1312,14 +1270,13 @@ Bundle.prototype.trimStart = function trimStart(charType) {
|
|
|
1312
1270
|
return this;
|
|
1313
1271
|
};
|
|
1314
1272
|
Bundle.prototype.trimEnd = function trimEnd(charType) {
|
|
1315
|
-
var this$1 = this;
|
|
1316
1273
|
var rx = new RegExp((charType || '\\s') + '+$');
|
|
1317
1274
|
var source;
|
|
1318
1275
|
var i = this.sources.length - 1;
|
|
1319
1276
|
do {
|
|
1320
|
-
source = this
|
|
1277
|
+
source = this.sources[i--];
|
|
1321
1278
|
if (!source) {
|
|
1322
|
-
this
|
|
1279
|
+
this.intro = this.intro.replace(rx, '');
|
|
1323
1280
|
break;
|
|
1324
1281
|
}
|
|
1325
1282
|
} while (!source.content.trimEndAborted(charType));
|
|
@@ -2608,7 +2565,7 @@ class Variable {
|
|
|
2608
2565
|
}
|
|
2609
2566
|
getName() {
|
|
2610
2567
|
const name = this.renderName || this.name;
|
|
2611
|
-
return this.renderBaseName ? `${this.renderBaseName}
|
|
2568
|
+
return this.renderBaseName ? `${this.renderBaseName}${getPropertyAccess(name)}` : name;
|
|
2612
2569
|
}
|
|
2613
2570
|
getReturnExpressionWhenCalledAtPath(_path, _recursionTracker, _origin) {
|
|
2614
2571
|
return UNKNOWN_EXPRESSION;
|
|
@@ -2648,6 +2605,9 @@ class Variable {
|
|
|
2648
2605
|
return this.name;
|
|
2649
2606
|
}
|
|
2650
2607
|
}
|
|
2608
|
+
const getPropertyAccess = (name) => {
|
|
2609
|
+
return /^(?!\d)[\w$]+$/.test(name) ? `.${name}` : `[${JSON.stringify(name)}]`;
|
|
2610
|
+
};
|
|
2651
2611
|
|
|
2652
2612
|
class ExternalVariable extends Variable {
|
|
2653
2613
|
constructor(module, name) {
|
|
@@ -2906,8 +2866,7 @@ class LocalVariable extends Variable {
|
|
|
2906
2866
|
if (trackedExpressions.has(this))
|
|
2907
2867
|
return false;
|
|
2908
2868
|
trackedExpressions.add(this);
|
|
2909
|
-
return (this.init &&
|
|
2910
|
-
this.init.hasEffectsWhenCalledAtPath(path, callOptions, context));
|
|
2869
|
+
return (this.init && this.init.hasEffectsWhenCalledAtPath(path, callOptions, context));
|
|
2911
2870
|
}
|
|
2912
2871
|
include(context) {
|
|
2913
2872
|
if (!this.included) {
|
|
@@ -4488,7 +4447,7 @@ class Identifier$1 extends NodeBase {
|
|
|
4488
4447
|
}
|
|
4489
4448
|
}
|
|
4490
4449
|
disallowImportReassignment() {
|
|
4491
|
-
this.context.error({
|
|
4450
|
+
return this.context.error({
|
|
4492
4451
|
code: 'ILLEGAL_REASSIGNMENT',
|
|
4493
4452
|
message: `Illegal reassignment to import '${this.name}'`
|
|
4494
4453
|
}, this.start);
|
|
@@ -4820,7 +4779,7 @@ class ExportShimVariable extends Variable {
|
|
|
4820
4779
|
}
|
|
4821
4780
|
|
|
4822
4781
|
class NamespaceVariable extends Variable {
|
|
4823
|
-
constructor(context) {
|
|
4782
|
+
constructor(context, syntheticNamedExports) {
|
|
4824
4783
|
super(context.getModuleName());
|
|
4825
4784
|
this.memberVariables = Object.create(null);
|
|
4826
4785
|
this.containsExternalNamespace = false;
|
|
@@ -4828,6 +4787,7 @@ class NamespaceVariable extends Variable {
|
|
|
4828
4787
|
this.references = [];
|
|
4829
4788
|
this.context = context;
|
|
4830
4789
|
this.module = context.module;
|
|
4790
|
+
this.syntheticNamedExports = syntheticNamedExports;
|
|
4831
4791
|
}
|
|
4832
4792
|
addReference(identifier) {
|
|
4833
4793
|
this.references.push(identifier);
|
|
@@ -4845,11 +4805,11 @@ class NamespaceVariable extends Variable {
|
|
|
4845
4805
|
include(context) {
|
|
4846
4806
|
if (!this.included) {
|
|
4847
4807
|
if (this.containsExternalNamespace) {
|
|
4848
|
-
this.context.error({
|
|
4808
|
+
return this.context.error({
|
|
4849
4809
|
code: 'NAMESPACE_CANNOT_CONTAIN_EXTERNAL',
|
|
4850
4810
|
id: this.module.id,
|
|
4851
4811
|
message: `Cannot create an explicit namespace object for module "${this.context.getModuleName()}" because it contains a reexported external namespace`
|
|
4852
|
-
}
|
|
4812
|
+
});
|
|
4853
4813
|
}
|
|
4854
4814
|
this.included = true;
|
|
4855
4815
|
for (const identifier of this.references) {
|
|
@@ -4892,9 +4852,14 @@ class NamespaceVariable extends Variable {
|
|
|
4892
4852
|
members.unshift(`${t}[Symbol.toStringTag]:${_}'Module'`);
|
|
4893
4853
|
}
|
|
4894
4854
|
const name = this.getName();
|
|
4895
|
-
|
|
4896
|
-
|
|
4897
|
-
|
|
4855
|
+
let output = `{${n}${members.join(`,${n}`)}${n}}`;
|
|
4856
|
+
if (this.syntheticNamedExports) {
|
|
4857
|
+
output = `/*#__PURE__*/Object.assign(${output}, ${this.module.getDefaultExport().getName()})`;
|
|
4858
|
+
}
|
|
4859
|
+
if (options.freeze) {
|
|
4860
|
+
output = `/*#__PURE__*/Object.freeze(${output})`;
|
|
4861
|
+
}
|
|
4862
|
+
output = `${options.varOrConst} ${name}${_}=${_}${output};`;
|
|
4898
4863
|
if (options.format === 'system' && this.exportName) {
|
|
4899
4864
|
output += `${n}exports('${this.exportName}',${_}${name});`;
|
|
4900
4865
|
}
|
|
@@ -5407,6 +5372,8 @@ var Errors;
|
|
|
5407
5372
|
Errors["UNRESOLVED_ENTRY"] = "UNRESOLVED_ENTRY";
|
|
5408
5373
|
Errors["UNRESOLVED_IMPORT"] = "UNRESOLVED_IMPORT";
|
|
5409
5374
|
Errors["VALIDATION_ERROR"] = "VALIDATION_ERROR";
|
|
5375
|
+
Errors["EXTERNAL_SYNTHETIC_EXPORTS"] = "EXTERNAL_SYNTHETIC_EXPORTS";
|
|
5376
|
+
Errors["SYNTHETIC_NAMED_EXPORTS_NEED_DEFAULT"] = "SYNTHETIC_NAMED_EXPORTS_NEED_DEFAULT";
|
|
5410
5377
|
})(Errors || (Errors = {}));
|
|
5411
5378
|
function errAssetNotFinalisedForFileName(name) {
|
|
5412
5379
|
return {
|
|
@@ -5559,6 +5526,14 @@ function errUnresolvedImportTreatedAsExternal(source, importer) {
|
|
|
5559
5526
|
url: 'https://rollupjs.org/guide/en/#warning-treating-module-as-external-dependency'
|
|
5560
5527
|
};
|
|
5561
5528
|
}
|
|
5529
|
+
function errExternalSyntheticExports(source, importer) {
|
|
5530
|
+
return {
|
|
5531
|
+
code: Errors.EXTERNAL_SYNTHETIC_EXPORTS,
|
|
5532
|
+
importer: index.relativeId(importer),
|
|
5533
|
+
message: `External '${source}' can not have 'syntheticNamedExports' enabled.`,
|
|
5534
|
+
source
|
|
5535
|
+
};
|
|
5536
|
+
}
|
|
5562
5537
|
function errFailedValidation(message) {
|
|
5563
5538
|
return {
|
|
5564
5539
|
code: Errors.VALIDATION_ERROR,
|
|
@@ -5629,7 +5604,7 @@ function iife(magicString, { dependencies, exports, hasExports, indentString: t,
|
|
|
5629
5604
|
const isNamespaced = name && name.indexOf('.') !== -1;
|
|
5630
5605
|
const useVariableAssignment = !extend && !isNamespaced;
|
|
5631
5606
|
if (name && useVariableAssignment && !isLegal(name)) {
|
|
5632
|
-
error({
|
|
5607
|
+
return error({
|
|
5633
5608
|
code: 'ILLEGAL_IDENTIFIER_AS_NAME',
|
|
5634
5609
|
message: `Given name "${name}" is not a legal JS identifier. If you need this, you can try "output.extend: true".`
|
|
5635
5610
|
});
|
|
@@ -5661,8 +5636,7 @@ function iife(magicString, { dependencies, exports, hasExports, indentString: t,
|
|
|
5661
5636
|
`${_}=${_}${wrapperIntro}`;
|
|
5662
5637
|
}
|
|
5663
5638
|
if (isNamespaced && hasExports) {
|
|
5664
|
-
wrapperIntro =
|
|
5665
|
-
setupNamespace(name, 'this', options.globals, options.compact) + wrapperIntro;
|
|
5639
|
+
wrapperIntro = setupNamespace(name, 'this', options.globals, options.compact) + wrapperIntro;
|
|
5666
5640
|
}
|
|
5667
5641
|
let wrapperOutro = `${n}${n}}(${deps.join(`,${_}`)}));`;
|
|
5668
5642
|
if (!extend && namedExportsMode && hasExports) {
|
|
@@ -5842,7 +5816,7 @@ function umd(magicString, { dependencies, exports, hasExports, indentString: t,
|
|
|
5842
5816
|
const factoryVar = options.compact ? 'f' : 'factory';
|
|
5843
5817
|
const globalVar = options.compact ? 'g' : 'global';
|
|
5844
5818
|
if (hasExports && !options.name) {
|
|
5845
|
-
error({
|
|
5819
|
+
return error({
|
|
5846
5820
|
code: 'INVALID_OPTION',
|
|
5847
5821
|
message: 'You must supply "output.name" for UMD bundles.'
|
|
5848
5822
|
});
|
|
@@ -6176,13 +6150,13 @@ function getSystemExportStatement(exportedVariables) {
|
|
|
6176
6150
|
}
|
|
6177
6151
|
|
|
6178
6152
|
class AssignmentExpression extends NodeBase {
|
|
6179
|
-
|
|
6180
|
-
super
|
|
6181
|
-
this.
|
|
6182
|
-
// We cannot propagate mutations of the new binding to the old binding with certainty
|
|
6183
|
-
this.right.deoptimizePath(UNKNOWN_PATH);
|
|
6153
|
+
constructor() {
|
|
6154
|
+
super(...arguments);
|
|
6155
|
+
this.deoptimized = false;
|
|
6184
6156
|
}
|
|
6185
6157
|
hasEffects(context) {
|
|
6158
|
+
if (!this.deoptimized)
|
|
6159
|
+
this.applyDeoptimizations();
|
|
6186
6160
|
return (this.right.hasEffects(context) ||
|
|
6187
6161
|
this.left.hasEffects(context) ||
|
|
6188
6162
|
this.left.hasEffectsWhenAssignedAtPath(EMPTY_PATH, context));
|
|
@@ -6190,6 +6164,13 @@ class AssignmentExpression extends NodeBase {
|
|
|
6190
6164
|
hasEffectsWhenAccessedAtPath(path, context) {
|
|
6191
6165
|
return path.length > 0 && this.right.hasEffectsWhenAccessedAtPath(path, context);
|
|
6192
6166
|
}
|
|
6167
|
+
include(context, includeChildrenRecursively) {
|
|
6168
|
+
if (!this.deoptimized)
|
|
6169
|
+
this.applyDeoptimizations();
|
|
6170
|
+
this.included = true;
|
|
6171
|
+
this.left.include(context, includeChildrenRecursively);
|
|
6172
|
+
this.right.include(context, includeChildrenRecursively);
|
|
6173
|
+
}
|
|
6193
6174
|
render(code, options) {
|
|
6194
6175
|
this.left.render(code, options);
|
|
6195
6176
|
this.right.render(code, options);
|
|
@@ -6212,6 +6193,11 @@ class AssignmentExpression extends NodeBase {
|
|
|
6212
6193
|
}
|
|
6213
6194
|
}
|
|
6214
6195
|
}
|
|
6196
|
+
applyDeoptimizations() {
|
|
6197
|
+
this.deoptimized = true;
|
|
6198
|
+
this.left.deoptimizePath(EMPTY_PATH);
|
|
6199
|
+
this.right.deoptimizePath(UNKNOWN_PATH);
|
|
6200
|
+
}
|
|
6215
6201
|
}
|
|
6216
6202
|
|
|
6217
6203
|
class AssignmentPattern extends NodeBase {
|
|
@@ -6593,7 +6579,7 @@ class MemberExpression extends NodeBase {
|
|
|
6593
6579
|
disallowNamespaceReassignment() {
|
|
6594
6580
|
if (this.object instanceof Identifier$1 &&
|
|
6595
6581
|
this.scope.findVariable(this.object.name).isNamespace) {
|
|
6596
|
-
this.context.error({
|
|
6582
|
+
return this.context.error({
|
|
6597
6583
|
code: 'ILLEGAL_NAMESPACE_REASSIGNMENT',
|
|
6598
6584
|
message: `Illegal reassignment to import '${this.object.name}'`
|
|
6599
6585
|
}, this.start);
|
|
@@ -6646,7 +6632,7 @@ class CallExpression$1 extends NodeBase {
|
|
|
6646
6632
|
if (this.callee instanceof Identifier$1) {
|
|
6647
6633
|
const variable = this.scope.findVariable(this.callee.name);
|
|
6648
6634
|
if (variable.isNamespace) {
|
|
6649
|
-
this.context.error({
|
|
6635
|
+
return this.context.error({
|
|
6650
6636
|
code: 'CANNOT_CALL_NAMESPACE',
|
|
6651
6637
|
message: `Cannot call a namespace ('${this.callee.name}')`
|
|
6652
6638
|
}, this.start);
|
|
@@ -7014,8 +7000,8 @@ class ConditionalExpression extends NodeBase {
|
|
|
7014
7000
|
include(context, includeChildrenRecursively) {
|
|
7015
7001
|
this.included = true;
|
|
7016
7002
|
if (includeChildrenRecursively ||
|
|
7017
|
-
this.
|
|
7018
|
-
this.
|
|
7003
|
+
this.test.shouldBeIncluded(context) ||
|
|
7004
|
+
this.usedBranch === null) {
|
|
7019
7005
|
this.test.include(context, includeChildrenRecursively);
|
|
7020
7006
|
this.consequent.include(context, includeChildrenRecursively);
|
|
7021
7007
|
this.alternate.include(context, includeChildrenRecursively);
|
|
@@ -7265,19 +7251,21 @@ class ForStatement extends NodeBase {
|
|
|
7265
7251
|
class FunctionExpression$1 extends FunctionNode {
|
|
7266
7252
|
}
|
|
7267
7253
|
|
|
7254
|
+
const unset = Symbol('unset');
|
|
7268
7255
|
class IfStatement extends NodeBase {
|
|
7269
|
-
|
|
7270
|
-
super
|
|
7271
|
-
|
|
7272
|
-
this.testValue = this.test.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, this);
|
|
7256
|
+
constructor() {
|
|
7257
|
+
super(...arguments);
|
|
7258
|
+
this.testValue = unset;
|
|
7273
7259
|
}
|
|
7274
7260
|
deoptimizeCache() {
|
|
7275
7261
|
this.testValue = UnknownValue;
|
|
7276
7262
|
}
|
|
7277
7263
|
hasEffects(context) {
|
|
7278
|
-
if (this.test.hasEffects(context))
|
|
7264
|
+
if (this.test.hasEffects(context)) {
|
|
7279
7265
|
return true;
|
|
7280
|
-
|
|
7266
|
+
}
|
|
7267
|
+
const testValue = this.getTestValue();
|
|
7268
|
+
if (testValue === UnknownValue) {
|
|
7281
7269
|
const { brokenFlow } = context;
|
|
7282
7270
|
if (this.consequent.hasEffects(context))
|
|
7283
7271
|
return true;
|
|
@@ -7291,7 +7279,7 @@ class IfStatement extends NodeBase {
|
|
|
7291
7279
|
context.brokenFlow < consequentBrokenFlow ? context.brokenFlow : consequentBrokenFlow;
|
|
7292
7280
|
return false;
|
|
7293
7281
|
}
|
|
7294
|
-
return
|
|
7282
|
+
return testValue
|
|
7295
7283
|
? this.consequent.hasEffects(context)
|
|
7296
7284
|
: this.alternate !== null && this.alternate.hasEffects(context);
|
|
7297
7285
|
}
|
|
@@ -7300,22 +7288,22 @@ class IfStatement extends NodeBase {
|
|
|
7300
7288
|
if (includeChildrenRecursively) {
|
|
7301
7289
|
this.includeRecursively(includeChildrenRecursively, context);
|
|
7302
7290
|
}
|
|
7303
|
-
else if (this.testValue === UnknownValue) {
|
|
7304
|
-
this.includeUnknownTest(context);
|
|
7305
|
-
}
|
|
7306
7291
|
else {
|
|
7307
|
-
this.
|
|
7292
|
+
const testValue = this.getTestValue();
|
|
7293
|
+
if (testValue === UnknownValue) {
|
|
7294
|
+
this.includeUnknownTest(context);
|
|
7295
|
+
}
|
|
7296
|
+
else {
|
|
7297
|
+
this.includeKnownTest(context, testValue);
|
|
7298
|
+
}
|
|
7308
7299
|
}
|
|
7309
7300
|
}
|
|
7310
7301
|
render(code, options) {
|
|
7311
7302
|
// Note that unknown test values are always included
|
|
7303
|
+
const testValue = this.getTestValue();
|
|
7312
7304
|
if (!this.test.included &&
|
|
7313
|
-
(this.
|
|
7314
|
-
|
|
7315
|
-
: !this.consequent.included)) {
|
|
7316
|
-
const singleRetainedBranch = (this.testValue
|
|
7317
|
-
? this.consequent
|
|
7318
|
-
: this.alternate);
|
|
7305
|
+
(testValue ? this.alternate === null || !this.alternate.included : !this.consequent.included)) {
|
|
7306
|
+
const singleRetainedBranch = (testValue ? this.consequent : this.alternate);
|
|
7319
7307
|
code.remove(this.start, singleRetainedBranch.start);
|
|
7320
7308
|
code.remove(singleRetainedBranch.end, this.end);
|
|
7321
7309
|
removeAnnotations(this, code);
|
|
@@ -7326,7 +7314,7 @@ class IfStatement extends NodeBase {
|
|
|
7326
7314
|
this.test.render(code, options);
|
|
7327
7315
|
}
|
|
7328
7316
|
else {
|
|
7329
|
-
code.overwrite(this.test.start, this.test.end,
|
|
7317
|
+
code.overwrite(this.test.start, this.test.end, testValue ? 'true' : 'false');
|
|
7330
7318
|
}
|
|
7331
7319
|
if (this.consequent.included) {
|
|
7332
7320
|
this.consequent.render(code, options);
|
|
@@ -7344,14 +7332,20 @@ class IfStatement extends NodeBase {
|
|
|
7344
7332
|
}
|
|
7345
7333
|
}
|
|
7346
7334
|
}
|
|
7347
|
-
|
|
7335
|
+
getTestValue() {
|
|
7336
|
+
if (this.testValue === unset) {
|
|
7337
|
+
return (this.testValue = this.test.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, this));
|
|
7338
|
+
}
|
|
7339
|
+
return this.testValue;
|
|
7340
|
+
}
|
|
7341
|
+
includeKnownTest(context, testValue) {
|
|
7348
7342
|
if (this.test.shouldBeIncluded(context)) {
|
|
7349
7343
|
this.test.include(context, false);
|
|
7350
7344
|
}
|
|
7351
|
-
if (
|
|
7345
|
+
if (testValue && this.consequent.shouldBeIncluded(context)) {
|
|
7352
7346
|
this.consequent.include(context, false);
|
|
7353
7347
|
}
|
|
7354
|
-
if (this.alternate !== null && !
|
|
7348
|
+
if (this.alternate !== null && !testValue && this.alternate.shouldBeIncluded(context)) {
|
|
7355
7349
|
this.alternate.include(context, false);
|
|
7356
7350
|
}
|
|
7357
7351
|
}
|
|
@@ -7631,8 +7625,8 @@ class LogicalExpression extends NodeBase {
|
|
|
7631
7625
|
include(context, includeChildrenRecursively) {
|
|
7632
7626
|
this.included = true;
|
|
7633
7627
|
if (includeChildrenRecursively ||
|
|
7634
|
-
this.usedBranch ===
|
|
7635
|
-
this.
|
|
7628
|
+
(this.usedBranch === this.right && this.left.shouldBeIncluded(context)) ||
|
|
7629
|
+
this.usedBranch === null) {
|
|
7636
7630
|
this.left.include(context, includeChildrenRecursively);
|
|
7637
7631
|
this.right.include(context, includeChildrenRecursively);
|
|
7638
7632
|
}
|
|
@@ -7766,7 +7760,7 @@ function addJsExtensionIfNecessary(file, preserveSymlinks) {
|
|
|
7766
7760
|
function createResolveId(preserveSymlinks) {
|
|
7767
7761
|
return function (source, importer) {
|
|
7768
7762
|
if (typeof process === 'undefined') {
|
|
7769
|
-
error({
|
|
7763
|
+
return error({
|
|
7770
7764
|
code: 'MISSING_PROCESS',
|
|
7771
7765
|
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`,
|
|
7772
7766
|
url: 'https://rollupjs.org/guide/en/#a-simple-example'
|
|
@@ -8350,8 +8344,7 @@ class Property$1 extends NodeBase {
|
|
|
8350
8344
|
return false;
|
|
8351
8345
|
trackedExpressions.add(this);
|
|
8352
8346
|
return (this.value.hasEffectsWhenCalledAtPath(EMPTY_PATH, this.accessorCallOptions, context) ||
|
|
8353
|
-
(path.length > 0 &&
|
|
8354
|
-
this.returnExpression.hasEffectsWhenAccessedAtPath(path, context)));
|
|
8347
|
+
(path.length > 0 && this.returnExpression.hasEffectsWhenAccessedAtPath(path, context)));
|
|
8355
8348
|
}
|
|
8356
8349
|
return this.value.hasEffectsWhenAccessedAtPath(path, context);
|
|
8357
8350
|
}
|
|
@@ -8606,14 +8599,15 @@ class TaggedTemplateExpression extends NodeBase {
|
|
|
8606
8599
|
bind() {
|
|
8607
8600
|
super.bind();
|
|
8608
8601
|
if (this.tag.type === Identifier) {
|
|
8609
|
-
const
|
|
8602
|
+
const name = this.tag.name;
|
|
8603
|
+
const variable = this.scope.findVariable(name);
|
|
8610
8604
|
if (variable.isNamespace) {
|
|
8611
|
-
this.context.error({
|
|
8605
|
+
return this.context.error({
|
|
8612
8606
|
code: 'CANNOT_CALL_NAMESPACE',
|
|
8613
|
-
message: `Cannot call a namespace ('${
|
|
8607
|
+
message: `Cannot call a namespace ('${name}')`
|
|
8614
8608
|
}, this.start);
|
|
8615
8609
|
}
|
|
8616
|
-
if (
|
|
8610
|
+
if (name === 'eval') {
|
|
8617
8611
|
this.context.warn({
|
|
8618
8612
|
code: 'EVAL',
|
|
8619
8613
|
message: `Use of eval is strongly discouraged, as it poses security risks and may cause issues with minification`,
|
|
@@ -8986,8 +8980,7 @@ class VariableDeclaration extends NodeBase {
|
|
|
8986
8980
|
node.id.addExportedVariables(systemPatternExports);
|
|
8987
8981
|
}
|
|
8988
8982
|
else if (node.id.variable.exportName) {
|
|
8989
|
-
code.prependLeft(code.original.indexOf('=', node.id.end) + 1, ` exports('${node.id.variable.safeExportName ||
|
|
8990
|
-
node.id.variable.exportName}',`);
|
|
8983
|
+
code.prependLeft(code.original.indexOf('=', node.id.end) + 1, ` exports('${node.id.variable.safeExportName || node.id.variable.exportName}',`);
|
|
8991
8984
|
nextSeparatorString += ')';
|
|
8992
8985
|
}
|
|
8993
8986
|
}
|
|
@@ -9152,6 +9145,22 @@ const nodeConstructors = {
|
|
|
9152
9145
|
YieldExpression
|
|
9153
9146
|
};
|
|
9154
9147
|
|
|
9148
|
+
class SyntheticNamedExportVariableVariable extends Variable {
|
|
9149
|
+
constructor(context, name, defaultVariable) {
|
|
9150
|
+
super(name);
|
|
9151
|
+
this.context = context;
|
|
9152
|
+
this.module = context.module;
|
|
9153
|
+
this.defaultVariable = defaultVariable;
|
|
9154
|
+
this.setRenderNames(defaultVariable.getName(), name);
|
|
9155
|
+
}
|
|
9156
|
+
include(context) {
|
|
9157
|
+
if (!this.included) {
|
|
9158
|
+
this.included = true;
|
|
9159
|
+
this.context.includeVariable(context, this.defaultVariable);
|
|
9160
|
+
}
|
|
9161
|
+
}
|
|
9162
|
+
}
|
|
9163
|
+
|
|
9155
9164
|
function getOriginalLocation(sourcemapChain, location) {
|
|
9156
9165
|
// This cast is guaranteed. If it were a missing Map, it wouldn't have a mappings.
|
|
9157
9166
|
const filteredSourcemapChain = sourcemapChain.filter(sourcemap => sourcemap.mappings);
|
|
@@ -9609,12 +9618,12 @@ function tryParse(module, Parser, acornOptions) {
|
|
|
9609
9618
|
catch (err) {
|
|
9610
9619
|
let message = err.message.replace(/ \(\d+:\d+\)$/, '');
|
|
9611
9620
|
if (module.id.endsWith('.json')) {
|
|
9612
|
-
message += ' (Note that you need rollup
|
|
9621
|
+
message += ' (Note that you need @rollup/plugin-json to import JSON files)';
|
|
9613
9622
|
}
|
|
9614
9623
|
else if (!module.id.endsWith('.js')) {
|
|
9615
9624
|
message += ' (Note that you need plugins to import files that are not JavaScript)';
|
|
9616
9625
|
}
|
|
9617
|
-
module.error({
|
|
9626
|
+
return module.error({
|
|
9618
9627
|
code: 'PARSE_ERROR',
|
|
9619
9628
|
message,
|
|
9620
9629
|
parserError: err
|
|
@@ -9622,7 +9631,7 @@ function tryParse(module, Parser, acornOptions) {
|
|
|
9622
9631
|
}
|
|
9623
9632
|
}
|
|
9624
9633
|
function handleMissingExport(exportName, importingModule, importedModule, importerStart) {
|
|
9625
|
-
importingModule.error({
|
|
9634
|
+
return importingModule.error({
|
|
9626
9635
|
code: 'MISSING_EXPORT',
|
|
9627
9636
|
message: `'${exportName}' is not exported by ${index.relativeId(importedModule)}`,
|
|
9628
9637
|
url: `https://rollupjs.org/guide/en/#error-name-is-not-exported-by-module`
|
|
@@ -9632,8 +9641,21 @@ const MISSING_EXPORT_SHIM_DESCRIPTION = {
|
|
|
9632
9641
|
identifier: null,
|
|
9633
9642
|
localName: MISSING_EXPORT_SHIM_VARIABLE
|
|
9634
9643
|
};
|
|
9644
|
+
function getVariableForExportNameRecursive(target, name, isExportAllSearch, searchedNamesAndModules = new Map()) {
|
|
9645
|
+
const searchedModules = searchedNamesAndModules.get(name);
|
|
9646
|
+
if (searchedModules) {
|
|
9647
|
+
if (searchedModules.has(target)) {
|
|
9648
|
+
return null;
|
|
9649
|
+
}
|
|
9650
|
+
searchedModules.add(target);
|
|
9651
|
+
}
|
|
9652
|
+
else {
|
|
9653
|
+
searchedNamesAndModules.set(name, new Set([target]));
|
|
9654
|
+
}
|
|
9655
|
+
return target.getVariableForExportName(name, isExportAllSearch, searchedNamesAndModules);
|
|
9656
|
+
}
|
|
9635
9657
|
class Module {
|
|
9636
|
-
constructor(graph, id, moduleSideEffects, isEntry) {
|
|
9658
|
+
constructor(graph, id, moduleSideEffects, syntheticNamedExports, isEntry) {
|
|
9637
9659
|
this.chunk = null;
|
|
9638
9660
|
this.chunkFileNames = new Set();
|
|
9639
9661
|
this.chunkName = null;
|
|
@@ -9661,7 +9683,9 @@ class Module {
|
|
|
9661
9683
|
this.userChunkNames = new Set();
|
|
9662
9684
|
this.usesTopLevelAwait = false;
|
|
9663
9685
|
this.allExportNames = null;
|
|
9686
|
+
this.defaultExport = null;
|
|
9664
9687
|
this.namespaceVariable = null;
|
|
9688
|
+
this.syntheticExports = new Map();
|
|
9665
9689
|
this.transformDependencies = [];
|
|
9666
9690
|
this.transitiveReexports = null;
|
|
9667
9691
|
this.id = id;
|
|
@@ -9669,6 +9693,7 @@ class Module {
|
|
|
9669
9693
|
this.excludeFromSourcemap = /\0/.test(id);
|
|
9670
9694
|
this.context = graph.getModuleContext(id);
|
|
9671
9695
|
this.moduleSideEffects = moduleSideEffects;
|
|
9696
|
+
this.syntheticNamedExports = syntheticNamedExports;
|
|
9672
9697
|
this.isEntryPoint = isEntry;
|
|
9673
9698
|
}
|
|
9674
9699
|
basename() {
|
|
@@ -9680,7 +9705,7 @@ class Module {
|
|
|
9680
9705
|
this.ast.bind();
|
|
9681
9706
|
}
|
|
9682
9707
|
error(props, pos) {
|
|
9683
|
-
if (pos
|
|
9708
|
+
if (typeof pos === 'number') {
|
|
9684
9709
|
props.pos = pos;
|
|
9685
9710
|
let location = locate(this.code, pos, { offsetLine: 1 });
|
|
9686
9711
|
try {
|
|
@@ -9696,7 +9721,7 @@ class Module {
|
|
|
9696
9721
|
},
|
|
9697
9722
|
message: `Error when using sourcemap for reporting an error: ${e.message}`,
|
|
9698
9723
|
pos
|
|
9699
|
-
}
|
|
9724
|
+
});
|
|
9700
9725
|
}
|
|
9701
9726
|
props.loc = {
|
|
9702
9727
|
column: location.column,
|
|
@@ -9705,7 +9730,7 @@ class Module {
|
|
|
9705
9730
|
};
|
|
9706
9731
|
props.frame = getCodeFrame(this.originalCode, location.line, location.column);
|
|
9707
9732
|
}
|
|
9708
|
-
error(props);
|
|
9733
|
+
return error(props);
|
|
9709
9734
|
}
|
|
9710
9735
|
getAllExportNames() {
|
|
9711
9736
|
if (this.allExportNames) {
|
|
@@ -9730,6 +9755,20 @@ class Module {
|
|
|
9730
9755
|
}
|
|
9731
9756
|
return allExportNames;
|
|
9732
9757
|
}
|
|
9758
|
+
getDefaultExport() {
|
|
9759
|
+
if (this.defaultExport === null) {
|
|
9760
|
+
this.defaultExport = undefined;
|
|
9761
|
+
this.defaultExport = this.getVariableForExportName('default');
|
|
9762
|
+
}
|
|
9763
|
+
if (!this.defaultExport) {
|
|
9764
|
+
return error({
|
|
9765
|
+
code: Errors.SYNTHETIC_NAMED_EXPORTS_NEED_DEFAULT,
|
|
9766
|
+
id: this.id,
|
|
9767
|
+
message: `Modules with 'syntheticNamedExports' need a default export.`
|
|
9768
|
+
});
|
|
9769
|
+
}
|
|
9770
|
+
return this.defaultExport;
|
|
9771
|
+
}
|
|
9733
9772
|
getDynamicImportExpressions() {
|
|
9734
9773
|
return this.dynamicImports.map(({ node }) => {
|
|
9735
9774
|
const importArgument = node.source;
|
|
@@ -9767,7 +9806,7 @@ class Module {
|
|
|
9767
9806
|
}
|
|
9768
9807
|
getOrCreateNamespace() {
|
|
9769
9808
|
if (!this.namespaceVariable) {
|
|
9770
|
-
this.namespaceVariable = new NamespaceVariable(this.astContext);
|
|
9809
|
+
this.namespaceVariable = new NamespaceVariable(this.astContext, this.syntheticNamedExports);
|
|
9771
9810
|
this.namespaceVariable.initialise();
|
|
9772
9811
|
}
|
|
9773
9812
|
return this.namespaceVariable;
|
|
@@ -9810,7 +9849,7 @@ class Module {
|
|
|
9810
9849
|
.concat(this.getExports())
|
|
9811
9850
|
.map((exportName) => this.getVariableForExportName(exportName).module));
|
|
9812
9851
|
}
|
|
9813
|
-
getVariableForExportName(name, isExportAllSearch) {
|
|
9852
|
+
getVariableForExportName(name, isExportAllSearch, searchedNamesAndModules) {
|
|
9814
9853
|
if (name[0] === '*') {
|
|
9815
9854
|
if (name.length === 1) {
|
|
9816
9855
|
return this.getOrCreateNamespace();
|
|
@@ -9824,9 +9863,9 @@ class Module {
|
|
|
9824
9863
|
// export { foo } from './other'
|
|
9825
9864
|
const reexportDeclaration = this.reexportDescriptions[name];
|
|
9826
9865
|
if (reexportDeclaration) {
|
|
9827
|
-
const declaration = reexportDeclaration.module
|
|
9866
|
+
const declaration = getVariableForExportNameRecursive(reexportDeclaration.module, reexportDeclaration.localName, false, searchedNamesAndModules);
|
|
9828
9867
|
if (!declaration) {
|
|
9829
|
-
handleMissingExport(reexportDeclaration.localName, this, reexportDeclaration.module.id, reexportDeclaration.start);
|
|
9868
|
+
return handleMissingExport(reexportDeclaration.localName, this, reexportDeclaration.module.id, reexportDeclaration.start);
|
|
9830
9869
|
}
|
|
9831
9870
|
return declaration;
|
|
9832
9871
|
}
|
|
@@ -9840,18 +9879,30 @@ class Module {
|
|
|
9840
9879
|
}
|
|
9841
9880
|
if (name !== 'default') {
|
|
9842
9881
|
for (const module of this.exportAllModules) {
|
|
9843
|
-
const declaration = module
|
|
9882
|
+
const declaration = getVariableForExportNameRecursive(module, name, true, searchedNamesAndModules);
|
|
9844
9883
|
if (declaration)
|
|
9845
9884
|
return declaration;
|
|
9846
9885
|
}
|
|
9847
9886
|
}
|
|
9848
9887
|
// we don't want to create shims when we are just
|
|
9849
9888
|
// probing export * modules for exports
|
|
9850
|
-
if (
|
|
9851
|
-
this.
|
|
9852
|
-
|
|
9889
|
+
if (!isExportAllSearch) {
|
|
9890
|
+
if (this.syntheticNamedExports) {
|
|
9891
|
+
let syntheticExport = this.syntheticExports.get(name);
|
|
9892
|
+
if (!syntheticExport) {
|
|
9893
|
+
const defaultExport = this.getDefaultExport();
|
|
9894
|
+
syntheticExport = new SyntheticNamedExportVariableVariable(this.astContext, name, defaultExport);
|
|
9895
|
+
this.syntheticExports.set(name, syntheticExport);
|
|
9896
|
+
return syntheticExport;
|
|
9897
|
+
}
|
|
9898
|
+
return syntheticExport;
|
|
9899
|
+
}
|
|
9900
|
+
if (this.graph.shimMissingExports) {
|
|
9901
|
+
this.shimMissingExport(name);
|
|
9902
|
+
return this.exportShimVariable;
|
|
9903
|
+
}
|
|
9853
9904
|
}
|
|
9854
|
-
return
|
|
9905
|
+
return null;
|
|
9855
9906
|
}
|
|
9856
9907
|
include() {
|
|
9857
9908
|
const context = createInclusionContext();
|
|
@@ -9918,7 +9969,7 @@ class Module {
|
|
|
9918
9969
|
this.usesTopLevelAwait = this.astContext.usesTopLevelAwait;
|
|
9919
9970
|
return magicString;
|
|
9920
9971
|
}
|
|
9921
|
-
setSource({ ast, code, customTransformCache, moduleSideEffects, originalCode, originalSourcemap, resolvedIds, sourcemapChain, transformDependencies, transformFiles }) {
|
|
9972
|
+
setSource({ ast, code, customTransformCache, moduleSideEffects, originalCode, originalSourcemap, resolvedIds, sourcemapChain, syntheticNamedExports, transformDependencies, transformFiles }) {
|
|
9922
9973
|
this.code = code;
|
|
9923
9974
|
this.originalCode = originalCode;
|
|
9924
9975
|
this.originalSourcemap = originalSourcemap;
|
|
@@ -9931,6 +9982,9 @@ class Module {
|
|
|
9931
9982
|
if (typeof moduleSideEffects === 'boolean') {
|
|
9932
9983
|
this.moduleSideEffects = moduleSideEffects;
|
|
9933
9984
|
}
|
|
9985
|
+
if (typeof syntheticNamedExports === 'boolean') {
|
|
9986
|
+
this.syntheticNamedExports = syntheticNamedExports;
|
|
9987
|
+
}
|
|
9934
9988
|
timeStart('generate ast', 3);
|
|
9935
9989
|
this.esTreeAst = ast || tryParse(this, this.graph.acornParser, this.graph.acornOptions);
|
|
9936
9990
|
markPureCallExpressions(this.comments, this.esTreeAst);
|
|
@@ -9950,8 +10004,7 @@ class Module {
|
|
|
9950
10004
|
addExport: this.addExport.bind(this),
|
|
9951
10005
|
addImport: this.addImport.bind(this),
|
|
9952
10006
|
addImportMeta: this.addImportMeta.bind(this),
|
|
9953
|
-
annotations: (this.graph.treeshakingOptions &&
|
|
9954
|
-
this.graph.treeshakingOptions.annotations),
|
|
10007
|
+
annotations: (this.graph.treeshakingOptions && this.graph.treeshakingOptions.annotations),
|
|
9955
10008
|
code,
|
|
9956
10009
|
deoptimizationTracker: this.graph.deoptimizationTracker,
|
|
9957
10010
|
error: this.error.bind(this),
|
|
@@ -9998,6 +10051,7 @@ class Module {
|
|
|
9998
10051
|
originalSourcemap: this.originalSourcemap,
|
|
9999
10052
|
resolvedIds: this.resolvedIds,
|
|
10000
10053
|
sourcemapChain: this.sourcemapChain,
|
|
10054
|
+
syntheticNamedExports: this.syntheticNamedExports,
|
|
10001
10055
|
transformDependencies: this.transformDependencies,
|
|
10002
10056
|
transformFiles: this.transformFiles
|
|
10003
10057
|
};
|
|
@@ -10015,14 +10069,14 @@ class Module {
|
|
|
10015
10069
|
}
|
|
10016
10070
|
const declaration = otherModule.getVariableForExportName(importDeclaration.name);
|
|
10017
10071
|
if (!declaration) {
|
|
10018
|
-
handleMissingExport(importDeclaration.name, this, otherModule.id, importDeclaration.start);
|
|
10072
|
+
return handleMissingExport(importDeclaration.name, this, otherModule.id, importDeclaration.start);
|
|
10019
10073
|
}
|
|
10020
10074
|
return declaration;
|
|
10021
10075
|
}
|
|
10022
10076
|
return null;
|
|
10023
10077
|
}
|
|
10024
10078
|
warn(warning, pos) {
|
|
10025
|
-
if (pos
|
|
10079
|
+
if (typeof pos === 'number') {
|
|
10026
10080
|
warning.pos = pos;
|
|
10027
10081
|
const { line, column } = locate(this.code, pos, { offsetLine: 1 }); // TODO trace sourcemaps, cf. error()
|
|
10028
10082
|
warning.loc = { file: this.id, line, column };
|
|
@@ -10094,7 +10148,7 @@ class Module {
|
|
|
10094
10148
|
for (const specifier of node.specifiers) {
|
|
10095
10149
|
const localName = specifier.local.name;
|
|
10096
10150
|
if (this.importDescriptions[localName]) {
|
|
10097
|
-
this.error({
|
|
10151
|
+
return this.error({
|
|
10098
10152
|
code: 'DUPLICATE_IMPORT',
|
|
10099
10153
|
message: `Duplicated import '${localName}'`
|
|
10100
10154
|
}, specifier.start);
|
|
@@ -10106,7 +10160,12 @@ class Module {
|
|
|
10106
10160
|
: isNamespace
|
|
10107
10161
|
? '*'
|
|
10108
10162
|
: specifier.imported.name;
|
|
10109
|
-
this.importDescriptions[localName] = {
|
|
10163
|
+
this.importDescriptions[localName] = {
|
|
10164
|
+
module: null,
|
|
10165
|
+
name,
|
|
10166
|
+
source,
|
|
10167
|
+
start: specifier.start
|
|
10168
|
+
};
|
|
10110
10169
|
}
|
|
10111
10170
|
}
|
|
10112
10171
|
addImportMeta(node) {
|
|
@@ -10199,7 +10258,7 @@ class Link {
|
|
|
10199
10258
|
}
|
|
10200
10259
|
else if (traced.source.content != null &&
|
|
10201
10260
|
sourcesContent[sourceIndex] !== traced.source.content) {
|
|
10202
|
-
error({
|
|
10261
|
+
return error({
|
|
10203
10262
|
message: `Multiple conflicting contents for sourcemap source ${traced.source.filename}`
|
|
10204
10263
|
});
|
|
10205
10264
|
}
|
|
@@ -10572,12 +10631,13 @@ function renderNamePattern(pattern, patternName, replacements) {
|
|
|
10572
10631
|
});
|
|
10573
10632
|
}
|
|
10574
10633
|
function makeUnique(name, existingNames) {
|
|
10575
|
-
|
|
10634
|
+
const existingNamesLowercase = new Set(Object.keys(existingNames).map(key => key.toLowerCase()));
|
|
10635
|
+
if (!existingNamesLowercase.has(name.toLocaleLowerCase()))
|
|
10576
10636
|
return name;
|
|
10577
10637
|
const ext = path.extname(name);
|
|
10578
10638
|
name = name.substr(0, name.length - ext.length);
|
|
10579
10639
|
let uniqueName, uniqueIndex = 1;
|
|
10580
|
-
while (
|
|
10640
|
+
while (existingNamesLowercase.has((uniqueName = name + ++uniqueIndex + ext).toLowerCase()))
|
|
10581
10641
|
;
|
|
10582
10642
|
return uniqueName;
|
|
10583
10643
|
}
|
|
@@ -11071,7 +11131,7 @@ class Chunk$1 {
|
|
|
11071
11131
|
}
|
|
11072
11132
|
}
|
|
11073
11133
|
if (usesTopLevelAwait && format !== 'es' && format !== 'system') {
|
|
11074
|
-
error({
|
|
11134
|
+
return error({
|
|
11075
11135
|
code: 'INVALID_TLA_FORMAT',
|
|
11076
11136
|
message: `Module format ${format} does not support top-level await. Use the "es" or "system" output formats rather.`
|
|
11077
11137
|
});
|
|
@@ -11844,6 +11904,7 @@ function transform(graph, source, module) {
|
|
|
11844
11904
|
const emittedFiles = [];
|
|
11845
11905
|
let customTransformCache = false;
|
|
11846
11906
|
let moduleSideEffects = null;
|
|
11907
|
+
let syntheticNamedExports = null;
|
|
11847
11908
|
let trackedPluginCache;
|
|
11848
11909
|
let curPlugin;
|
|
11849
11910
|
const curSource = source.code;
|
|
@@ -11885,6 +11946,9 @@ function transform(graph, source, module) {
|
|
|
11885
11946
|
if (typeof result.moduleSideEffects === 'boolean') {
|
|
11886
11947
|
moduleSideEffects = result.moduleSideEffects;
|
|
11887
11948
|
}
|
|
11949
|
+
if (typeof result.syntheticNamedExports === 'boolean') {
|
|
11950
|
+
syntheticNamedExports = result.syntheticNamedExports;
|
|
11951
|
+
}
|
|
11888
11952
|
}
|
|
11889
11953
|
else {
|
|
11890
11954
|
return code;
|
|
@@ -11945,7 +12009,7 @@ function transform(graph, source, module) {
|
|
|
11945
12009
|
pluginContext.setAssetSource(assetReferenceId, source);
|
|
11946
12010
|
if (!customTransformCache && !setAssetSourceErr) {
|
|
11947
12011
|
try {
|
|
11948
|
-
this.error({
|
|
12012
|
+
return this.error({
|
|
11949
12013
|
code: 'INVALID_SETASSETSOURCE',
|
|
11950
12014
|
message: `setAssetSource cannot be called in transform for caching reasons. Use emitFile with a source, or call setAssetSource in another hook.`
|
|
11951
12015
|
});
|
|
@@ -11980,6 +12044,7 @@ function transform(graph, source, module) {
|
|
|
11980
12044
|
originalCode,
|
|
11981
12045
|
originalSourcemap,
|
|
11982
12046
|
sourcemapChain,
|
|
12047
|
+
syntheticNamedExports,
|
|
11983
12048
|
transformDependencies
|
|
11984
12049
|
};
|
|
11985
12050
|
});
|
|
@@ -12036,7 +12101,7 @@ class ModuleLoader {
|
|
|
12036
12101
|
? resolveIdResult.id
|
|
12037
12102
|
: resolveIdResult;
|
|
12038
12103
|
if (typeof id === 'string') {
|
|
12039
|
-
return this.fetchModule(id, undefined, true, isEntry);
|
|
12104
|
+
return this.fetchModule(id, undefined, true, false, isEntry);
|
|
12040
12105
|
}
|
|
12041
12106
|
return error(errUnresolvedEntry(unresolvedId));
|
|
12042
12107
|
});
|
|
@@ -12101,7 +12166,7 @@ class ModuleLoader {
|
|
|
12101
12166
|
return this.awaitLoadModulesPromise(loadNewManualChunkModulesPromise);
|
|
12102
12167
|
}
|
|
12103
12168
|
resolveId(source, importer, skip) {
|
|
12104
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
12169
|
+
return index.__awaiter(this, void 0, void 0, function* () {
|
|
12105
12170
|
return this.normalizeResolveIdResult(this.isExternal(source, importer, false)
|
|
12106
12171
|
? false
|
|
12107
12172
|
: yield this.pluginDriver.hookFirst('resolveId', [source, importer], null, skip), importer, source);
|
|
@@ -12109,7 +12174,7 @@ class ModuleLoader {
|
|
|
12109
12174
|
}
|
|
12110
12175
|
addModuleToManualChunk(alias, module) {
|
|
12111
12176
|
if (module.manualChunkAlias !== null && module.manualChunkAlias !== alias) {
|
|
12112
|
-
error(errCannotAssignModuleToChunk(module.id, alias, module.manualChunkAlias));
|
|
12177
|
+
return error(errCannotAssignModuleToChunk(module.id, alias, module.manualChunkAlias));
|
|
12113
12178
|
}
|
|
12114
12179
|
module.manualChunkAlias = alias;
|
|
12115
12180
|
if (!this.manualChunkModules[alias]) {
|
|
@@ -12134,10 +12199,10 @@ class ModuleLoader {
|
|
|
12134
12199
|
}
|
|
12135
12200
|
fetchAllDependencies(module) {
|
|
12136
12201
|
return Promise.all([
|
|
12137
|
-
...Array.from(module.sources).map((source) => __awaiter(this, void 0, void 0, function* () {
|
|
12202
|
+
...Array.from(module.sources).map((source) => index.__awaiter(this, void 0, void 0, function* () {
|
|
12138
12203
|
return this.fetchResolvedDependency(source, module.id, (module.resolvedIds[source] =
|
|
12139
12204
|
module.resolvedIds[source] ||
|
|
12140
|
-
this.
|
|
12205
|
+
this.handleResolveId(yield this.resolveId(source, module.id), source, module.id)));
|
|
12141
12206
|
})),
|
|
12142
12207
|
...module.getDynamicImportExpressions().map((specifier, index$1) => this.resolveDynamicImport(module, specifier, module.id).then(resolvedId => {
|
|
12143
12208
|
if (resolvedId === null)
|
|
@@ -12153,13 +12218,13 @@ class ModuleLoader {
|
|
|
12153
12218
|
}))
|
|
12154
12219
|
]);
|
|
12155
12220
|
}
|
|
12156
|
-
fetchModule(id, importer, moduleSideEffects, isEntry) {
|
|
12221
|
+
fetchModule(id, importer, moduleSideEffects, syntheticNamedExports, isEntry) {
|
|
12157
12222
|
const existingModule = this.modulesById.get(id);
|
|
12158
12223
|
if (existingModule instanceof Module) {
|
|
12159
12224
|
existingModule.isEntryPoint = existingModule.isEntryPoint || isEntry;
|
|
12160
12225
|
return Promise.resolve(existingModule);
|
|
12161
12226
|
}
|
|
12162
|
-
const module = new Module(this.graph, id, moduleSideEffects, isEntry);
|
|
12227
|
+
const module = new Module(this.graph, id, moduleSideEffects, syntheticNamedExports, isEntry);
|
|
12163
12228
|
this.modulesById.set(id, module);
|
|
12164
12229
|
this.graph.watchFiles[id] = true;
|
|
12165
12230
|
const manualChunkAlias = this.getManualChunk(id);
|
|
@@ -12199,6 +12264,9 @@ class ModuleLoader {
|
|
|
12199
12264
|
if (typeof sourceDescription.moduleSideEffects === 'boolean') {
|
|
12200
12265
|
module.moduleSideEffects = sourceDescription.moduleSideEffects;
|
|
12201
12266
|
}
|
|
12267
|
+
if (typeof sourceDescription.syntheticNamedExports === 'boolean') {
|
|
12268
|
+
module.syntheticNamedExports = sourceDescription.syntheticNamedExports;
|
|
12269
|
+
}
|
|
12202
12270
|
return transform(this.graph, sourceDescription, module);
|
|
12203
12271
|
})
|
|
12204
12272
|
.then((source) => {
|
|
@@ -12240,27 +12308,34 @@ class ModuleLoader {
|
|
|
12240
12308
|
return Promise.resolve(externalModule);
|
|
12241
12309
|
}
|
|
12242
12310
|
else {
|
|
12243
|
-
return this.fetchModule(resolvedId.id, importer, resolvedId.moduleSideEffects, false);
|
|
12311
|
+
return this.fetchModule(resolvedId.id, importer, resolvedId.moduleSideEffects, resolvedId.syntheticNamedExports, false);
|
|
12244
12312
|
}
|
|
12245
12313
|
}
|
|
12246
|
-
|
|
12314
|
+
handleResolveId(resolvedId, source, importer) {
|
|
12247
12315
|
if (resolvedId === null) {
|
|
12248
12316
|
if (index.isRelative(source)) {
|
|
12249
|
-
error(errUnresolvedImport(source, importer));
|
|
12317
|
+
return error(errUnresolvedImport(source, importer));
|
|
12250
12318
|
}
|
|
12251
12319
|
this.graph.warn(errUnresolvedImportTreatedAsExternal(source, importer));
|
|
12252
12320
|
return {
|
|
12253
12321
|
external: true,
|
|
12254
12322
|
id: source,
|
|
12255
|
-
moduleSideEffects: this.hasModuleSideEffects(source, true)
|
|
12323
|
+
moduleSideEffects: this.hasModuleSideEffects(source, true),
|
|
12324
|
+
syntheticNamedExports: false
|
|
12256
12325
|
};
|
|
12257
12326
|
}
|
|
12327
|
+
else {
|
|
12328
|
+
if (resolvedId.external && resolvedId.syntheticNamedExports) {
|
|
12329
|
+
this.graph.warn(errExternalSyntheticExports(source, importer));
|
|
12330
|
+
}
|
|
12331
|
+
}
|
|
12258
12332
|
return resolvedId;
|
|
12259
12333
|
}
|
|
12260
12334
|
normalizeResolveIdResult(resolveIdResult, importer, source) {
|
|
12261
12335
|
let id = '';
|
|
12262
12336
|
let external = false;
|
|
12263
12337
|
let moduleSideEffects = null;
|
|
12338
|
+
let syntheticNamedExports = false;
|
|
12264
12339
|
if (resolveIdResult) {
|
|
12265
12340
|
if (typeof resolveIdResult === 'object') {
|
|
12266
12341
|
id = resolveIdResult.id;
|
|
@@ -12270,6 +12345,9 @@ class ModuleLoader {
|
|
|
12270
12345
|
if (typeof resolveIdResult.moduleSideEffects === 'boolean') {
|
|
12271
12346
|
moduleSideEffects = resolveIdResult.moduleSideEffects;
|
|
12272
12347
|
}
|
|
12348
|
+
if (typeof resolveIdResult.syntheticNamedExports === 'boolean') {
|
|
12349
|
+
syntheticNamedExports = resolveIdResult.syntheticNamedExports;
|
|
12350
|
+
}
|
|
12273
12351
|
}
|
|
12274
12352
|
else {
|
|
12275
12353
|
if (this.isExternal(resolveIdResult, importer, true)) {
|
|
@@ -12290,11 +12368,12 @@ class ModuleLoader {
|
|
|
12290
12368
|
id,
|
|
12291
12369
|
moduleSideEffects: typeof moduleSideEffects === 'boolean'
|
|
12292
12370
|
? moduleSideEffects
|
|
12293
|
-
: this.hasModuleSideEffects(id, external)
|
|
12371
|
+
: this.hasModuleSideEffects(id, external),
|
|
12372
|
+
syntheticNamedExports
|
|
12294
12373
|
};
|
|
12295
12374
|
}
|
|
12296
12375
|
resolveDynamicImport(module, specifier, importer) {
|
|
12297
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
12376
|
+
return index.__awaiter(this, void 0, void 0, function* () {
|
|
12298
12377
|
// TODO we only should expose the acorn AST here
|
|
12299
12378
|
const resolution = yield this.pluginDriver.hookFirst('resolveDynamicImport', [
|
|
12300
12379
|
specifier,
|
|
@@ -12312,9 +12391,9 @@ class ModuleLoader {
|
|
|
12312
12391
|
if (resolution == null) {
|
|
12313
12392
|
return (module.resolvedIds[specifier] =
|
|
12314
12393
|
module.resolvedIds[specifier] ||
|
|
12315
|
-
this.
|
|
12394
|
+
this.handleResolveId(yield this.resolveId(specifier, module.id), specifier, module.id));
|
|
12316
12395
|
}
|
|
12317
|
-
return this.
|
|
12396
|
+
return this.handleResolveId(this.normalizeResolveIdResult(resolution, importer, specifier), specifier, importer);
|
|
12318
12397
|
});
|
|
12319
12398
|
}
|
|
12320
12399
|
}
|
|
@@ -12476,7 +12555,7 @@ class FileEmitter {
|
|
|
12476
12555
|
this.assertAssetsFinalized = () => {
|
|
12477
12556
|
for (const [referenceId, emittedFile] of this.filesByReferenceId.entries()) {
|
|
12478
12557
|
if (emittedFile.type === 'asset' && typeof emittedFile.fileName !== 'string')
|
|
12479
|
-
error(errNoAssetSourceSet(emittedFile.name || referenceId));
|
|
12558
|
+
return error(errNoAssetSourceSet(emittedFile.name || referenceId));
|
|
12480
12559
|
}
|
|
12481
12560
|
};
|
|
12482
12561
|
this.emitFile = (emittedFile) => {
|
|
@@ -12583,7 +12662,7 @@ class FileEmitter {
|
|
|
12583
12662
|
}
|
|
12584
12663
|
emitChunk(emittedChunk) {
|
|
12585
12664
|
if (this.graph.phase > BuildPhase.LOAD_AND_PARSE) {
|
|
12586
|
-
error(errInvalidRollupPhaseForChunkEmission());
|
|
12665
|
+
return error(errInvalidRollupPhaseForChunkEmission());
|
|
12587
12666
|
}
|
|
12588
12667
|
if (typeof emittedChunk.id !== 'string') {
|
|
12589
12668
|
return error(errFailedValidation(`Emitted chunks need to have a valid string id, received "${emittedChunk.id}"`));
|
|
@@ -12682,8 +12761,9 @@ function getPluginContexts(pluginCache, graph, fileEmitter, watcher) {
|
|
|
12682
12761
|
}
|
|
12683
12762
|
const context = {
|
|
12684
12763
|
addWatchFile(id) {
|
|
12685
|
-
if (graph.phase >= BuildPhase.GENERATE)
|
|
12686
|
-
this.error(errInvalidRollupPhaseForAddWatchFile());
|
|
12764
|
+
if (graph.phase >= BuildPhase.GENERATE) {
|
|
12765
|
+
return this.error(errInvalidRollupPhaseForAddWatchFile());
|
|
12766
|
+
}
|
|
12687
12767
|
graph.watchFiles[id] = true;
|
|
12688
12768
|
},
|
|
12689
12769
|
cache: cacheInstance,
|
|
@@ -12863,7 +12943,7 @@ class PluginDriver {
|
|
|
12863
12943
|
}
|
|
12864
12944
|
// chains, ignores returns
|
|
12865
12945
|
hookSeq(hookName, args, replaceContext) {
|
|
12866
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
12946
|
+
return index.__awaiter(this, void 0, void 0, function* () {
|
|
12867
12947
|
let promise = Promise.resolve();
|
|
12868
12948
|
for (let i = 0; i < this.plugins.length; i++)
|
|
12869
12949
|
promise = promise.then(() => this.runHook(hookName, args, i, false, replaceContext));
|
|
@@ -12891,7 +12971,7 @@ class PluginDriver {
|
|
|
12891
12971
|
if (typeof hook !== 'function') {
|
|
12892
12972
|
if (permitValues)
|
|
12893
12973
|
return hook;
|
|
12894
|
-
error({
|
|
12974
|
+
return error({
|
|
12895
12975
|
code: 'INVALID_PLUGIN_HOOK',
|
|
12896
12976
|
message: `Error running plugin hook ${hookName} for ${plugin.name}, expected a function hook.`
|
|
12897
12977
|
});
|
|
@@ -12913,7 +12993,7 @@ class PluginDriver {
|
|
|
12913
12993
|
try {
|
|
12914
12994
|
// permit values allows values to be returned instead of a functional hook
|
|
12915
12995
|
if (typeof hook !== 'function') {
|
|
12916
|
-
error({
|
|
12996
|
+
return error({
|
|
12917
12997
|
code: 'INVALID_PLUGIN_HOOK',
|
|
12918
12998
|
message: `Error running plugin hook ${hookName} for ${plugin.name}, expected a function hook.`
|
|
12919
12999
|
});
|
|
@@ -12978,22 +13058,23 @@ class Graph {
|
|
|
12978
13058
|
this.strictDeprecations = options.strictDeprecations;
|
|
12979
13059
|
this.cacheExpiry = options.experimentalCacheExpiry;
|
|
12980
13060
|
if (options.treeshake !== false) {
|
|
12981
|
-
this.treeshakingOptions =
|
|
12982
|
-
|
|
12983
|
-
|
|
12984
|
-
|
|
12985
|
-
|
|
12986
|
-
|
|
12987
|
-
|
|
12988
|
-
|
|
12989
|
-
|
|
12990
|
-
|
|
12991
|
-
|
|
12992
|
-
|
|
12993
|
-
|
|
12994
|
-
|
|
12995
|
-
|
|
12996
|
-
|
|
13061
|
+
this.treeshakingOptions =
|
|
13062
|
+
options.treeshake && options.treeshake !== true
|
|
13063
|
+
? {
|
|
13064
|
+
annotations: options.treeshake.annotations !== false,
|
|
13065
|
+
moduleSideEffects: options.treeshake.moduleSideEffects,
|
|
13066
|
+
propertyReadSideEffects: options.treeshake.propertyReadSideEffects !== false,
|
|
13067
|
+
pureExternalModules: options.treeshake.pureExternalModules,
|
|
13068
|
+
tryCatchDeoptimization: options.treeshake.tryCatchDeoptimization !== false,
|
|
13069
|
+
unknownGlobalSideEffects: options.treeshake.unknownGlobalSideEffects !== false
|
|
13070
|
+
}
|
|
13071
|
+
: {
|
|
13072
|
+
annotations: true,
|
|
13073
|
+
moduleSideEffects: true,
|
|
13074
|
+
propertyReadSideEffects: true,
|
|
13075
|
+
tryCatchDeoptimization: true,
|
|
13076
|
+
unknownGlobalSideEffects: true
|
|
13077
|
+
};
|
|
12997
13078
|
if (typeof this.treeshakingOptions.pureExternalModules !== 'undefined') {
|
|
12998
13079
|
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);
|
|
12999
13080
|
}
|
|
@@ -13027,9 +13108,7 @@ class Graph {
|
|
|
13027
13108
|
this.acornOptions = options.acorn ? Object.assign({}, options.acorn) : {};
|
|
13028
13109
|
const acornPluginsToInject = [];
|
|
13029
13110
|
acornPluginsToInject.push(acornImportMeta, acornExportNsFrom);
|
|
13030
|
-
|
|
13031
|
-
this.acornOptions.allowAwaitOutsideFunction = true;
|
|
13032
|
-
}
|
|
13111
|
+
this.acornOptions.allowAwaitOutsideFunction = true;
|
|
13033
13112
|
const acornInjectPlugins = options.acornInjectPlugins;
|
|
13034
13113
|
acornPluginsToInject.push(...(Array.isArray(acornInjectPlugins)
|
|
13035
13114
|
? acornInjectPlugins
|
|
@@ -13037,11 +13116,7 @@ class Graph {
|
|
|
13037
13116
|
? [acornInjectPlugins]
|
|
13038
13117
|
: []));
|
|
13039
13118
|
this.acornParser = acorn.Parser.extend(...acornPluginsToInject);
|
|
13040
|
-
this.moduleLoader = new ModuleLoader(this, this.moduleById, this.pluginDriver, options.external, (typeof options.manualChunks === 'function' && options.manualChunks), (this.treeshakingOptions
|
|
13041
|
-
? this.treeshakingOptions.moduleSideEffects
|
|
13042
|
-
: null), (this.treeshakingOptions
|
|
13043
|
-
? this.treeshakingOptions.pureExternalModules
|
|
13044
|
-
: false));
|
|
13119
|
+
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));
|
|
13045
13120
|
}
|
|
13046
13121
|
build(entryModules, manualChunks, inlineDynamicImports) {
|
|
13047
13122
|
// Phase 1 – discovery. We load the entry module and find which
|
|
@@ -13266,7 +13341,7 @@ function createAddons(options, outputPluginDriver) {
|
|
|
13266
13341
|
return { intro, outro, banner, footer };
|
|
13267
13342
|
})
|
|
13268
13343
|
.catch((err) => {
|
|
13269
|
-
error({
|
|
13344
|
+
return error({
|
|
13270
13345
|
code: 'ADDON_ERROR',
|
|
13271
13346
|
message: `Could not retrieve ${err.hook}. Check configuration of plugin ${err.plugin}.
|
|
13272
13347
|
\tError Message: ${err.message}`
|
|
@@ -13320,11 +13395,11 @@ function getExportMode(chunk, { exports: exportMode, name, format }, facadeModul
|
|
|
13320
13395
|
const exportKeys = chunk.getExportNames();
|
|
13321
13396
|
if (exportMode === 'default') {
|
|
13322
13397
|
if (exportKeys.length !== 1 || exportKeys[0] !== 'default') {
|
|
13323
|
-
error(errIncompatibleExportOptionValue('default', exportKeys, facadeModuleId));
|
|
13398
|
+
return error(errIncompatibleExportOptionValue('default', exportKeys, facadeModuleId));
|
|
13324
13399
|
}
|
|
13325
13400
|
}
|
|
13326
13401
|
else if (exportMode === 'none' && exportKeys.length) {
|
|
13327
|
-
error(errIncompatibleExportOptionValue('none', exportKeys, facadeModuleId));
|
|
13402
|
+
return error(errIncompatibleExportOptionValue('none', exportKeys, facadeModuleId));
|
|
13328
13403
|
}
|
|
13329
13404
|
if (!exportMode || exportMode === 'auto') {
|
|
13330
13405
|
if (exportKeys.length === 0) {
|
|
@@ -13345,19 +13420,19 @@ function getExportMode(chunk, { exports: exportMode, name, format }, facadeModul
|
|
|
13345
13420
|
|
|
13346
13421
|
function checkOutputOptions(options) {
|
|
13347
13422
|
if (options.format === 'es6') {
|
|
13348
|
-
error(errDeprecation({
|
|
13423
|
+
return error(errDeprecation({
|
|
13349
13424
|
message: 'The "es6" output format is deprecated – use "esm" instead',
|
|
13350
13425
|
url: `https://rollupjs.org/guide/en/#output-format`
|
|
13351
13426
|
}));
|
|
13352
13427
|
}
|
|
13353
13428
|
if (['amd', 'cjs', 'system', 'es', 'iife', 'umd'].indexOf(options.format) < 0) {
|
|
13354
|
-
error({
|
|
13429
|
+
return error({
|
|
13355
13430
|
message: `You must specify "output.format", which can be one of "amd", "cjs", "system", "esm", "iife" or "umd".`,
|
|
13356
13431
|
url: `https://rollupjs.org/guide/en/#output-format`
|
|
13357
13432
|
});
|
|
13358
13433
|
}
|
|
13359
13434
|
if (options.exports && !['default', 'named', 'none', 'auto'].includes(options.exports)) {
|
|
13360
|
-
error(errInvalidExportOptionValue(options.exports));
|
|
13435
|
+
return error(errInvalidExportOptionValue(options.exports));
|
|
13361
13436
|
}
|
|
13362
13437
|
}
|
|
13363
13438
|
function getAbsoluteEntryModulePaths(chunks) {
|
|
@@ -13381,17 +13456,8 @@ function applyOptionHook(inputOptions, plugin) {
|
|
|
13381
13456
|
return plugin.options.call({ meta: { rollupVersion: index.version } }, inputOptions) || inputOptions;
|
|
13382
13457
|
return inputOptions;
|
|
13383
13458
|
}
|
|
13384
|
-
function ensureArray(items) {
|
|
13385
|
-
if (Array.isArray(items)) {
|
|
13386
|
-
return items.filter(Boolean);
|
|
13387
|
-
}
|
|
13388
|
-
if (items) {
|
|
13389
|
-
return [items];
|
|
13390
|
-
}
|
|
13391
|
-
return [];
|
|
13392
|
-
}
|
|
13393
13459
|
function normalizePlugins(rawPlugins, anonymousPrefix) {
|
|
13394
|
-
const plugins = ensureArray(rawPlugins);
|
|
13460
|
+
const plugins = index.ensureArray(rawPlugins);
|
|
13395
13461
|
for (let pluginIndex = 0; pluginIndex < plugins.length; pluginIndex++) {
|
|
13396
13462
|
const plugin = plugins[pluginIndex];
|
|
13397
13463
|
if (!plugin.name) {
|
|
@@ -13409,39 +13475,39 @@ function getInputOptions(rawInputOptions) {
|
|
|
13409
13475
|
});
|
|
13410
13476
|
if (optionError)
|
|
13411
13477
|
inputOptions.onwarn({ message: optionError, code: 'UNKNOWN_OPTION' });
|
|
13412
|
-
inputOptions =
|
|
13478
|
+
inputOptions = inputOptions.plugins.reduce(applyOptionHook, inputOptions);
|
|
13413
13479
|
inputOptions.plugins = normalizePlugins(inputOptions.plugins, ANONYMOUS_PLUGIN_PREFIX);
|
|
13414
13480
|
if (inputOptions.inlineDynamicImports) {
|
|
13415
13481
|
if (inputOptions.preserveModules)
|
|
13416
|
-
error({
|
|
13482
|
+
return error({
|
|
13417
13483
|
code: 'INVALID_OPTION',
|
|
13418
13484
|
message: `"preserveModules" does not support the "inlineDynamicImports" option.`
|
|
13419
13485
|
});
|
|
13420
13486
|
if (inputOptions.manualChunks)
|
|
13421
|
-
error({
|
|
13487
|
+
return error({
|
|
13422
13488
|
code: 'INVALID_OPTION',
|
|
13423
13489
|
message: '"manualChunks" option is not supported for "inlineDynamicImports".'
|
|
13424
13490
|
});
|
|
13425
13491
|
if (inputOptions.experimentalOptimizeChunks)
|
|
13426
|
-
error({
|
|
13492
|
+
return error({
|
|
13427
13493
|
code: 'INVALID_OPTION',
|
|
13428
13494
|
message: '"experimentalOptimizeChunks" option is not supported for "inlineDynamicImports".'
|
|
13429
13495
|
});
|
|
13430
13496
|
if ((inputOptions.input instanceof Array && inputOptions.input.length > 1) ||
|
|
13431
13497
|
(typeof inputOptions.input === 'object' && Object.keys(inputOptions.input).length > 1))
|
|
13432
|
-
error({
|
|
13498
|
+
return error({
|
|
13433
13499
|
code: 'INVALID_OPTION',
|
|
13434
13500
|
message: 'Multiple inputs are not supported for "inlineDynamicImports".'
|
|
13435
13501
|
});
|
|
13436
13502
|
}
|
|
13437
13503
|
else if (inputOptions.preserveModules) {
|
|
13438
13504
|
if (inputOptions.manualChunks)
|
|
13439
|
-
error({
|
|
13505
|
+
return error({
|
|
13440
13506
|
code: 'INVALID_OPTION',
|
|
13441
13507
|
message: '"preserveModules" does not support the "manualChunks" option.'
|
|
13442
13508
|
});
|
|
13443
13509
|
if (inputOptions.experimentalOptimizeChunks)
|
|
13444
|
-
error({
|
|
13510
|
+
return error({
|
|
13445
13511
|
code: 'INVALID_OPTION',
|
|
13446
13512
|
message: '"preserveModules" does not support the "experimentalOptimizeChunks" option.'
|
|
13447
13513
|
});
|
|
@@ -13476,7 +13542,7 @@ function assignChunksToBundle(chunks, outputBundle) {
|
|
|
13476
13542
|
return outputBundle;
|
|
13477
13543
|
}
|
|
13478
13544
|
function rollup(rawInputOptions) {
|
|
13479
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
13545
|
+
return index.__awaiter(this, void 0, void 0, function* () {
|
|
13480
13546
|
const inputOptions = getInputOptions(rawInputOptions);
|
|
13481
13547
|
initialiseTimers(inputOptions);
|
|
13482
13548
|
const graph = new Graph(inputOptions, curWatcher);
|
|
@@ -13514,7 +13580,7 @@ function rollup(rawInputOptions) {
|
|
|
13514
13580
|
};
|
|
13515
13581
|
}
|
|
13516
13582
|
function generate(outputOptions, isWrite, outputPluginDriver) {
|
|
13517
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
13583
|
+
return index.__awaiter(this, void 0, void 0, function* () {
|
|
13518
13584
|
timeStart('GENERATE', 1);
|
|
13519
13585
|
const assetFileNames = outputOptions.assetFileNames || 'assets/[name]-[hash][extname]';
|
|
13520
13586
|
const inputBase = commondir(getAbsoluteEntryModulePaths(chunks));
|
|
@@ -13584,12 +13650,12 @@ function rollup(rawInputOptions) {
|
|
|
13584
13650
|
write: ((rawOutputOptions) => {
|
|
13585
13651
|
const { outputOptions, outputPluginDriver } = getOutputOptionsAndPluginDriver(rawOutputOptions);
|
|
13586
13652
|
if (!outputOptions.dir && !outputOptions.file) {
|
|
13587
|
-
error({
|
|
13653
|
+
return error({
|
|
13588
13654
|
code: 'MISSING_OPTION',
|
|
13589
13655
|
message: 'You must specify "output.file" or "output.dir" for the build.'
|
|
13590
13656
|
});
|
|
13591
13657
|
}
|
|
13592
|
-
return generate(outputOptions, true, outputPluginDriver).then((bundle) => __awaiter(this, void 0, void 0, function* () {
|
|
13658
|
+
return generate(outputOptions, true, outputPluginDriver).then((bundle) => index.__awaiter(this, void 0, void 0, function* () {
|
|
13593
13659
|
let chunkCount = 0;
|
|
13594
13660
|
for (const fileName of Object.keys(bundle)) {
|
|
13595
13661
|
const file = bundle[fileName];
|
|
@@ -13601,12 +13667,12 @@ function rollup(rawInputOptions) {
|
|
|
13601
13667
|
}
|
|
13602
13668
|
if (chunkCount > 1) {
|
|
13603
13669
|
if (outputOptions.sourcemapFile)
|
|
13604
|
-
error({
|
|
13670
|
+
return error({
|
|
13605
13671
|
code: 'INVALID_OPTION',
|
|
13606
13672
|
message: '"output.sourcemapFile" is only supported for single-file builds.'
|
|
13607
13673
|
});
|
|
13608
13674
|
if (typeof outputOptions.file === 'string')
|
|
13609
|
-
error({
|
|
13675
|
+
return error({
|
|
13610
13676
|
code: 'INVALID_OPTION',
|
|
13611
13677
|
message: 'When building multiple chunks, the "output.dir" option must be used, not "output.file".' +
|
|
13612
13678
|
(typeof inputOptions.input !== 'string' ||
|
|
@@ -13704,30 +13770,30 @@ function normalizeOutputOptions(inputOptions, rawOutputOptions, hasMultipleChunk
|
|
|
13704
13770
|
checkOutputOptions(outputOptions);
|
|
13705
13771
|
if (typeof outputOptions.file === 'string') {
|
|
13706
13772
|
if (typeof outputOptions.dir === 'string')
|
|
13707
|
-
error({
|
|
13773
|
+
return error({
|
|
13708
13774
|
code: 'INVALID_OPTION',
|
|
13709
13775
|
message: 'You must set either "output.file" for a single-file build or "output.dir" when generating multiple chunks.'
|
|
13710
13776
|
});
|
|
13711
13777
|
if (inputOptions.preserveModules) {
|
|
13712
|
-
error({
|
|
13778
|
+
return error({
|
|
13713
13779
|
code: 'INVALID_OPTION',
|
|
13714
13780
|
message: 'You must set "output.dir" instead of "output.file" when using the "preserveModules" option.'
|
|
13715
13781
|
});
|
|
13716
13782
|
}
|
|
13717
13783
|
if (typeof inputOptions.input === 'object' && !Array.isArray(inputOptions.input))
|
|
13718
|
-
error({
|
|
13784
|
+
return error({
|
|
13719
13785
|
code: 'INVALID_OPTION',
|
|
13720
13786
|
message: 'You must set "output.dir" instead of "output.file" when providing named inputs.'
|
|
13721
13787
|
});
|
|
13722
13788
|
}
|
|
13723
13789
|
if (hasMultipleChunks) {
|
|
13724
13790
|
if (outputOptions.format === 'umd' || outputOptions.format === 'iife')
|
|
13725
|
-
error({
|
|
13791
|
+
return error({
|
|
13726
13792
|
code: 'INVALID_OPTION',
|
|
13727
13793
|
message: 'UMD and IIFE output formats are not supported for code-splitting builds.'
|
|
13728
13794
|
});
|
|
13729
13795
|
if (typeof outputOptions.file === 'string')
|
|
13730
|
-
error({
|
|
13796
|
+
return error({
|
|
13731
13797
|
code: 'INVALID_OPTION',
|
|
13732
13798
|
message: 'You must set "output.dir" instead of "output.file" when generating multiple chunks.'
|
|
13733
13799
|
});
|
|
@@ -16711,7 +16777,7 @@ micromatch.braceExpand = (pattern, options) => {
|
|
|
16711
16777
|
*/
|
|
16712
16778
|
var micromatch_1 = micromatch;
|
|
16713
16779
|
|
|
16714
|
-
function ensureArray
|
|
16780
|
+
function ensureArray(thing) {
|
|
16715
16781
|
if (Array.isArray(thing))
|
|
16716
16782
|
return thing;
|
|
16717
16783
|
if (thing == undefined)
|
|
@@ -16736,8 +16802,8 @@ const createFilter = function createFilter(include, exclude, options) {
|
|
|
16736
16802
|
.join('/'), { dot: true })
|
|
16737
16803
|
};
|
|
16738
16804
|
};
|
|
16739
|
-
const includeMatchers = ensureArray
|
|
16740
|
-
const excludeMatchers = ensureArray
|
|
16805
|
+
const includeMatchers = ensureArray(include).map(getMatcher);
|
|
16806
|
+
const excludeMatchers = ensureArray(exclude).map(getMatcher);
|
|
16741
16807
|
return function (id) {
|
|
16742
16808
|
if (typeof id !== 'string')
|
|
16743
16809
|
return false;
|