rollup 3.9.1 → 3.10.0
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/LICENSE.md +0 -29
- package/dist/bin/rollup +2 -2
- package/dist/es/rollup.js +2 -2
- package/dist/es/shared/rollup.js +202 -208
- package/dist/es/shared/watch.js +2 -2
- package/dist/loadConfigFile.js +2 -2
- package/dist/rollup.d.ts +4 -0
- package/dist/rollup.js +2 -2
- package/dist/shared/index.js +2 -2
- package/dist/shared/loadConfigFile.js +2 -2
- package/dist/shared/rollup.js +219 -225
- package/dist/shared/watch-cli.js +2 -2
- package/dist/shared/watch.js +2 -2
- package/package.json +13 -12
package/dist/es/shared/rollup.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
/*
|
|
2
2
|
@license
|
|
3
|
-
Rollup.js v3.
|
|
4
|
-
|
|
3
|
+
Rollup.js v3.10.0
|
|
4
|
+
Thu, 12 Jan 2023 07:56:20 GMT - commit ffc19b0091267d9bf5072b16969599e457a63f5c
|
|
5
5
|
|
|
6
6
|
https://github.com/rollup/rollup
|
|
7
7
|
|
|
8
8
|
Released under the MIT License.
|
|
9
9
|
*/
|
|
10
10
|
import { resolve, basename, extname, dirname, relative as relative$1 } from 'node:path';
|
|
11
|
-
import require$$0$
|
|
11
|
+
import require$$0$1, { win32, posix, isAbsolute as isAbsolute$1, resolve as resolve$1 } from 'path';
|
|
12
12
|
import process$1, { env as env$1 } from 'node:process';
|
|
13
13
|
import { performance } from 'node:perf_hooks';
|
|
14
14
|
import { createHash as createHash$1 } from 'node:crypto';
|
|
@@ -16,15 +16,15 @@ 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.
|
|
19
|
+
var version$1 = "3.10.0";
|
|
20
20
|
|
|
21
21
|
const comma = ','.charCodeAt(0);
|
|
22
22
|
const semicolon = ';'.charCodeAt(0);
|
|
23
|
-
const chars$
|
|
23
|
+
const chars$1 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
|
|
24
24
|
const intToChar = new Uint8Array(64); // 64 possible chars.
|
|
25
25
|
const charToInt = new Uint8Array(128); // z is 122 in ASCII
|
|
26
|
-
for (let i = 0; i < chars$
|
|
27
|
-
const c = chars$
|
|
26
|
+
for (let i = 0; i < chars$1.length; i++) {
|
|
27
|
+
const c = chars$1.charCodeAt(i);
|
|
28
28
|
intToChar[i] = c;
|
|
29
29
|
charToInt[c] = i;
|
|
30
30
|
}
|
|
@@ -47,6 +47,80 @@ const td = typeof TextDecoder !== 'undefined'
|
|
|
47
47
|
return out;
|
|
48
48
|
},
|
|
49
49
|
};
|
|
50
|
+
function decode(mappings) {
|
|
51
|
+
const state = new Int32Array(5);
|
|
52
|
+
const decoded = [];
|
|
53
|
+
let index = 0;
|
|
54
|
+
do {
|
|
55
|
+
const semi = indexOf(mappings, index);
|
|
56
|
+
const line = [];
|
|
57
|
+
let sorted = true;
|
|
58
|
+
let lastCol = 0;
|
|
59
|
+
state[0] = 0;
|
|
60
|
+
for (let i = index; i < semi; i++) {
|
|
61
|
+
let seg;
|
|
62
|
+
i = decodeInteger(mappings, i, state, 0); // genColumn
|
|
63
|
+
const col = state[0];
|
|
64
|
+
if (col < lastCol)
|
|
65
|
+
sorted = false;
|
|
66
|
+
lastCol = col;
|
|
67
|
+
if (hasMoreVlq(mappings, i, semi)) {
|
|
68
|
+
i = decodeInteger(mappings, i, state, 1); // sourcesIndex
|
|
69
|
+
i = decodeInteger(mappings, i, state, 2); // sourceLine
|
|
70
|
+
i = decodeInteger(mappings, i, state, 3); // sourceColumn
|
|
71
|
+
if (hasMoreVlq(mappings, i, semi)) {
|
|
72
|
+
i = decodeInteger(mappings, i, state, 4); // namesIndex
|
|
73
|
+
seg = [col, state[1], state[2], state[3], state[4]];
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
seg = [col, state[1], state[2], state[3]];
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
seg = [col];
|
|
81
|
+
}
|
|
82
|
+
line.push(seg);
|
|
83
|
+
}
|
|
84
|
+
if (!sorted)
|
|
85
|
+
sort(line);
|
|
86
|
+
decoded.push(line);
|
|
87
|
+
index = semi + 1;
|
|
88
|
+
} while (index <= mappings.length);
|
|
89
|
+
return decoded;
|
|
90
|
+
}
|
|
91
|
+
function indexOf(mappings, index) {
|
|
92
|
+
const idx = mappings.indexOf(';', index);
|
|
93
|
+
return idx === -1 ? mappings.length : idx;
|
|
94
|
+
}
|
|
95
|
+
function decodeInteger(mappings, pos, state, j) {
|
|
96
|
+
let value = 0;
|
|
97
|
+
let shift = 0;
|
|
98
|
+
let integer = 0;
|
|
99
|
+
do {
|
|
100
|
+
const c = mappings.charCodeAt(pos++);
|
|
101
|
+
integer = charToInt[c];
|
|
102
|
+
value |= (integer & 31) << shift;
|
|
103
|
+
shift += 5;
|
|
104
|
+
} while (integer & 32);
|
|
105
|
+
const shouldNegate = value & 1;
|
|
106
|
+
value >>>= 1;
|
|
107
|
+
if (shouldNegate) {
|
|
108
|
+
value = -0x80000000 | -value;
|
|
109
|
+
}
|
|
110
|
+
state[j] += value;
|
|
111
|
+
return pos;
|
|
112
|
+
}
|
|
113
|
+
function hasMoreVlq(mappings, i, length) {
|
|
114
|
+
if (i >= length)
|
|
115
|
+
return false;
|
|
116
|
+
return mappings.charCodeAt(i) !== comma;
|
|
117
|
+
}
|
|
118
|
+
function sort(line) {
|
|
119
|
+
line.sort(sortComparator);
|
|
120
|
+
}
|
|
121
|
+
function sortComparator(a, b) {
|
|
122
|
+
return a[0] - b[0];
|
|
123
|
+
}
|
|
50
124
|
function encode(decoded) {
|
|
51
125
|
const state = new Int32Array(5);
|
|
52
126
|
const bufLength = 1024 * 16;
|
|
@@ -2703,7 +2777,7 @@ var picomatch$1 = {
|
|
|
2703
2777
|
|
|
2704
2778
|
var utils$3 = {};
|
|
2705
2779
|
|
|
2706
|
-
const path$1 = require$$0$
|
|
2780
|
+
const path$1 = require$$0$1;
|
|
2707
2781
|
const WIN_SLASH = '\\\\/';
|
|
2708
2782
|
const WIN_NO_SLASH = `[^${WIN_SLASH}]`;
|
|
2709
2783
|
|
|
@@ -2883,7 +2957,7 @@ var constants$2 = {
|
|
|
2883
2957
|
|
|
2884
2958
|
(function (exports) {
|
|
2885
2959
|
|
|
2886
|
-
const path = require$$0$
|
|
2960
|
+
const path = require$$0$1;
|
|
2887
2961
|
const win32 = process.platform === 'win32';
|
|
2888
2962
|
const {
|
|
2889
2963
|
REGEX_BACKSLASH,
|
|
@@ -4420,7 +4494,7 @@ parse$2.fastpaths = (input, options) => {
|
|
|
4420
4494
|
|
|
4421
4495
|
var parse_1 = parse$2;
|
|
4422
4496
|
|
|
4423
|
-
const path = require$$0$
|
|
4497
|
+
const path = require$$0$1;
|
|
4424
4498
|
const scan = scan_1;
|
|
4425
4499
|
const parse$1 = parse_1;
|
|
4426
4500
|
const utils = utils$3;
|
|
@@ -6561,14 +6635,14 @@ class LocalVariable extends Variable {
|
|
|
6561
6635
|
}
|
|
6562
6636
|
}
|
|
6563
6637
|
|
|
6564
|
-
const chars
|
|
6638
|
+
const chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_$';
|
|
6565
6639
|
const base = 64;
|
|
6566
6640
|
function toBase64(value) {
|
|
6567
6641
|
let outString = '';
|
|
6568
6642
|
do {
|
|
6569
6643
|
const currentDigit = value % base;
|
|
6570
6644
|
value = (value / base) | 0;
|
|
6571
|
-
outString = chars
|
|
6645
|
+
outString = chars[currentDigit] + outString;
|
|
6572
6646
|
} while (value !== 0);
|
|
6573
6647
|
return outString;
|
|
6574
6648
|
}
|
|
@@ -6792,7 +6866,6 @@ class ReturnValueScope extends ParameterScope {
|
|
|
6792
6866
|
}
|
|
6793
6867
|
}
|
|
6794
6868
|
|
|
6795
|
-
//@ts-check
|
|
6796
6869
|
/** @typedef { import('estree').Node} Node */
|
|
6797
6870
|
/** @typedef {Node | {
|
|
6798
6871
|
* type: 'PropertyDefinition';
|
|
@@ -6804,7 +6877,7 @@ class ReturnValueScope extends ParameterScope {
|
|
|
6804
6877
|
*
|
|
6805
6878
|
* @param {NodeWithPropertyDefinition} node
|
|
6806
6879
|
* @param {NodeWithPropertyDefinition} parent
|
|
6807
|
-
* @returns boolean
|
|
6880
|
+
* @returns {boolean}
|
|
6808
6881
|
*/
|
|
6809
6882
|
function is_reference (node, parent) {
|
|
6810
6883
|
if (node.type === 'MemberExpression') {
|
|
@@ -9408,7 +9481,34 @@ class CatchClause extends NodeBase {
|
|
|
9408
9481
|
}
|
|
9409
9482
|
}
|
|
9410
9483
|
|
|
9484
|
+
const unset$1 = Symbol('unset');
|
|
9411
9485
|
class ChainExpression extends NodeBase {
|
|
9486
|
+
constructor() {
|
|
9487
|
+
super(...arguments);
|
|
9488
|
+
this.objectValue = unset$1;
|
|
9489
|
+
}
|
|
9490
|
+
deoptimizeCache() {
|
|
9491
|
+
this.objectValue = UnknownValue;
|
|
9492
|
+
}
|
|
9493
|
+
getLiteralValueAtPath() {
|
|
9494
|
+
if (this.getObjectValue() == null)
|
|
9495
|
+
return undefined;
|
|
9496
|
+
return UnknownValue;
|
|
9497
|
+
}
|
|
9498
|
+
hasEffects(context) {
|
|
9499
|
+
if (this.getObjectValue() == null)
|
|
9500
|
+
return false;
|
|
9501
|
+
return this.expression.hasEffects(context);
|
|
9502
|
+
}
|
|
9503
|
+
getObjectValue() {
|
|
9504
|
+
if (this.objectValue === unset$1) {
|
|
9505
|
+
let object = this.expression.type === 'CallExpression' ? this.expression.callee : this.expression.object;
|
|
9506
|
+
if (object.type === 'MemberExpression')
|
|
9507
|
+
object = object.object;
|
|
9508
|
+
this.objectValue = object.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, this);
|
|
9509
|
+
}
|
|
9510
|
+
return this.objectValue;
|
|
9511
|
+
}
|
|
9412
9512
|
}
|
|
9413
9513
|
|
|
9414
9514
|
class ClassBodyScope extends ChildScope {
|
|
@@ -13244,10 +13344,10 @@ class Module {
|
|
|
13244
13344
|
this.transformDependencies = transformDependencies;
|
|
13245
13345
|
this.customTransformCache = customTransformCache;
|
|
13246
13346
|
this.updateOptions(moduleOptions);
|
|
13247
|
-
const moduleAst = ast
|
|
13347
|
+
const moduleAst = ast ?? this.tryParse();
|
|
13248
13348
|
timeEnd('generate ast', 3);
|
|
13249
13349
|
timeStart('analyze ast', 3);
|
|
13250
|
-
this.resolvedIds = resolvedIds
|
|
13350
|
+
this.resolvedIds = resolvedIds ?? Object.create(null);
|
|
13251
13351
|
// By default, `id` is the file name. Custom resolvers and loaders
|
|
13252
13352
|
// can change that, but it makes sense to use it for the source file name
|
|
13253
13353
|
const fileName = this.id;
|
|
@@ -13348,14 +13448,6 @@ class Module {
|
|
|
13348
13448
|
}
|
|
13349
13449
|
return null;
|
|
13350
13450
|
}
|
|
13351
|
-
tryParse() {
|
|
13352
|
-
try {
|
|
13353
|
-
return this.graph.contextParse(this.info.code);
|
|
13354
|
-
}
|
|
13355
|
-
catch (error_) {
|
|
13356
|
-
return this.error(errorParseError(error_, this.id), error_.pos);
|
|
13357
|
-
}
|
|
13358
|
-
}
|
|
13359
13451
|
updateOptions({ meta, moduleSideEffects, syntheticNamedExports }) {
|
|
13360
13452
|
if (moduleSideEffects != null) {
|
|
13361
13453
|
this.info.moduleSideEffects = moduleSideEffects;
|
|
@@ -13637,6 +13729,14 @@ class Module {
|
|
|
13637
13729
|
this.options.onwarn(errorShimmedExport(this.id, name));
|
|
13638
13730
|
this.exports.set(name, MISSING_EXPORT_SHIM_DESCRIPTION);
|
|
13639
13731
|
}
|
|
13732
|
+
tryParse() {
|
|
13733
|
+
try {
|
|
13734
|
+
return this.graph.contextParse(this.info.code);
|
|
13735
|
+
}
|
|
13736
|
+
catch (error_) {
|
|
13737
|
+
return this.error(errorParseError(error_, this.id), error_.pos);
|
|
13738
|
+
}
|
|
13739
|
+
}
|
|
13640
13740
|
}
|
|
13641
13741
|
// if there is a cyclic import in the reexport chain, we should not
|
|
13642
13742
|
// import from the original module but from the cyclic module to not
|
|
@@ -13880,7 +13980,7 @@ var _static = {
|
|
|
13880
13980
|
set exports(v){ _staticExports = v; },
|
|
13881
13981
|
};
|
|
13882
13982
|
|
|
13883
|
-
const require$$0
|
|
13983
|
+
const require$$0 = [
|
|
13884
13984
|
"assert",
|
|
13885
13985
|
"async_hooks",
|
|
13886
13986
|
"buffer",
|
|
@@ -13925,7 +14025,7 @@ const require$$0$1 = [
|
|
|
13925
14025
|
];
|
|
13926
14026
|
|
|
13927
14027
|
(function (module) {
|
|
13928
|
-
module.exports = require$$0
|
|
14028
|
+
module.exports = require$$0;
|
|
13929
14029
|
} (_static));
|
|
13930
14030
|
|
|
13931
14031
|
const builtinModules = /*@__PURE__*/getDefaultExportFromCjs(_staticExports);
|
|
@@ -16403,78 +16503,6 @@ function collapseSourcemap(id, originalCode, originalSourcemap, sourcemapChain,
|
|
|
16403
16503
|
|
|
16404
16504
|
const createHash = () => createHash$1('sha256');
|
|
16405
16505
|
|
|
16406
|
-
var charToInteger = {};
|
|
16407
|
-
var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
|
|
16408
|
-
for (var i$1 = 0; i$1 < chars.length; i$1++) {
|
|
16409
|
-
charToInteger[chars.charCodeAt(i$1)] = i$1;
|
|
16410
|
-
}
|
|
16411
|
-
function decode(mappings) {
|
|
16412
|
-
var decoded = [];
|
|
16413
|
-
var line = [];
|
|
16414
|
-
var segment = [
|
|
16415
|
-
0,
|
|
16416
|
-
0,
|
|
16417
|
-
0,
|
|
16418
|
-
0,
|
|
16419
|
-
0,
|
|
16420
|
-
];
|
|
16421
|
-
var j = 0;
|
|
16422
|
-
for (var i = 0, shift = 0, value = 0; i < mappings.length; i++) {
|
|
16423
|
-
var c = mappings.charCodeAt(i);
|
|
16424
|
-
if (c === 44) { // ","
|
|
16425
|
-
segmentify(line, segment, j);
|
|
16426
|
-
j = 0;
|
|
16427
|
-
}
|
|
16428
|
-
else if (c === 59) { // ";"
|
|
16429
|
-
segmentify(line, segment, j);
|
|
16430
|
-
j = 0;
|
|
16431
|
-
decoded.push(line);
|
|
16432
|
-
line = [];
|
|
16433
|
-
segment[0] = 0;
|
|
16434
|
-
}
|
|
16435
|
-
else {
|
|
16436
|
-
var integer = charToInteger[c];
|
|
16437
|
-
if (integer === undefined) {
|
|
16438
|
-
throw new Error('Invalid character (' + String.fromCharCode(c) + ')');
|
|
16439
|
-
}
|
|
16440
|
-
var hasContinuationBit = integer & 32;
|
|
16441
|
-
integer &= 31;
|
|
16442
|
-
value += integer << shift;
|
|
16443
|
-
if (hasContinuationBit) {
|
|
16444
|
-
shift += 5;
|
|
16445
|
-
}
|
|
16446
|
-
else {
|
|
16447
|
-
var shouldNegate = value & 1;
|
|
16448
|
-
value >>>= 1;
|
|
16449
|
-
if (shouldNegate) {
|
|
16450
|
-
value = value === 0 ? -0x80000000 : -value;
|
|
16451
|
-
}
|
|
16452
|
-
segment[j] += value;
|
|
16453
|
-
j++;
|
|
16454
|
-
value = shift = 0; // reset
|
|
16455
|
-
}
|
|
16456
|
-
}
|
|
16457
|
-
}
|
|
16458
|
-
segmentify(line, segment, j);
|
|
16459
|
-
decoded.push(line);
|
|
16460
|
-
return decoded;
|
|
16461
|
-
}
|
|
16462
|
-
function segmentify(line, segment, j) {
|
|
16463
|
-
// This looks ugly, but we're creating specialized arrays with a specific
|
|
16464
|
-
// length. This is much faster than creating a new array (which v8 expands to
|
|
16465
|
-
// a capacity of 17 after pushing the first item), or slicing out a subarray
|
|
16466
|
-
// (which is slow). Length 4 is assumed to be the most frequent, followed by
|
|
16467
|
-
// length 5 (since not everything will have an associated name), followed by
|
|
16468
|
-
// length 1 (it's probably rare for a source substring to not have an
|
|
16469
|
-
// associated segment data).
|
|
16470
|
-
if (j === 4)
|
|
16471
|
-
line.push([segment[0], segment[1], segment[2], segment[3]]);
|
|
16472
|
-
else if (j === 5)
|
|
16473
|
-
line.push([segment[0], segment[1], segment[2], segment[3], segment[4]]);
|
|
16474
|
-
else if (j === 1)
|
|
16475
|
-
line.push([segment[0]]);
|
|
16476
|
-
}
|
|
16477
|
-
|
|
16478
16506
|
function decodedSourcemap(map) {
|
|
16479
16507
|
if (!map)
|
|
16480
16508
|
return null;
|
|
@@ -16767,7 +16795,6 @@ class Bundle {
|
|
|
16767
16795
|
if ('code' in file) {
|
|
16768
16796
|
try {
|
|
16769
16797
|
this.graph.contextParse(file.code, {
|
|
16770
|
-
allowHashBang: true,
|
|
16771
16798
|
ecmaVersion: 'latest'
|
|
16772
16799
|
});
|
|
16773
16800
|
}
|
|
@@ -22428,7 +22455,7 @@ function tokenizer(input, options) {
|
|
|
22428
22455
|
return Parser.tokenizer(input, options)
|
|
22429
22456
|
}
|
|
22430
22457
|
|
|
22431
|
-
const
|
|
22458
|
+
const _acorn = /*#__PURE__*/Object.defineProperty({
|
|
22432
22459
|
__proto__: null,
|
|
22433
22460
|
Node,
|
|
22434
22461
|
Parser,
|
|
@@ -22513,13 +22540,27 @@ function resolveIdViaPlugins(source, importer, pluginDriver, moduleLoaderResolve
|
|
|
22513
22540
|
resolve: (source, importer, { assertions, custom, isEntry, skipSelf } = BLANK) => moduleLoaderResolveId(source, importer, custom, isEntry, assertions || EMPTY_OBJECT, skipSelf ? [...skip, { importer, plugin, source }] : skip)
|
|
22514
22541
|
});
|
|
22515
22542
|
}
|
|
22516
|
-
return pluginDriver.
|
|
22543
|
+
return pluginDriver.hookFirstAndGetPlugin('resolveId', [source, importer, { assertions, custom: customOptions, isEntry }], replaceContext, skipped);
|
|
22517
22544
|
}
|
|
22518
22545
|
|
|
22519
22546
|
async function resolveId(source, importer, preserveSymlinks, pluginDriver, moduleLoaderResolveId, skip, customOptions, isEntry, assertions) {
|
|
22520
22547
|
const pluginResult = await resolveIdViaPlugins(source, importer, pluginDriver, moduleLoaderResolveId, skip, customOptions, isEntry, assertions);
|
|
22521
|
-
if (pluginResult != null)
|
|
22522
|
-
|
|
22548
|
+
if (pluginResult != null) {
|
|
22549
|
+
const [resolveIdResult, plugin] = pluginResult;
|
|
22550
|
+
if (typeof resolveIdResult === 'object' && !resolveIdResult.resolvedBy) {
|
|
22551
|
+
return {
|
|
22552
|
+
...resolveIdResult,
|
|
22553
|
+
resolvedBy: plugin.name
|
|
22554
|
+
};
|
|
22555
|
+
}
|
|
22556
|
+
if (typeof resolveIdResult === 'string') {
|
|
22557
|
+
return {
|
|
22558
|
+
id: resolveIdResult,
|
|
22559
|
+
resolvedBy: plugin.name
|
|
22560
|
+
};
|
|
22561
|
+
}
|
|
22562
|
+
return resolveIdResult;
|
|
22563
|
+
}
|
|
22523
22564
|
// external modules (non-entry modules that start with neither '.' or '/')
|
|
22524
22565
|
// are skipped at this stage.
|
|
22525
22566
|
if (importer !== undefined && !isAbsolute(source) && source[0] !== '.')
|
|
@@ -23069,6 +23110,7 @@ class ModuleLoader {
|
|
|
23069
23110
|
id: resolvedId.id,
|
|
23070
23111
|
meta: resolvedId.meta || {},
|
|
23071
23112
|
moduleSideEffects: resolvedId.moduleSideEffects ?? this.hasModuleSideEffects(resolvedId.id, !!external),
|
|
23113
|
+
resolvedBy: resolvedId.resolvedBy ?? 'rollup',
|
|
23072
23114
|
syntheticNamedExports: resolvedId.syntheticNamedExports ?? false
|
|
23073
23115
|
};
|
|
23074
23116
|
}
|
|
@@ -23101,6 +23143,7 @@ class ModuleLoader {
|
|
|
23101
23143
|
id: source,
|
|
23102
23144
|
meta: {},
|
|
23103
23145
|
moduleSideEffects: this.hasModuleSideEffects(source, true),
|
|
23146
|
+
resolvedBy: 'rollup',
|
|
23104
23147
|
syntheticNamedExports: false
|
|
23105
23148
|
};
|
|
23106
23149
|
}
|
|
@@ -23551,17 +23594,18 @@ class PluginDriver {
|
|
|
23551
23594
|
}
|
|
23552
23595
|
// chains, first non-null result stops and returns
|
|
23553
23596
|
hookFirst(hookName, parameters, replaceContext, skipped) {
|
|
23554
|
-
|
|
23597
|
+
return this.hookFirstAndGetPlugin(hookName, parameters, replaceContext, skipped).then(result => result && result[0]);
|
|
23598
|
+
}
|
|
23599
|
+
// chains, first non-null result stops and returns result and last plugin
|
|
23600
|
+
async hookFirstAndGetPlugin(hookName, parameters, replaceContext, skipped) {
|
|
23555
23601
|
for (const plugin of this.getSortedPlugins(hookName)) {
|
|
23556
|
-
if (skipped
|
|
23602
|
+
if (skipped?.has(plugin))
|
|
23557
23603
|
continue;
|
|
23558
|
-
|
|
23559
|
-
|
|
23560
|
-
|
|
23561
|
-
return this.runHook(hookName, parameters, plugin, replaceContext);
|
|
23562
|
-
});
|
|
23604
|
+
const result = await this.runHook(hookName, parameters, plugin, replaceContext);
|
|
23605
|
+
if (result != null)
|
|
23606
|
+
return [result, plugin];
|
|
23563
23607
|
}
|
|
23564
|
-
return
|
|
23608
|
+
return null;
|
|
23565
23609
|
}
|
|
23566
23610
|
// chains synchronously, first non-null result stops and returns
|
|
23567
23611
|
hookFirstSync(hookName, parameters, replaceContext) {
|
|
@@ -24024,26 +24068,11 @@ async function catchUnfinishedHookActions(pluginDriver, callback) {
|
|
|
24024
24068
|
return result;
|
|
24025
24069
|
}
|
|
24026
24070
|
|
|
24027
|
-
var lib = {};
|
|
24028
|
-
|
|
24029
|
-
const require$$0 = /*@__PURE__*/getAugmentedNamespace(acorn);
|
|
24030
|
-
|
|
24031
|
-
Object.defineProperty(lib, "__esModule", {
|
|
24032
|
-
value: true
|
|
24033
|
-
});
|
|
24034
|
-
var importAssertions_1 = lib.importAssertions = importAssertions;
|
|
24035
|
-
|
|
24036
|
-
var _acorn = _interopRequireWildcard(require$$0);
|
|
24037
|
-
|
|
24038
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
24039
|
-
|
|
24040
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
24041
|
-
|
|
24042
24071
|
const leftCurlyBrace = "{".charCodeAt(0);
|
|
24043
24072
|
const space = " ".charCodeAt(0);
|
|
24073
|
+
|
|
24044
24074
|
const keyword = "assert";
|
|
24045
|
-
const FUNC_STATEMENT = 1,
|
|
24046
|
-
FUNC_NULLABLE_ID = 4;
|
|
24075
|
+
const FUNC_STATEMENT = 1, FUNC_NULLABLE_ID = 4;
|
|
24047
24076
|
|
|
24048
24077
|
function importAssertions(Parser) {
|
|
24049
24078
|
// Use supplied version acorn version if present, to avoid
|
|
@@ -24052,10 +24081,8 @@ function importAssertions(Parser) {
|
|
|
24052
24081
|
// its own internal version of acorn and thereby sidesteps
|
|
24053
24082
|
// the package manager.
|
|
24054
24083
|
const acorn = Parser.acorn || _acorn;
|
|
24055
|
-
const {
|
|
24056
|
-
|
|
24057
|
-
TokenType
|
|
24058
|
-
} = acorn;
|
|
24084
|
+
const { tokTypes: tt, TokenType } = acorn;
|
|
24085
|
+
|
|
24059
24086
|
return class extends Parser {
|
|
24060
24087
|
constructor(...args) {
|
|
24061
24088
|
super(...args);
|
|
@@ -24070,21 +24097,19 @@ function importAssertions(Parser) {
|
|
|
24070
24097
|
if (this.type !== t) {
|
|
24071
24098
|
this.unexpected();
|
|
24072
24099
|
}
|
|
24073
|
-
|
|
24074
24100
|
this.next();
|
|
24075
24101
|
}
|
|
24076
24102
|
|
|
24077
24103
|
readToken(code) {
|
|
24078
24104
|
let i = 0;
|
|
24079
|
-
|
|
24080
24105
|
for (; i < keyword.length; i++) {
|
|
24081
24106
|
if (this._codeAt(this.pos + i) !== keyword.charCodeAt(i)) {
|
|
24082
24107
|
return super.readToken(code);
|
|
24083
24108
|
}
|
|
24084
|
-
}
|
|
24085
|
-
// ie `assert{...` or `assert {...`
|
|
24086
|
-
|
|
24109
|
+
}
|
|
24087
24110
|
|
|
24111
|
+
// ensure that the keyword is at the correct location
|
|
24112
|
+
// ie `assert{...` or `assert {...`
|
|
24088
24113
|
for (;; i++) {
|
|
24089
24114
|
if (this._codeAt(this.pos + i) === leftCurlyBrace) {
|
|
24090
24115
|
// Found '{'
|
|
@@ -24095,11 +24120,11 @@ function importAssertions(Parser) {
|
|
|
24095
24120
|
} else {
|
|
24096
24121
|
return super.readToken(code);
|
|
24097
24122
|
}
|
|
24098
|
-
}
|
|
24123
|
+
}
|
|
24124
|
+
|
|
24125
|
+
// If we're inside a dynamic import expression we'll parse
|
|
24099
24126
|
// the `assert` keyword as a standard object property name
|
|
24100
24127
|
// ie `import(""./foo.json", { assert: { type: "json" } })`
|
|
24101
|
-
|
|
24102
|
-
|
|
24103
24128
|
if (this.type.label === "{") {
|
|
24104
24129
|
return super.readToken(code);
|
|
24105
24130
|
}
|
|
@@ -24110,24 +24135,22 @@ function importAssertions(Parser) {
|
|
|
24110
24135
|
|
|
24111
24136
|
parseDynamicImport(node) {
|
|
24112
24137
|
this.next(); // skip `(`
|
|
24113
|
-
// Parse node.source.
|
|
24114
24138
|
|
|
24139
|
+
// Parse node.source.
|
|
24115
24140
|
node.source = this.parseMaybeAssign();
|
|
24116
24141
|
|
|
24117
24142
|
if (this.eat(tt.comma)) {
|
|
24118
24143
|
const obj = this.parseObj(false);
|
|
24119
24144
|
node.arguments = [obj];
|
|
24120
24145
|
}
|
|
24121
|
-
|
|
24122
24146
|
this._eat(tt.parenR);
|
|
24123
|
-
|
|
24124
24147
|
return this.finishNode(node, "ImportExpression");
|
|
24125
|
-
}
|
|
24126
|
-
|
|
24148
|
+
}
|
|
24127
24149
|
|
|
24150
|
+
// ported from acorn/src/statement.js pp.parseExport
|
|
24128
24151
|
parseExport(node, exports) {
|
|
24129
|
-
this.next();
|
|
24130
|
-
|
|
24152
|
+
this.next();
|
|
24153
|
+
// export * from '...'
|
|
24131
24154
|
if (this.eat(tt.star)) {
|
|
24132
24155
|
if (this.options.ecmaVersion >= 11) {
|
|
24133
24156
|
if (this.eatContextual("as")) {
|
|
@@ -24137,41 +24160,28 @@ function importAssertions(Parser) {
|
|
|
24137
24160
|
node.exported = null;
|
|
24138
24161
|
}
|
|
24139
24162
|
}
|
|
24140
|
-
|
|
24141
24163
|
this.expectContextual("from");
|
|
24142
|
-
|
|
24143
|
-
if (this.type !== tt.string) {
|
|
24144
|
-
this.unexpected();
|
|
24145
|
-
}
|
|
24146
|
-
|
|
24164
|
+
if (this.type !== tt.string) { this.unexpected(); }
|
|
24147
24165
|
node.source = this.parseExprAtom();
|
|
24148
24166
|
|
|
24149
24167
|
if (this.type === this.assertToken) {
|
|
24150
24168
|
this.next();
|
|
24151
24169
|
const assertions = this.parseImportAssertions();
|
|
24152
|
-
|
|
24153
24170
|
if (assertions) {
|
|
24154
24171
|
node.assertions = assertions;
|
|
24155
24172
|
}
|
|
24156
24173
|
}
|
|
24157
24174
|
|
|
24158
24175
|
this.semicolon();
|
|
24159
|
-
return this.finishNode(node, "ExportAllDeclaration")
|
|
24176
|
+
return this.finishNode(node, "ExportAllDeclaration")
|
|
24160
24177
|
}
|
|
24161
|
-
|
|
24162
|
-
if (this.eat(tt._default)) {
|
|
24163
|
-
// export default ...
|
|
24178
|
+
if (this.eat(tt._default)) { // export default ...
|
|
24164
24179
|
this.checkExport(exports, "default", this.lastTokStart);
|
|
24165
24180
|
var isAsync;
|
|
24166
|
-
|
|
24167
24181
|
if (this.type === tt._function || (isAsync = this.isAsyncFunction())) {
|
|
24168
24182
|
var fNode = this.startNode();
|
|
24169
24183
|
this.next();
|
|
24170
|
-
|
|
24171
|
-
if (isAsync) {
|
|
24172
|
-
this.next();
|
|
24173
|
-
}
|
|
24174
|
-
|
|
24184
|
+
if (isAsync) { this.next(); }
|
|
24175
24185
|
node.declaration = this.parseFunction(fNode, FUNC_STATEMENT | FUNC_NULLABLE_ID, false, isAsync);
|
|
24176
24186
|
} else if (this.type === tt._class) {
|
|
24177
24187
|
var cNode = this.startNode();
|
|
@@ -24180,38 +24190,27 @@ function importAssertions(Parser) {
|
|
|
24180
24190
|
node.declaration = this.parseMaybeAssign();
|
|
24181
24191
|
this.semicolon();
|
|
24182
24192
|
}
|
|
24183
|
-
|
|
24184
|
-
|
|
24185
|
-
|
|
24186
|
-
|
|
24187
|
-
|
|
24193
|
+
return this.finishNode(node, "ExportDefaultDeclaration")
|
|
24194
|
+
}
|
|
24195
|
+
// export var|const|let|function|class ...
|
|
24188
24196
|
if (this.shouldParseExportStatement()) {
|
|
24189
24197
|
node.declaration = this.parseStatement(null);
|
|
24190
|
-
|
|
24191
|
-
|
|
24192
|
-
|
|
24193
|
-
|
|
24194
|
-
this.checkExport(exports, node.declaration.id.name, node.declaration.id.start);
|
|
24195
|
-
}
|
|
24196
|
-
|
|
24198
|
+
if (node.declaration.type === "VariableDeclaration")
|
|
24199
|
+
{ this.checkVariableExport(exports, node.declaration.declarations); }
|
|
24200
|
+
else
|
|
24201
|
+
{ this.checkExport(exports, node.declaration.id.name, node.declaration.id.start); }
|
|
24197
24202
|
node.specifiers = [];
|
|
24198
24203
|
node.source = null;
|
|
24199
|
-
} else {
|
|
24200
|
-
// export { x, y as z } [from '...']
|
|
24204
|
+
} else { // export { x, y as z } [from '...']
|
|
24201
24205
|
node.declaration = null;
|
|
24202
24206
|
node.specifiers = this.parseExportSpecifiers(exports);
|
|
24203
|
-
|
|
24204
24207
|
if (this.eatContextual("from")) {
|
|
24205
|
-
if (this.type !== tt.string) {
|
|
24206
|
-
this.unexpected();
|
|
24207
|
-
}
|
|
24208
|
-
|
|
24208
|
+
if (this.type !== tt.string) { this.unexpected(); }
|
|
24209
24209
|
node.source = this.parseExprAtom();
|
|
24210
24210
|
|
|
24211
24211
|
if (this.type === this.assertToken) {
|
|
24212
24212
|
this.next();
|
|
24213
24213
|
const assertions = this.parseImportAssertions();
|
|
24214
|
-
|
|
24215
24214
|
if (assertions) {
|
|
24216
24215
|
node.assertions = assertions;
|
|
24217
24216
|
}
|
|
@@ -24220,52 +24219,47 @@ function importAssertions(Parser) {
|
|
|
24220
24219
|
for (var i = 0, list = node.specifiers; i < list.length; i += 1) {
|
|
24221
24220
|
// check for keywords used as local names
|
|
24222
24221
|
var spec = list[i];
|
|
24223
|
-
this.checkUnreserved(spec.local); // check if export is defined
|
|
24224
24222
|
|
|
24223
|
+
this.checkUnreserved(spec.local);
|
|
24224
|
+
// check if export is defined
|
|
24225
24225
|
this.checkLocalExport(spec.local);
|
|
24226
24226
|
}
|
|
24227
24227
|
|
|
24228
24228
|
node.source = null;
|
|
24229
24229
|
}
|
|
24230
|
-
|
|
24231
24230
|
this.semicolon();
|
|
24232
24231
|
}
|
|
24233
|
-
|
|
24234
|
-
return this.finishNode(node, "ExportNamedDeclaration");
|
|
24232
|
+
return this.finishNode(node, "ExportNamedDeclaration")
|
|
24235
24233
|
}
|
|
24236
24234
|
|
|
24237
24235
|
parseImport(node) {
|
|
24238
|
-
this.next();
|
|
24239
|
-
|
|
24236
|
+
this.next();
|
|
24237
|
+
// import '...'
|
|
24240
24238
|
if (this.type === tt.string) {
|
|
24241
24239
|
node.specifiers = [];
|
|
24242
24240
|
node.source = this.parseExprAtom();
|
|
24243
24241
|
} else {
|
|
24244
24242
|
node.specifiers = this.parseImportSpecifiers();
|
|
24245
24243
|
this.expectContextual("from");
|
|
24246
|
-
node.source =
|
|
24244
|
+
node.source =
|
|
24245
|
+
this.type === tt.string ? this.parseExprAtom() : this.unexpected();
|
|
24247
24246
|
}
|
|
24248
24247
|
|
|
24249
24248
|
if (this.type === this.assertToken) {
|
|
24250
24249
|
this.next();
|
|
24251
24250
|
const assertions = this.parseImportAssertions();
|
|
24252
|
-
|
|
24253
24251
|
if (assertions) {
|
|
24254
24252
|
node.assertions = assertions;
|
|
24255
24253
|
}
|
|
24256
24254
|
}
|
|
24257
|
-
|
|
24258
24255
|
this.semicolon();
|
|
24259
24256
|
return this.finishNode(node, "ImportDeclaration");
|
|
24260
24257
|
}
|
|
24261
24258
|
|
|
24262
24259
|
parseImportAssertions() {
|
|
24263
24260
|
this._eat(tt.braceL);
|
|
24264
|
-
|
|
24265
24261
|
const attrs = this.parseAssertEntries();
|
|
24266
|
-
|
|
24267
24262
|
this._eat(tt.braceR);
|
|
24268
|
-
|
|
24269
24263
|
return attrs;
|
|
24270
24264
|
}
|
|
24271
24265
|
|
|
@@ -24278,38 +24272,40 @@ function importAssertions(Parser) {
|
|
|
24278
24272
|
break;
|
|
24279
24273
|
}
|
|
24280
24274
|
|
|
24281
|
-
const node = this.startNode();
|
|
24275
|
+
const node = this.startNode();
|
|
24282
24276
|
|
|
24277
|
+
// parse AssertionKey : IdentifierName, StringLiteral
|
|
24283
24278
|
let assertionKeyNode;
|
|
24284
|
-
|
|
24285
24279
|
if (this.type === tt.string) {
|
|
24286
24280
|
assertionKeyNode = this.parseLiteral(this.value);
|
|
24287
24281
|
} else {
|
|
24288
24282
|
assertionKeyNode = this.parseIdent(true);
|
|
24289
24283
|
}
|
|
24290
|
-
|
|
24291
24284
|
this.next();
|
|
24292
|
-
node.key = assertionKeyNode;
|
|
24285
|
+
node.key = assertionKeyNode;
|
|
24286
|
+
|
|
24287
|
+
// check if we already have an entry for an attribute
|
|
24293
24288
|
// if a duplicate entry is found, throw an error
|
|
24294
24289
|
// for now this logic will come into play only when someone declares `type` twice
|
|
24295
|
-
|
|
24296
24290
|
if (attrNames.has(node.key.name)) {
|
|
24297
24291
|
this.raise(this.pos, "Duplicated key in assertions");
|
|
24298
24292
|
}
|
|
24299
|
-
|
|
24300
24293
|
attrNames.add(node.key.name);
|
|
24301
24294
|
|
|
24302
24295
|
if (this.type !== tt.string) {
|
|
24303
|
-
this.raise(
|
|
24296
|
+
this.raise(
|
|
24297
|
+
this.pos,
|
|
24298
|
+
"Only string is supported as an assertion value"
|
|
24299
|
+
);
|
|
24304
24300
|
}
|
|
24305
24301
|
|
|
24306
24302
|
node.value = this.parseLiteral(this.value);
|
|
24303
|
+
|
|
24307
24304
|
attrs.push(this.finishNode(node, "ImportAttribute"));
|
|
24308
24305
|
} while (this.eat(tt.comma));
|
|
24309
24306
|
|
|
24310
24307
|
return attrs;
|
|
24311
24308
|
}
|
|
24312
|
-
|
|
24313
24309
|
};
|
|
24314
24310
|
}
|
|
24315
24311
|
|
|
@@ -24463,14 +24459,12 @@ const getOnwarn = (config) => {
|
|
|
24463
24459
|
: defaultOnWarn;
|
|
24464
24460
|
};
|
|
24465
24461
|
const getAcorn = (config) => ({
|
|
24466
|
-
allowAwaitOutsideFunction: true,
|
|
24467
24462
|
ecmaVersion: 'latest',
|
|
24468
|
-
preserveParens: false,
|
|
24469
24463
|
sourceType: 'module',
|
|
24470
24464
|
...config.acorn
|
|
24471
24465
|
});
|
|
24472
24466
|
const getAcornInjectPlugins = (config) => [
|
|
24473
|
-
|
|
24467
|
+
importAssertions,
|
|
24474
24468
|
...ensureArray(config.acornInjectPlugins)
|
|
24475
24469
|
];
|
|
24476
24470
|
const getCache = (config) => config.cache?.cache || config.cache;
|
|
@@ -24537,7 +24531,7 @@ const getModuleContext = (config, context) => {
|
|
|
24537
24531
|
for (const [key, moduleContext] of Object.entries(configModuleContext)) {
|
|
24538
24532
|
contextByModuleId[resolve(key)] = moduleContext;
|
|
24539
24533
|
}
|
|
24540
|
-
return id => contextByModuleId[id]
|
|
24534
|
+
return id => contextByModuleId[id] ?? context;
|
|
24541
24535
|
}
|
|
24542
24536
|
return () => context;
|
|
24543
24537
|
};
|