rollup 3.20.3 → 3.20.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/rollup +2 -2
- package/dist/es/rollup.js +2 -2
- package/dist/es/shared/node-entry.js +102 -104
- package/dist/es/shared/watch.js +2 -2
- package/dist/loadConfigFile.js +2 -2
- package/dist/rollup.js +2 -2
- package/dist/shared/fsevents-importer.js +2 -2
- package/dist/shared/index.js +2 -2
- package/dist/shared/loadConfigFile.js +2 -2
- package/dist/shared/rollup.js +102 -104
- package/dist/shared/watch-cli.js +2 -2
- package/dist/shared/watch-proxy.js +2 -2
- package/dist/shared/watch.js +2 -2
- package/package.json +1 -1
package/dist/bin/rollup
CHANGED
package/dist/es/rollup.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
2
|
@license
|
|
3
|
-
Rollup.js v3.20.
|
|
4
|
-
|
|
3
|
+
Rollup.js v3.20.5
|
|
4
|
+
Tue, 18 Apr 2023 05:00:18 GMT - commit 8411bd07421c8b02b53722fb943cb96700a6e058
|
|
5
5
|
|
|
6
6
|
https://github.com/rollup/rollup
|
|
7
7
|
|
|
@@ -16,7 +16,7 @@ import { lstat, realpath, readdir, readFile, mkdir, writeFile } from 'node:fs/pr
|
|
|
16
16
|
import { EventEmitter } from 'node:events';
|
|
17
17
|
import * as tty from 'tty';
|
|
18
18
|
|
|
19
|
-
var version$1 = "3.20.
|
|
19
|
+
var version$1 = "3.20.5";
|
|
20
20
|
|
|
21
21
|
const comma = ','.charCodeAt(0);
|
|
22
22
|
const semicolon = ';'.charCodeAt(0);
|
|
@@ -5039,12 +5039,11 @@ const builtins = 'arguments Infinity NaN undefined null true false eval uneval i
|
|
|
5039
5039
|
const forbiddenIdentifiers = new Set(`${reservedWords$1} ${builtins}`.split(' '));
|
|
5040
5040
|
forbiddenIdentifiers.add('');
|
|
5041
5041
|
|
|
5042
|
-
const BROKEN_FLOW_NONE = 0;
|
|
5043
|
-
const BROKEN_FLOW_BREAK_CONTINUE = 1;
|
|
5044
|
-
const BROKEN_FLOW_ERROR_RETURN_LABEL = 2;
|
|
5045
5042
|
function createInclusionContext() {
|
|
5046
5043
|
return {
|
|
5047
|
-
brokenFlow:
|
|
5044
|
+
brokenFlow: false,
|
|
5045
|
+
hasBreak: false,
|
|
5046
|
+
hasContinue: false,
|
|
5048
5047
|
includedCallArguments: new Set(),
|
|
5049
5048
|
includedLabels: new Set()
|
|
5050
5049
|
};
|
|
@@ -5053,8 +5052,10 @@ function createHasEffectsContext() {
|
|
|
5053
5052
|
return {
|
|
5054
5053
|
accessed: new PathTracker(),
|
|
5055
5054
|
assigned: new PathTracker(),
|
|
5056
|
-
brokenFlow:
|
|
5055
|
+
brokenFlow: false,
|
|
5057
5056
|
called: new DiscriminatedPathTracker(),
|
|
5057
|
+
hasBreak: false,
|
|
5058
|
+
hasContinue: false,
|
|
5058
5059
|
ignore: {
|
|
5059
5060
|
breaks: false,
|
|
5060
5061
|
continues: false,
|
|
@@ -6859,11 +6860,17 @@ function toBase64(value) {
|
|
|
6859
6860
|
return outString;
|
|
6860
6861
|
}
|
|
6861
6862
|
|
|
6863
|
+
const validIdentifier = /^(?!\d)[\w$]+$/;
|
|
6864
|
+
function isValidIdentifier(name) {
|
|
6865
|
+
return validIdentifier.test(name);
|
|
6866
|
+
}
|
|
6867
|
+
|
|
6862
6868
|
function getSafeName(baseName, usedNames, forbiddenNames) {
|
|
6863
|
-
|
|
6869
|
+
const safeBase = isValidIdentifier(baseName) ? baseName : '_safe';
|
|
6870
|
+
let safeName = safeBase;
|
|
6864
6871
|
let count = 1;
|
|
6865
6872
|
while (usedNames.has(safeName) || RESERVED_NAMES$1.has(safeName) || forbiddenNames?.has(safeName)) {
|
|
6866
|
-
safeName = `${
|
|
6873
|
+
safeName = `${safeBase}$${toBase64(count++)}`;
|
|
6867
6874
|
}
|
|
6868
6875
|
usedNames.add(safeName);
|
|
6869
6876
|
return safeName;
|
|
@@ -8672,7 +8679,7 @@ class FunctionBase extends NodeBase {
|
|
|
8672
8679
|
this.applyDeoptimizations();
|
|
8673
8680
|
this.included = true;
|
|
8674
8681
|
const { brokenFlow } = context;
|
|
8675
|
-
context.brokenFlow =
|
|
8682
|
+
context.brokenFlow = false;
|
|
8676
8683
|
this.body.include(context, includeChildrenRecursively);
|
|
8677
8684
|
context.brokenFlow = brokenFlow;
|
|
8678
8685
|
}
|
|
@@ -9150,13 +9157,13 @@ class BreakStatement extends NodeBase {
|
|
|
9150
9157
|
if (!context.ignore.labels.has(this.label.name))
|
|
9151
9158
|
return true;
|
|
9152
9159
|
context.includedLabels.add(this.label.name);
|
|
9153
|
-
context.brokenFlow = BROKEN_FLOW_ERROR_RETURN_LABEL;
|
|
9154
9160
|
}
|
|
9155
9161
|
else {
|
|
9156
9162
|
if (!context.ignore.breaks)
|
|
9157
9163
|
return true;
|
|
9158
|
-
context.
|
|
9164
|
+
context.hasBreak = true;
|
|
9159
9165
|
}
|
|
9166
|
+
context.brokenFlow = true;
|
|
9160
9167
|
return false;
|
|
9161
9168
|
}
|
|
9162
9169
|
include(context) {
|
|
@@ -9165,7 +9172,10 @@ class BreakStatement extends NodeBase {
|
|
|
9165
9172
|
this.label.include();
|
|
9166
9173
|
context.includedLabels.add(this.label.name);
|
|
9167
9174
|
}
|
|
9168
|
-
|
|
9175
|
+
else {
|
|
9176
|
+
context.hasBreak = true;
|
|
9177
|
+
}
|
|
9178
|
+
context.brokenFlow = true;
|
|
9169
9179
|
}
|
|
9170
9180
|
}
|
|
9171
9181
|
|
|
@@ -10238,13 +10248,13 @@ class ContinueStatement extends NodeBase {
|
|
|
10238
10248
|
if (!context.ignore.labels.has(this.label.name))
|
|
10239
10249
|
return true;
|
|
10240
10250
|
context.includedLabels.add(this.label.name);
|
|
10241
|
-
context.brokenFlow = BROKEN_FLOW_ERROR_RETURN_LABEL;
|
|
10242
10251
|
}
|
|
10243
10252
|
else {
|
|
10244
10253
|
if (!context.ignore.continues)
|
|
10245
10254
|
return true;
|
|
10246
|
-
context.
|
|
10255
|
+
context.hasContinue = true;
|
|
10247
10256
|
}
|
|
10257
|
+
context.brokenFlow = true;
|
|
10248
10258
|
return false;
|
|
10249
10259
|
}
|
|
10250
10260
|
include(context) {
|
|
@@ -10253,31 +10263,49 @@ class ContinueStatement extends NodeBase {
|
|
|
10253
10263
|
this.label.include();
|
|
10254
10264
|
context.includedLabels.add(this.label.name);
|
|
10255
10265
|
}
|
|
10256
|
-
|
|
10266
|
+
else {
|
|
10267
|
+
context.hasContinue = true;
|
|
10268
|
+
}
|
|
10269
|
+
context.brokenFlow = true;
|
|
10257
10270
|
}
|
|
10258
10271
|
}
|
|
10259
10272
|
|
|
10273
|
+
function hasLoopBodyEffects(context, body) {
|
|
10274
|
+
const { brokenFlow, hasBreak, hasContinue, ignore } = context;
|
|
10275
|
+
const { breaks, continues } = ignore;
|
|
10276
|
+
ignore.breaks = true;
|
|
10277
|
+
ignore.continues = true;
|
|
10278
|
+
context.hasBreak = false;
|
|
10279
|
+
context.hasContinue = false;
|
|
10280
|
+
if (body.hasEffects(context))
|
|
10281
|
+
return true;
|
|
10282
|
+
ignore.breaks = breaks;
|
|
10283
|
+
ignore.continues = continues;
|
|
10284
|
+
context.hasBreak = hasBreak;
|
|
10285
|
+
context.hasContinue = hasContinue;
|
|
10286
|
+
context.brokenFlow = brokenFlow;
|
|
10287
|
+
return false;
|
|
10288
|
+
}
|
|
10289
|
+
function includeLoopBody(context, body, includeChildrenRecursively) {
|
|
10290
|
+
const { brokenFlow, hasBreak, hasContinue } = context;
|
|
10291
|
+
context.hasBreak = false;
|
|
10292
|
+
context.hasContinue = false;
|
|
10293
|
+
body.include(context, includeChildrenRecursively, { asSingleStatement: true });
|
|
10294
|
+
context.hasBreak = hasBreak;
|
|
10295
|
+
context.hasContinue = hasContinue;
|
|
10296
|
+
context.brokenFlow = brokenFlow;
|
|
10297
|
+
}
|
|
10298
|
+
|
|
10260
10299
|
class DoWhileStatement extends NodeBase {
|
|
10261
10300
|
hasEffects(context) {
|
|
10262
10301
|
if (this.test.hasEffects(context))
|
|
10263
10302
|
return true;
|
|
10264
|
-
|
|
10265
|
-
const { breaks, continues } = ignore;
|
|
10266
|
-
ignore.breaks = true;
|
|
10267
|
-
ignore.continues = true;
|
|
10268
|
-
if (this.body.hasEffects(context))
|
|
10269
|
-
return true;
|
|
10270
|
-
ignore.breaks = breaks;
|
|
10271
|
-
ignore.continues = continues;
|
|
10272
|
-
context.brokenFlow = brokenFlow;
|
|
10273
|
-
return false;
|
|
10303
|
+
return hasLoopBodyEffects(context, this.body);
|
|
10274
10304
|
}
|
|
10275
10305
|
include(context, includeChildrenRecursively) {
|
|
10276
10306
|
this.included = true;
|
|
10277
10307
|
this.test.include(context, includeChildrenRecursively);
|
|
10278
|
-
|
|
10279
|
-
this.body.include(context, includeChildrenRecursively, { asSingleStatement: true });
|
|
10280
|
-
context.brokenFlow = brokenFlow;
|
|
10308
|
+
includeLoopBody(context, this.body, includeChildrenRecursively);
|
|
10281
10309
|
}
|
|
10282
10310
|
}
|
|
10283
10311
|
|
|
@@ -10443,16 +10471,7 @@ class ForInStatement extends NodeBase {
|
|
|
10443
10471
|
this.applyDeoptimizations();
|
|
10444
10472
|
if (left.hasEffectsAsAssignmentTarget(context, false) || right.hasEffects(context))
|
|
10445
10473
|
return true;
|
|
10446
|
-
|
|
10447
|
-
const { breaks, continues } = ignore;
|
|
10448
|
-
ignore.breaks = true;
|
|
10449
|
-
ignore.continues = true;
|
|
10450
|
-
if (body.hasEffects(context))
|
|
10451
|
-
return true;
|
|
10452
|
-
ignore.breaks = breaks;
|
|
10453
|
-
ignore.continues = continues;
|
|
10454
|
-
context.brokenFlow = brokenFlow;
|
|
10455
|
-
return false;
|
|
10474
|
+
return hasLoopBodyEffects(context, body);
|
|
10456
10475
|
}
|
|
10457
10476
|
include(context, includeChildrenRecursively) {
|
|
10458
10477
|
const { body, deoptimized, left, right } = this;
|
|
@@ -10461,9 +10480,7 @@ class ForInStatement extends NodeBase {
|
|
|
10461
10480
|
this.included = true;
|
|
10462
10481
|
left.includeAsAssignmentTarget(context, includeChildrenRecursively || true, false);
|
|
10463
10482
|
right.include(context, includeChildrenRecursively);
|
|
10464
|
-
|
|
10465
|
-
body.include(context, includeChildrenRecursively, { asSingleStatement: true });
|
|
10466
|
-
context.brokenFlow = brokenFlow;
|
|
10483
|
+
includeLoopBody(context, body, includeChildrenRecursively);
|
|
10467
10484
|
}
|
|
10468
10485
|
initialise() {
|
|
10469
10486
|
this.left.setAssignedValue(UNKNOWN_EXPRESSION);
|
|
@@ -10501,9 +10518,7 @@ class ForOfStatement extends NodeBase {
|
|
|
10501
10518
|
this.included = true;
|
|
10502
10519
|
left.includeAsAssignmentTarget(context, includeChildrenRecursively || true, false);
|
|
10503
10520
|
right.include(context, includeChildrenRecursively);
|
|
10504
|
-
|
|
10505
|
-
body.include(context, includeChildrenRecursively, { asSingleStatement: true });
|
|
10506
|
-
context.brokenFlow = brokenFlow;
|
|
10521
|
+
includeLoopBody(context, body, includeChildrenRecursively);
|
|
10507
10522
|
}
|
|
10508
10523
|
initialise() {
|
|
10509
10524
|
this.left.setAssignedValue(UNKNOWN_EXPRESSION);
|
|
@@ -10531,27 +10546,17 @@ class ForStatement extends NodeBase {
|
|
|
10531
10546
|
hasEffects(context) {
|
|
10532
10547
|
if (this.init?.hasEffects(context) ||
|
|
10533
10548
|
this.test?.hasEffects(context) ||
|
|
10534
|
-
this.update?.hasEffects(context))
|
|
10549
|
+
this.update?.hasEffects(context)) {
|
|
10535
10550
|
return true;
|
|
10536
|
-
|
|
10537
|
-
|
|
10538
|
-
ignore.breaks = true;
|
|
10539
|
-
ignore.continues = true;
|
|
10540
|
-
if (this.body.hasEffects(context))
|
|
10541
|
-
return true;
|
|
10542
|
-
ignore.breaks = breaks;
|
|
10543
|
-
ignore.continues = continues;
|
|
10544
|
-
context.brokenFlow = brokenFlow;
|
|
10545
|
-
return false;
|
|
10551
|
+
}
|
|
10552
|
+
return hasLoopBodyEffects(context, this.body);
|
|
10546
10553
|
}
|
|
10547
10554
|
include(context, includeChildrenRecursively) {
|
|
10548
10555
|
this.included = true;
|
|
10549
10556
|
this.init?.include(context, includeChildrenRecursively, { asSingleStatement: true });
|
|
10550
10557
|
this.test?.include(context, includeChildrenRecursively);
|
|
10551
|
-
const { brokenFlow } = context;
|
|
10552
10558
|
this.update?.include(context, includeChildrenRecursively);
|
|
10553
|
-
this.body
|
|
10554
|
-
context.brokenFlow = brokenFlow;
|
|
10559
|
+
includeLoopBody(context, this.body, includeChildrenRecursively);
|
|
10555
10560
|
}
|
|
10556
10561
|
render(code, options) {
|
|
10557
10562
|
this.init?.render(code, options, NO_SEMICOLON);
|
|
@@ -10607,9 +10612,8 @@ class IfStatement extends NodeBase {
|
|
|
10607
10612
|
return false;
|
|
10608
10613
|
if (this.alternate.hasEffects(context))
|
|
10609
10614
|
return true;
|
|
10610
|
-
|
|
10611
|
-
|
|
10612
|
-
context.brokenFlow < consequentBrokenFlow ? context.brokenFlow : consequentBrokenFlow;
|
|
10615
|
+
// eslint-disable-next-line unicorn/consistent-destructuring
|
|
10616
|
+
context.brokenFlow = context.brokenFlow && consequentBrokenFlow;
|
|
10613
10617
|
return false;
|
|
10614
10618
|
}
|
|
10615
10619
|
return testValue ? this.consequent.hasEffects(context) : !!this.alternate?.hasEffects(context);
|
|
@@ -10708,7 +10712,7 @@ class IfStatement extends NodeBase {
|
|
|
10708
10712
|
includeUnknownTest(context) {
|
|
10709
10713
|
this.test.include(context, false);
|
|
10710
10714
|
const { brokenFlow } = context;
|
|
10711
|
-
let consequentBrokenFlow =
|
|
10715
|
+
let consequentBrokenFlow = false;
|
|
10712
10716
|
if (this.consequent.shouldBeIncluded(context)) {
|
|
10713
10717
|
this.consequent.include(context, false, { asSingleStatement: true });
|
|
10714
10718
|
// eslint-disable-next-line unicorn/consistent-destructuring
|
|
@@ -10717,9 +10721,8 @@ class IfStatement extends NodeBase {
|
|
|
10717
10721
|
}
|
|
10718
10722
|
if (this.alternate?.shouldBeIncluded(context)) {
|
|
10719
10723
|
this.alternate.include(context, false, { asSingleStatement: true });
|
|
10720
|
-
|
|
10721
|
-
|
|
10722
|
-
context.brokenFlow < consequentBrokenFlow ? context.brokenFlow : consequentBrokenFlow;
|
|
10724
|
+
// eslint-disable-next-line unicorn/consistent-destructuring
|
|
10725
|
+
context.brokenFlow = context.brokenFlow && consequentBrokenFlow;
|
|
10723
10726
|
}
|
|
10724
10727
|
}
|
|
10725
10728
|
renderHoistedDeclarations(hoistedDeclarations, code, getPropertyAccess) {
|
|
@@ -11770,13 +11773,13 @@ class ReturnStatement extends NodeBase {
|
|
|
11770
11773
|
hasEffects(context) {
|
|
11771
11774
|
if (!context.ignore.returnYield || this.argument?.hasEffects(context))
|
|
11772
11775
|
return true;
|
|
11773
|
-
context.brokenFlow =
|
|
11776
|
+
context.brokenFlow = true;
|
|
11774
11777
|
return false;
|
|
11775
11778
|
}
|
|
11776
11779
|
include(context, includeChildrenRecursively) {
|
|
11777
11780
|
this.included = true;
|
|
11778
11781
|
this.argument?.include(context, includeChildrenRecursively);
|
|
11779
|
-
context.brokenFlow =
|
|
11782
|
+
context.brokenFlow = true;
|
|
11780
11783
|
}
|
|
11781
11784
|
initialise() {
|
|
11782
11785
|
this.scope.addReturnExpression(this.argument || UNKNOWN_EXPRESSION);
|
|
@@ -11943,28 +11946,32 @@ class SwitchStatement extends NodeBase {
|
|
|
11943
11946
|
hasEffects(context) {
|
|
11944
11947
|
if (this.discriminant.hasEffects(context))
|
|
11945
11948
|
return true;
|
|
11946
|
-
const { brokenFlow, ignore } = context;
|
|
11949
|
+
const { brokenFlow, hasBreak, ignore } = context;
|
|
11947
11950
|
const { breaks } = ignore;
|
|
11948
|
-
let minBrokenFlow = Infinity;
|
|
11949
11951
|
ignore.breaks = true;
|
|
11952
|
+
context.hasBreak = false;
|
|
11953
|
+
let onlyHasBrokenFlow = true;
|
|
11950
11954
|
for (const switchCase of this.cases) {
|
|
11951
11955
|
if (switchCase.hasEffects(context))
|
|
11952
11956
|
return true;
|
|
11953
11957
|
// eslint-disable-next-line unicorn/consistent-destructuring
|
|
11954
|
-
|
|
11958
|
+
onlyHasBrokenFlow && (onlyHasBrokenFlow = context.brokenFlow && !context.hasBreak);
|
|
11959
|
+
context.hasBreak = false;
|
|
11955
11960
|
context.brokenFlow = brokenFlow;
|
|
11956
11961
|
}
|
|
11957
|
-
if (this.defaultCase !== null
|
|
11958
|
-
context.brokenFlow =
|
|
11962
|
+
if (this.defaultCase !== null) {
|
|
11963
|
+
context.brokenFlow = onlyHasBrokenFlow;
|
|
11959
11964
|
}
|
|
11960
11965
|
ignore.breaks = breaks;
|
|
11966
|
+
context.hasBreak = hasBreak;
|
|
11961
11967
|
return false;
|
|
11962
11968
|
}
|
|
11963
11969
|
include(context, includeChildrenRecursively) {
|
|
11964
11970
|
this.included = true;
|
|
11965
11971
|
this.discriminant.include(context, includeChildrenRecursively);
|
|
11966
|
-
const { brokenFlow } = context;
|
|
11967
|
-
|
|
11972
|
+
const { brokenFlow, hasBreak } = context;
|
|
11973
|
+
context.hasBreak = false;
|
|
11974
|
+
let onlyHasBrokenFlow = true;
|
|
11968
11975
|
let isCaseIncluded = includeChildrenRecursively ||
|
|
11969
11976
|
(this.defaultCase !== null && this.defaultCase < this.cases.length - 1);
|
|
11970
11977
|
for (let caseIndex = this.cases.length - 1; caseIndex >= 0; caseIndex--) {
|
|
@@ -11980,18 +11987,18 @@ class SwitchStatement extends NodeBase {
|
|
|
11980
11987
|
if (isCaseIncluded) {
|
|
11981
11988
|
switchCase.include(context, includeChildrenRecursively);
|
|
11982
11989
|
// eslint-disable-next-line unicorn/consistent-destructuring
|
|
11983
|
-
|
|
11990
|
+
onlyHasBrokenFlow && (onlyHasBrokenFlow = context.brokenFlow && !context.hasBreak);
|
|
11991
|
+
context.hasBreak = false;
|
|
11984
11992
|
context.brokenFlow = brokenFlow;
|
|
11985
11993
|
}
|
|
11986
11994
|
else {
|
|
11987
|
-
|
|
11995
|
+
onlyHasBrokenFlow = brokenFlow;
|
|
11988
11996
|
}
|
|
11989
11997
|
}
|
|
11990
|
-
if (isCaseIncluded &&
|
|
11991
|
-
|
|
11992
|
-
!(minBrokenFlow === BROKEN_FLOW_BREAK_CONTINUE)) {
|
|
11993
|
-
context.brokenFlow = minBrokenFlow;
|
|
11998
|
+
if (isCaseIncluded && this.defaultCase !== null) {
|
|
11999
|
+
context.brokenFlow = onlyHasBrokenFlow;
|
|
11994
12000
|
}
|
|
12001
|
+
context.hasBreak = hasBreak;
|
|
11995
12002
|
}
|
|
11996
12003
|
initialise() {
|
|
11997
12004
|
for (let caseIndex = 0; caseIndex < this.cases.length; caseIndex++) {
|
|
@@ -12284,7 +12291,7 @@ class ThrowStatement extends NodeBase {
|
|
|
12284
12291
|
include(context, includeChildrenRecursively) {
|
|
12285
12292
|
this.included = true;
|
|
12286
12293
|
this.argument.include(context, includeChildrenRecursively);
|
|
12287
|
-
context.brokenFlow =
|
|
12294
|
+
context.brokenFlow = true;
|
|
12288
12295
|
}
|
|
12289
12296
|
render(code, options) {
|
|
12290
12297
|
this.argument.render(code, options, { preventASI: true });
|
|
@@ -12678,23 +12685,12 @@ class WhileStatement extends NodeBase {
|
|
|
12678
12685
|
hasEffects(context) {
|
|
12679
12686
|
if (this.test.hasEffects(context))
|
|
12680
12687
|
return true;
|
|
12681
|
-
|
|
12682
|
-
const { breaks, continues } = ignore;
|
|
12683
|
-
ignore.breaks = true;
|
|
12684
|
-
ignore.continues = true;
|
|
12685
|
-
if (this.body.hasEffects(context))
|
|
12686
|
-
return true;
|
|
12687
|
-
ignore.breaks = breaks;
|
|
12688
|
-
ignore.continues = continues;
|
|
12689
|
-
context.brokenFlow = brokenFlow;
|
|
12690
|
-
return false;
|
|
12688
|
+
return hasLoopBodyEffects(context, this.body);
|
|
12691
12689
|
}
|
|
12692
12690
|
include(context, includeChildrenRecursively) {
|
|
12693
12691
|
this.included = true;
|
|
12694
12692
|
this.test.include(context, includeChildrenRecursively);
|
|
12695
|
-
|
|
12696
|
-
this.body.include(context, includeChildrenRecursively, { asSingleStatement: true });
|
|
12697
|
-
context.brokenFlow = brokenFlow;
|
|
12693
|
+
includeLoopBody(context, this.body, includeChildrenRecursively);
|
|
12698
12694
|
}
|
|
12699
12695
|
}
|
|
12700
12696
|
|
|
@@ -14411,6 +14407,7 @@ function getImportBlock$1(dependencies, { _, cnst, n }, compact) {
|
|
|
14411
14407
|
return '';
|
|
14412
14408
|
}
|
|
14413
14409
|
|
|
14410
|
+
const safeExportName = (name) => isValidIdentifier(name) ? name : JSON.stringify(name);
|
|
14414
14411
|
function es(magicString, { accessedGlobals, indent: t, intro, outro, dependencies, exports, snippets }, { externalLiveBindings, freeze, namespaceToStringTag }) {
|
|
14415
14412
|
const { n } = snippets;
|
|
14416
14413
|
const importBlock = getImportBlock(dependencies, snippets);
|
|
@@ -14460,7 +14457,7 @@ function getImportBlock(dependencies, { _ }) {
|
|
|
14460
14457
|
importBlock.push(`import ${defaultImport ? `${defaultImport.local},${_}` : ''}{${_}${importedNames
|
|
14461
14458
|
.map(specifier => specifier.imported === specifier.local
|
|
14462
14459
|
? specifier.imported
|
|
14463
|
-
: `${specifier.imported} as ${specifier.local}`)
|
|
14460
|
+
: `${safeExportName(specifier.imported)} as ${specifier.local}`)
|
|
14464
14461
|
.join(`,${_}`)}${_}}${_}from${_}${pathWithAssertion}`);
|
|
14465
14462
|
}
|
|
14466
14463
|
}
|
|
@@ -14488,14 +14485,16 @@ function getImportBlock(dependencies, { _ }) {
|
|
|
14488
14485
|
importBlock.push(`import${_}*${_}as ${name} from${_}${pathWithAssertion}`);
|
|
14489
14486
|
}
|
|
14490
14487
|
for (const specifier of namespaceReexports) {
|
|
14491
|
-
importBlock.push(`export${_}{${_}${name === specifier.reexported
|
|
14488
|
+
importBlock.push(`export${_}{${_}${name === specifier.reexported
|
|
14489
|
+
? name
|
|
14490
|
+
: `${name} as ${safeExportName(specifier.reexported)}`} };`);
|
|
14492
14491
|
}
|
|
14493
14492
|
}
|
|
14494
14493
|
if (namedReexports.length > 0) {
|
|
14495
14494
|
importBlock.push(`export${_}{${_}${namedReexports
|
|
14496
14495
|
.map(specifier => specifier.imported === specifier.reexported
|
|
14497
|
-
? specifier.imported
|
|
14498
|
-
: `${specifier.imported} as ${specifier.reexported}`)
|
|
14496
|
+
? safeExportName(specifier.imported)
|
|
14497
|
+
: `${safeExportName(specifier.imported)} as ${safeExportName(specifier.reexported)}`)
|
|
14499
14498
|
.join(`,${_}`)}${_}}${_}from${_}${pathWithAssertion}`);
|
|
14500
14499
|
}
|
|
14501
14500
|
}
|
|
@@ -14511,7 +14510,7 @@ function getExportBlock(exports, { _, cnst }) {
|
|
|
14511
14510
|
}
|
|
14512
14511
|
exportDeclaration.push(specifier.exported === specifier.local
|
|
14513
14512
|
? specifier.local
|
|
14514
|
-
: `${specifier.local} as ${specifier.exported}`);
|
|
14513
|
+
: `${specifier.local} as ${safeExportName(specifier.exported)}`);
|
|
14515
14514
|
}
|
|
14516
14515
|
if (exportDeclaration.length > 0) {
|
|
14517
14516
|
exportBlock.push(`export${_}{${_}${exportDeclaration.join(`,${_}`)}${_}};`);
|
|
@@ -16969,8 +16968,8 @@ function getGenerateCodeSnippets({ compact, generatedCode: { arrowFunctions, con
|
|
|
16969
16968
|
: `${s}${lineBreakIndent ? `${n}${lineBreakIndent.base}` : _}}`
|
|
16970
16969
|
];
|
|
16971
16970
|
const isValidPropertyName = reservedNamesAsProps
|
|
16972
|
-
?
|
|
16973
|
-
: (name) => !RESERVED_NAMES$1.has(name) &&
|
|
16971
|
+
? isValidIdentifier
|
|
16972
|
+
: (name) => !RESERVED_NAMES$1.has(name) && isValidIdentifier(name);
|
|
16974
16973
|
return {
|
|
16975
16974
|
_,
|
|
16976
16975
|
cnst,
|
|
@@ -17004,7 +17003,6 @@ function getGenerateCodeSnippets({ compact, generatedCode: { arrowFunctions, con
|
|
|
17004
17003
|
};
|
|
17005
17004
|
}
|
|
17006
17005
|
const wrapIfNeeded = (code, needsParens) => needsParens ? `(${code})` : code;
|
|
17007
|
-
const validPropertyName = /^(?!\d)[\w$]+$/;
|
|
17008
17006
|
|
|
17009
17007
|
class Source {
|
|
17010
17008
|
constructor(filename, content) {
|
package/dist/es/shared/watch.js
CHANGED
package/dist/loadConfigFile.js
CHANGED
package/dist/rollup.js
CHANGED
package/dist/shared/index.js
CHANGED
package/dist/shared/rollup.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
2
|
@license
|
|
3
|
-
Rollup.js v3.20.
|
|
4
|
-
|
|
3
|
+
Rollup.js v3.20.5
|
|
4
|
+
Tue, 18 Apr 2023 05:00:18 GMT - commit 8411bd07421c8b02b53722fb943cb96700a6e058
|
|
5
5
|
|
|
6
6
|
https://github.com/rollup/rollup
|
|
7
7
|
|
|
@@ -31,7 +31,7 @@ function _interopNamespaceDefault(e) {
|
|
|
31
31
|
|
|
32
32
|
const tty__namespace = /*#__PURE__*/_interopNamespaceDefault(tty);
|
|
33
33
|
|
|
34
|
-
var version$1 = "3.20.
|
|
34
|
+
var version$1 = "3.20.5";
|
|
35
35
|
|
|
36
36
|
function ensureArray$1(items) {
|
|
37
37
|
if (Array.isArray(items)) {
|
|
@@ -5537,12 +5537,11 @@ const builtins = 'arguments Infinity NaN undefined null true false eval uneval i
|
|
|
5537
5537
|
const forbiddenIdentifiers = new Set(`${reservedWords$1} ${builtins}`.split(' '));
|
|
5538
5538
|
forbiddenIdentifiers.add('');
|
|
5539
5539
|
|
|
5540
|
-
const BROKEN_FLOW_NONE = 0;
|
|
5541
|
-
const BROKEN_FLOW_BREAK_CONTINUE = 1;
|
|
5542
|
-
const BROKEN_FLOW_ERROR_RETURN_LABEL = 2;
|
|
5543
5540
|
function createInclusionContext() {
|
|
5544
5541
|
return {
|
|
5545
|
-
brokenFlow:
|
|
5542
|
+
brokenFlow: false,
|
|
5543
|
+
hasBreak: false,
|
|
5544
|
+
hasContinue: false,
|
|
5546
5545
|
includedCallArguments: new Set(),
|
|
5547
5546
|
includedLabels: new Set()
|
|
5548
5547
|
};
|
|
@@ -5551,8 +5550,10 @@ function createHasEffectsContext() {
|
|
|
5551
5550
|
return {
|
|
5552
5551
|
accessed: new PathTracker(),
|
|
5553
5552
|
assigned: new PathTracker(),
|
|
5554
|
-
brokenFlow:
|
|
5553
|
+
brokenFlow: false,
|
|
5555
5554
|
called: new DiscriminatedPathTracker(),
|
|
5555
|
+
hasBreak: false,
|
|
5556
|
+
hasContinue: false,
|
|
5556
5557
|
ignore: {
|
|
5557
5558
|
breaks: false,
|
|
5558
5559
|
continues: false,
|
|
@@ -7357,11 +7358,17 @@ function toBase64(value) {
|
|
|
7357
7358
|
return outString;
|
|
7358
7359
|
}
|
|
7359
7360
|
|
|
7361
|
+
const validIdentifier = /^(?!\d)[\w$]+$/;
|
|
7362
|
+
function isValidIdentifier(name) {
|
|
7363
|
+
return validIdentifier.test(name);
|
|
7364
|
+
}
|
|
7365
|
+
|
|
7360
7366
|
function getSafeName(baseName, usedNames, forbiddenNames) {
|
|
7361
|
-
|
|
7367
|
+
const safeBase = isValidIdentifier(baseName) ? baseName : '_safe';
|
|
7368
|
+
let safeName = safeBase;
|
|
7362
7369
|
let count = 1;
|
|
7363
7370
|
while (usedNames.has(safeName) || RESERVED_NAMES$1.has(safeName) || forbiddenNames?.has(safeName)) {
|
|
7364
|
-
safeName = `${
|
|
7371
|
+
safeName = `${safeBase}$${toBase64(count++)}`;
|
|
7365
7372
|
}
|
|
7366
7373
|
usedNames.add(safeName);
|
|
7367
7374
|
return safeName;
|
|
@@ -9170,7 +9177,7 @@ class FunctionBase extends NodeBase {
|
|
|
9170
9177
|
this.applyDeoptimizations();
|
|
9171
9178
|
this.included = true;
|
|
9172
9179
|
const { brokenFlow } = context;
|
|
9173
|
-
context.brokenFlow =
|
|
9180
|
+
context.brokenFlow = false;
|
|
9174
9181
|
this.body.include(context, includeChildrenRecursively);
|
|
9175
9182
|
context.brokenFlow = brokenFlow;
|
|
9176
9183
|
}
|
|
@@ -9648,13 +9655,13 @@ class BreakStatement extends NodeBase {
|
|
|
9648
9655
|
if (!context.ignore.labels.has(this.label.name))
|
|
9649
9656
|
return true;
|
|
9650
9657
|
context.includedLabels.add(this.label.name);
|
|
9651
|
-
context.brokenFlow = BROKEN_FLOW_ERROR_RETURN_LABEL;
|
|
9652
9658
|
}
|
|
9653
9659
|
else {
|
|
9654
9660
|
if (!context.ignore.breaks)
|
|
9655
9661
|
return true;
|
|
9656
|
-
context.
|
|
9662
|
+
context.hasBreak = true;
|
|
9657
9663
|
}
|
|
9664
|
+
context.brokenFlow = true;
|
|
9658
9665
|
return false;
|
|
9659
9666
|
}
|
|
9660
9667
|
include(context) {
|
|
@@ -9663,7 +9670,10 @@ class BreakStatement extends NodeBase {
|
|
|
9663
9670
|
this.label.include();
|
|
9664
9671
|
context.includedLabels.add(this.label.name);
|
|
9665
9672
|
}
|
|
9666
|
-
|
|
9673
|
+
else {
|
|
9674
|
+
context.hasBreak = true;
|
|
9675
|
+
}
|
|
9676
|
+
context.brokenFlow = true;
|
|
9667
9677
|
}
|
|
9668
9678
|
}
|
|
9669
9679
|
|
|
@@ -10736,13 +10746,13 @@ class ContinueStatement extends NodeBase {
|
|
|
10736
10746
|
if (!context.ignore.labels.has(this.label.name))
|
|
10737
10747
|
return true;
|
|
10738
10748
|
context.includedLabels.add(this.label.name);
|
|
10739
|
-
context.brokenFlow = BROKEN_FLOW_ERROR_RETURN_LABEL;
|
|
10740
10749
|
}
|
|
10741
10750
|
else {
|
|
10742
10751
|
if (!context.ignore.continues)
|
|
10743
10752
|
return true;
|
|
10744
|
-
context.
|
|
10753
|
+
context.hasContinue = true;
|
|
10745
10754
|
}
|
|
10755
|
+
context.brokenFlow = true;
|
|
10746
10756
|
return false;
|
|
10747
10757
|
}
|
|
10748
10758
|
include(context) {
|
|
@@ -10751,31 +10761,49 @@ class ContinueStatement extends NodeBase {
|
|
|
10751
10761
|
this.label.include();
|
|
10752
10762
|
context.includedLabels.add(this.label.name);
|
|
10753
10763
|
}
|
|
10754
|
-
|
|
10764
|
+
else {
|
|
10765
|
+
context.hasContinue = true;
|
|
10766
|
+
}
|
|
10767
|
+
context.brokenFlow = true;
|
|
10755
10768
|
}
|
|
10756
10769
|
}
|
|
10757
10770
|
|
|
10771
|
+
function hasLoopBodyEffects(context, body) {
|
|
10772
|
+
const { brokenFlow, hasBreak, hasContinue, ignore } = context;
|
|
10773
|
+
const { breaks, continues } = ignore;
|
|
10774
|
+
ignore.breaks = true;
|
|
10775
|
+
ignore.continues = true;
|
|
10776
|
+
context.hasBreak = false;
|
|
10777
|
+
context.hasContinue = false;
|
|
10778
|
+
if (body.hasEffects(context))
|
|
10779
|
+
return true;
|
|
10780
|
+
ignore.breaks = breaks;
|
|
10781
|
+
ignore.continues = continues;
|
|
10782
|
+
context.hasBreak = hasBreak;
|
|
10783
|
+
context.hasContinue = hasContinue;
|
|
10784
|
+
context.brokenFlow = brokenFlow;
|
|
10785
|
+
return false;
|
|
10786
|
+
}
|
|
10787
|
+
function includeLoopBody(context, body, includeChildrenRecursively) {
|
|
10788
|
+
const { brokenFlow, hasBreak, hasContinue } = context;
|
|
10789
|
+
context.hasBreak = false;
|
|
10790
|
+
context.hasContinue = false;
|
|
10791
|
+
body.include(context, includeChildrenRecursively, { asSingleStatement: true });
|
|
10792
|
+
context.hasBreak = hasBreak;
|
|
10793
|
+
context.hasContinue = hasContinue;
|
|
10794
|
+
context.brokenFlow = brokenFlow;
|
|
10795
|
+
}
|
|
10796
|
+
|
|
10758
10797
|
class DoWhileStatement extends NodeBase {
|
|
10759
10798
|
hasEffects(context) {
|
|
10760
10799
|
if (this.test.hasEffects(context))
|
|
10761
10800
|
return true;
|
|
10762
|
-
|
|
10763
|
-
const { breaks, continues } = ignore;
|
|
10764
|
-
ignore.breaks = true;
|
|
10765
|
-
ignore.continues = true;
|
|
10766
|
-
if (this.body.hasEffects(context))
|
|
10767
|
-
return true;
|
|
10768
|
-
ignore.breaks = breaks;
|
|
10769
|
-
ignore.continues = continues;
|
|
10770
|
-
context.brokenFlow = brokenFlow;
|
|
10771
|
-
return false;
|
|
10801
|
+
return hasLoopBodyEffects(context, this.body);
|
|
10772
10802
|
}
|
|
10773
10803
|
include(context, includeChildrenRecursively) {
|
|
10774
10804
|
this.included = true;
|
|
10775
10805
|
this.test.include(context, includeChildrenRecursively);
|
|
10776
|
-
|
|
10777
|
-
this.body.include(context, includeChildrenRecursively, { asSingleStatement: true });
|
|
10778
|
-
context.brokenFlow = brokenFlow;
|
|
10806
|
+
includeLoopBody(context, this.body, includeChildrenRecursively);
|
|
10779
10807
|
}
|
|
10780
10808
|
}
|
|
10781
10809
|
|
|
@@ -10941,16 +10969,7 @@ class ForInStatement extends NodeBase {
|
|
|
10941
10969
|
this.applyDeoptimizations();
|
|
10942
10970
|
if (left.hasEffectsAsAssignmentTarget(context, false) || right.hasEffects(context))
|
|
10943
10971
|
return true;
|
|
10944
|
-
|
|
10945
|
-
const { breaks, continues } = ignore;
|
|
10946
|
-
ignore.breaks = true;
|
|
10947
|
-
ignore.continues = true;
|
|
10948
|
-
if (body.hasEffects(context))
|
|
10949
|
-
return true;
|
|
10950
|
-
ignore.breaks = breaks;
|
|
10951
|
-
ignore.continues = continues;
|
|
10952
|
-
context.brokenFlow = brokenFlow;
|
|
10953
|
-
return false;
|
|
10972
|
+
return hasLoopBodyEffects(context, body);
|
|
10954
10973
|
}
|
|
10955
10974
|
include(context, includeChildrenRecursively) {
|
|
10956
10975
|
const { body, deoptimized, left, right } = this;
|
|
@@ -10959,9 +10978,7 @@ class ForInStatement extends NodeBase {
|
|
|
10959
10978
|
this.included = true;
|
|
10960
10979
|
left.includeAsAssignmentTarget(context, includeChildrenRecursively || true, false);
|
|
10961
10980
|
right.include(context, includeChildrenRecursively);
|
|
10962
|
-
|
|
10963
|
-
body.include(context, includeChildrenRecursively, { asSingleStatement: true });
|
|
10964
|
-
context.brokenFlow = brokenFlow;
|
|
10981
|
+
includeLoopBody(context, body, includeChildrenRecursively);
|
|
10965
10982
|
}
|
|
10966
10983
|
initialise() {
|
|
10967
10984
|
this.left.setAssignedValue(UNKNOWN_EXPRESSION);
|
|
@@ -10999,9 +11016,7 @@ class ForOfStatement extends NodeBase {
|
|
|
10999
11016
|
this.included = true;
|
|
11000
11017
|
left.includeAsAssignmentTarget(context, includeChildrenRecursively || true, false);
|
|
11001
11018
|
right.include(context, includeChildrenRecursively);
|
|
11002
|
-
|
|
11003
|
-
body.include(context, includeChildrenRecursively, { asSingleStatement: true });
|
|
11004
|
-
context.brokenFlow = brokenFlow;
|
|
11019
|
+
includeLoopBody(context, body, includeChildrenRecursively);
|
|
11005
11020
|
}
|
|
11006
11021
|
initialise() {
|
|
11007
11022
|
this.left.setAssignedValue(UNKNOWN_EXPRESSION);
|
|
@@ -11029,27 +11044,17 @@ class ForStatement extends NodeBase {
|
|
|
11029
11044
|
hasEffects(context) {
|
|
11030
11045
|
if (this.init?.hasEffects(context) ||
|
|
11031
11046
|
this.test?.hasEffects(context) ||
|
|
11032
|
-
this.update?.hasEffects(context))
|
|
11047
|
+
this.update?.hasEffects(context)) {
|
|
11033
11048
|
return true;
|
|
11034
|
-
|
|
11035
|
-
|
|
11036
|
-
ignore.breaks = true;
|
|
11037
|
-
ignore.continues = true;
|
|
11038
|
-
if (this.body.hasEffects(context))
|
|
11039
|
-
return true;
|
|
11040
|
-
ignore.breaks = breaks;
|
|
11041
|
-
ignore.continues = continues;
|
|
11042
|
-
context.brokenFlow = brokenFlow;
|
|
11043
|
-
return false;
|
|
11049
|
+
}
|
|
11050
|
+
return hasLoopBodyEffects(context, this.body);
|
|
11044
11051
|
}
|
|
11045
11052
|
include(context, includeChildrenRecursively) {
|
|
11046
11053
|
this.included = true;
|
|
11047
11054
|
this.init?.include(context, includeChildrenRecursively, { asSingleStatement: true });
|
|
11048
11055
|
this.test?.include(context, includeChildrenRecursively);
|
|
11049
|
-
const { brokenFlow } = context;
|
|
11050
11056
|
this.update?.include(context, includeChildrenRecursively);
|
|
11051
|
-
this.body
|
|
11052
|
-
context.brokenFlow = brokenFlow;
|
|
11057
|
+
includeLoopBody(context, this.body, includeChildrenRecursively);
|
|
11053
11058
|
}
|
|
11054
11059
|
render(code, options) {
|
|
11055
11060
|
this.init?.render(code, options, NO_SEMICOLON);
|
|
@@ -11105,9 +11110,8 @@ class IfStatement extends NodeBase {
|
|
|
11105
11110
|
return false;
|
|
11106
11111
|
if (this.alternate.hasEffects(context))
|
|
11107
11112
|
return true;
|
|
11108
|
-
|
|
11109
|
-
|
|
11110
|
-
context.brokenFlow < consequentBrokenFlow ? context.brokenFlow : consequentBrokenFlow;
|
|
11113
|
+
// eslint-disable-next-line unicorn/consistent-destructuring
|
|
11114
|
+
context.brokenFlow = context.brokenFlow && consequentBrokenFlow;
|
|
11111
11115
|
return false;
|
|
11112
11116
|
}
|
|
11113
11117
|
return testValue ? this.consequent.hasEffects(context) : !!this.alternate?.hasEffects(context);
|
|
@@ -11206,7 +11210,7 @@ class IfStatement extends NodeBase {
|
|
|
11206
11210
|
includeUnknownTest(context) {
|
|
11207
11211
|
this.test.include(context, false);
|
|
11208
11212
|
const { brokenFlow } = context;
|
|
11209
|
-
let consequentBrokenFlow =
|
|
11213
|
+
let consequentBrokenFlow = false;
|
|
11210
11214
|
if (this.consequent.shouldBeIncluded(context)) {
|
|
11211
11215
|
this.consequent.include(context, false, { asSingleStatement: true });
|
|
11212
11216
|
// eslint-disable-next-line unicorn/consistent-destructuring
|
|
@@ -11215,9 +11219,8 @@ class IfStatement extends NodeBase {
|
|
|
11215
11219
|
}
|
|
11216
11220
|
if (this.alternate?.shouldBeIncluded(context)) {
|
|
11217
11221
|
this.alternate.include(context, false, { asSingleStatement: true });
|
|
11218
|
-
|
|
11219
|
-
|
|
11220
|
-
context.brokenFlow < consequentBrokenFlow ? context.brokenFlow : consequentBrokenFlow;
|
|
11222
|
+
// eslint-disable-next-line unicorn/consistent-destructuring
|
|
11223
|
+
context.brokenFlow = context.brokenFlow && consequentBrokenFlow;
|
|
11221
11224
|
}
|
|
11222
11225
|
}
|
|
11223
11226
|
renderHoistedDeclarations(hoistedDeclarations, code, getPropertyAccess) {
|
|
@@ -12268,13 +12271,13 @@ class ReturnStatement extends NodeBase {
|
|
|
12268
12271
|
hasEffects(context) {
|
|
12269
12272
|
if (!context.ignore.returnYield || this.argument?.hasEffects(context))
|
|
12270
12273
|
return true;
|
|
12271
|
-
context.brokenFlow =
|
|
12274
|
+
context.brokenFlow = true;
|
|
12272
12275
|
return false;
|
|
12273
12276
|
}
|
|
12274
12277
|
include(context, includeChildrenRecursively) {
|
|
12275
12278
|
this.included = true;
|
|
12276
12279
|
this.argument?.include(context, includeChildrenRecursively);
|
|
12277
|
-
context.brokenFlow =
|
|
12280
|
+
context.brokenFlow = true;
|
|
12278
12281
|
}
|
|
12279
12282
|
initialise() {
|
|
12280
12283
|
this.scope.addReturnExpression(this.argument || UNKNOWN_EXPRESSION);
|
|
@@ -12441,28 +12444,32 @@ class SwitchStatement extends NodeBase {
|
|
|
12441
12444
|
hasEffects(context) {
|
|
12442
12445
|
if (this.discriminant.hasEffects(context))
|
|
12443
12446
|
return true;
|
|
12444
|
-
const { brokenFlow, ignore } = context;
|
|
12447
|
+
const { brokenFlow, hasBreak, ignore } = context;
|
|
12445
12448
|
const { breaks } = ignore;
|
|
12446
|
-
let minBrokenFlow = Infinity;
|
|
12447
12449
|
ignore.breaks = true;
|
|
12450
|
+
context.hasBreak = false;
|
|
12451
|
+
let onlyHasBrokenFlow = true;
|
|
12448
12452
|
for (const switchCase of this.cases) {
|
|
12449
12453
|
if (switchCase.hasEffects(context))
|
|
12450
12454
|
return true;
|
|
12451
12455
|
// eslint-disable-next-line unicorn/consistent-destructuring
|
|
12452
|
-
|
|
12456
|
+
onlyHasBrokenFlow && (onlyHasBrokenFlow = context.brokenFlow && !context.hasBreak);
|
|
12457
|
+
context.hasBreak = false;
|
|
12453
12458
|
context.brokenFlow = brokenFlow;
|
|
12454
12459
|
}
|
|
12455
|
-
if (this.defaultCase !== null
|
|
12456
|
-
context.brokenFlow =
|
|
12460
|
+
if (this.defaultCase !== null) {
|
|
12461
|
+
context.brokenFlow = onlyHasBrokenFlow;
|
|
12457
12462
|
}
|
|
12458
12463
|
ignore.breaks = breaks;
|
|
12464
|
+
context.hasBreak = hasBreak;
|
|
12459
12465
|
return false;
|
|
12460
12466
|
}
|
|
12461
12467
|
include(context, includeChildrenRecursively) {
|
|
12462
12468
|
this.included = true;
|
|
12463
12469
|
this.discriminant.include(context, includeChildrenRecursively);
|
|
12464
|
-
const { brokenFlow } = context;
|
|
12465
|
-
|
|
12470
|
+
const { brokenFlow, hasBreak } = context;
|
|
12471
|
+
context.hasBreak = false;
|
|
12472
|
+
let onlyHasBrokenFlow = true;
|
|
12466
12473
|
let isCaseIncluded = includeChildrenRecursively ||
|
|
12467
12474
|
(this.defaultCase !== null && this.defaultCase < this.cases.length - 1);
|
|
12468
12475
|
for (let caseIndex = this.cases.length - 1; caseIndex >= 0; caseIndex--) {
|
|
@@ -12478,18 +12485,18 @@ class SwitchStatement extends NodeBase {
|
|
|
12478
12485
|
if (isCaseIncluded) {
|
|
12479
12486
|
switchCase.include(context, includeChildrenRecursively);
|
|
12480
12487
|
// eslint-disable-next-line unicorn/consistent-destructuring
|
|
12481
|
-
|
|
12488
|
+
onlyHasBrokenFlow && (onlyHasBrokenFlow = context.brokenFlow && !context.hasBreak);
|
|
12489
|
+
context.hasBreak = false;
|
|
12482
12490
|
context.brokenFlow = brokenFlow;
|
|
12483
12491
|
}
|
|
12484
12492
|
else {
|
|
12485
|
-
|
|
12493
|
+
onlyHasBrokenFlow = brokenFlow;
|
|
12486
12494
|
}
|
|
12487
12495
|
}
|
|
12488
|
-
if (isCaseIncluded &&
|
|
12489
|
-
|
|
12490
|
-
!(minBrokenFlow === BROKEN_FLOW_BREAK_CONTINUE)) {
|
|
12491
|
-
context.brokenFlow = minBrokenFlow;
|
|
12496
|
+
if (isCaseIncluded && this.defaultCase !== null) {
|
|
12497
|
+
context.brokenFlow = onlyHasBrokenFlow;
|
|
12492
12498
|
}
|
|
12499
|
+
context.hasBreak = hasBreak;
|
|
12493
12500
|
}
|
|
12494
12501
|
initialise() {
|
|
12495
12502
|
for (let caseIndex = 0; caseIndex < this.cases.length; caseIndex++) {
|
|
@@ -12782,7 +12789,7 @@ class ThrowStatement extends NodeBase {
|
|
|
12782
12789
|
include(context, includeChildrenRecursively) {
|
|
12783
12790
|
this.included = true;
|
|
12784
12791
|
this.argument.include(context, includeChildrenRecursively);
|
|
12785
|
-
context.brokenFlow =
|
|
12792
|
+
context.brokenFlow = true;
|
|
12786
12793
|
}
|
|
12787
12794
|
render(code, options) {
|
|
12788
12795
|
this.argument.render(code, options, { preventASI: true });
|
|
@@ -13176,23 +13183,12 @@ class WhileStatement extends NodeBase {
|
|
|
13176
13183
|
hasEffects(context) {
|
|
13177
13184
|
if (this.test.hasEffects(context))
|
|
13178
13185
|
return true;
|
|
13179
|
-
|
|
13180
|
-
const { breaks, continues } = ignore;
|
|
13181
|
-
ignore.breaks = true;
|
|
13182
|
-
ignore.continues = true;
|
|
13183
|
-
if (this.body.hasEffects(context))
|
|
13184
|
-
return true;
|
|
13185
|
-
ignore.breaks = breaks;
|
|
13186
|
-
ignore.continues = continues;
|
|
13187
|
-
context.brokenFlow = brokenFlow;
|
|
13188
|
-
return false;
|
|
13186
|
+
return hasLoopBodyEffects(context, this.body);
|
|
13189
13187
|
}
|
|
13190
13188
|
include(context, includeChildrenRecursively) {
|
|
13191
13189
|
this.included = true;
|
|
13192
13190
|
this.test.include(context, includeChildrenRecursively);
|
|
13193
|
-
|
|
13194
|
-
this.body.include(context, includeChildrenRecursively, { asSingleStatement: true });
|
|
13195
|
-
context.brokenFlow = brokenFlow;
|
|
13191
|
+
includeLoopBody(context, this.body, includeChildrenRecursively);
|
|
13196
13192
|
}
|
|
13197
13193
|
}
|
|
13198
13194
|
|
|
@@ -14909,6 +14905,7 @@ function getImportBlock$1(dependencies, { _, cnst, n }, compact) {
|
|
|
14909
14905
|
return '';
|
|
14910
14906
|
}
|
|
14911
14907
|
|
|
14908
|
+
const safeExportName = (name) => isValidIdentifier(name) ? name : JSON.stringify(name);
|
|
14912
14909
|
function es(magicString, { accessedGlobals, indent: t, intro, outro, dependencies, exports, snippets }, { externalLiveBindings, freeze, namespaceToStringTag }) {
|
|
14913
14910
|
const { n } = snippets;
|
|
14914
14911
|
const importBlock = getImportBlock(dependencies, snippets);
|
|
@@ -14958,7 +14955,7 @@ function getImportBlock(dependencies, { _ }) {
|
|
|
14958
14955
|
importBlock.push(`import ${defaultImport ? `${defaultImport.local},${_}` : ''}{${_}${importedNames
|
|
14959
14956
|
.map(specifier => specifier.imported === specifier.local
|
|
14960
14957
|
? specifier.imported
|
|
14961
|
-
: `${specifier.imported} as ${specifier.local}`)
|
|
14958
|
+
: `${safeExportName(specifier.imported)} as ${specifier.local}`)
|
|
14962
14959
|
.join(`,${_}`)}${_}}${_}from${_}${pathWithAssertion}`);
|
|
14963
14960
|
}
|
|
14964
14961
|
}
|
|
@@ -14986,14 +14983,16 @@ function getImportBlock(dependencies, { _ }) {
|
|
|
14986
14983
|
importBlock.push(`import${_}*${_}as ${name} from${_}${pathWithAssertion}`);
|
|
14987
14984
|
}
|
|
14988
14985
|
for (const specifier of namespaceReexports) {
|
|
14989
|
-
importBlock.push(`export${_}{${_}${name === specifier.reexported
|
|
14986
|
+
importBlock.push(`export${_}{${_}${name === specifier.reexported
|
|
14987
|
+
? name
|
|
14988
|
+
: `${name} as ${safeExportName(specifier.reexported)}`} };`);
|
|
14990
14989
|
}
|
|
14991
14990
|
}
|
|
14992
14991
|
if (namedReexports.length > 0) {
|
|
14993
14992
|
importBlock.push(`export${_}{${_}${namedReexports
|
|
14994
14993
|
.map(specifier => specifier.imported === specifier.reexported
|
|
14995
|
-
? specifier.imported
|
|
14996
|
-
: `${specifier.imported} as ${specifier.reexported}`)
|
|
14994
|
+
? safeExportName(specifier.imported)
|
|
14995
|
+
: `${safeExportName(specifier.imported)} as ${safeExportName(specifier.reexported)}`)
|
|
14997
14996
|
.join(`,${_}`)}${_}}${_}from${_}${pathWithAssertion}`);
|
|
14998
14997
|
}
|
|
14999
14998
|
}
|
|
@@ -15009,7 +15008,7 @@ function getExportBlock(exports, { _, cnst }) {
|
|
|
15009
15008
|
}
|
|
15010
15009
|
exportDeclaration.push(specifier.exported === specifier.local
|
|
15011
15010
|
? specifier.local
|
|
15012
|
-
: `${specifier.local} as ${specifier.exported}`);
|
|
15011
|
+
: `${specifier.local} as ${safeExportName(specifier.exported)}`);
|
|
15013
15012
|
}
|
|
15014
15013
|
if (exportDeclaration.length > 0) {
|
|
15015
15014
|
exportBlock.push(`export${_}{${_}${exportDeclaration.join(`,${_}`)}${_}};`);
|
|
@@ -17467,8 +17466,8 @@ function getGenerateCodeSnippets({ compact, generatedCode: { arrowFunctions, con
|
|
|
17467
17466
|
: `${s}${lineBreakIndent ? `${n}${lineBreakIndent.base}` : _}}`
|
|
17468
17467
|
];
|
|
17469
17468
|
const isValidPropertyName = reservedNamesAsProps
|
|
17470
|
-
?
|
|
17471
|
-
: (name) => !RESERVED_NAMES$1.has(name) &&
|
|
17469
|
+
? isValidIdentifier
|
|
17470
|
+
: (name) => !RESERVED_NAMES$1.has(name) && isValidIdentifier(name);
|
|
17472
17471
|
return {
|
|
17473
17472
|
_,
|
|
17474
17473
|
cnst,
|
|
@@ -17502,7 +17501,6 @@ function getGenerateCodeSnippets({ compact, generatedCode: { arrowFunctions, con
|
|
|
17502
17501
|
};
|
|
17503
17502
|
}
|
|
17504
17503
|
const wrapIfNeeded = (code, needsParens) => needsParens ? `(${code})` : code;
|
|
17505
|
-
const validPropertyName = /^(?!\d)[\w$]+$/;
|
|
17506
17504
|
|
|
17507
17505
|
class Source {
|
|
17508
17506
|
constructor(filename, content) {
|
package/dist/shared/watch-cli.js
CHANGED
package/dist/shared/watch.js
CHANGED