vite 3.2.0 → 3.2.2
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 -82
- package/dist/node/chunks/{dep-1180cbc3.js → dep-6873f27c.js} +1 -1
- package/dist/node/chunks/{dep-61d2428a.js → dep-c842e491.js} +134 -1851
- package/dist/node/cli.js +6 -8
- package/dist/node/constants.js +1 -1
- package/dist/node/index.d.ts +1 -1
- package/dist/node/index.js +2 -4
- package/dist/node-cjs/publicUtils.cjs +8 -9
- package/package.json +3 -5
- package/src/client/client.ts +0 -593
- package/src/client/env.ts +0 -29
- package/src/client/overlay.ts +0 -208
- package/src/client/tsconfig.json +0 -10
|
@@ -1,30 +1,28 @@
|
|
|
1
|
-
import fs$l, {
|
|
2
|
-
import path$n, { posix as posix$2, isAbsolute as isAbsolute$2, resolve as resolve$
|
|
3
|
-
import {
|
|
1
|
+
import fs$l, { promises as promises$2 } from 'node:fs';
|
|
2
|
+
import path$n, { posix as posix$2, isAbsolute as isAbsolute$2, resolve as resolve$6, join as join$2, relative as relative$2, dirname as dirname$2, basename as basename$2, extname as extname$1 } from 'node:path';
|
|
3
|
+
import { URL as URL$3, URLSearchParams, parse as parse$k, pathToFileURL as pathToFileURL$1 } from 'node:url';
|
|
4
4
|
import { performance } from 'node:perf_hooks';
|
|
5
|
-
import {
|
|
5
|
+
import { createRequire as createRequire$1, builtinModules } from 'node:module';
|
|
6
6
|
import require$$0$3 from 'tty';
|
|
7
7
|
import { transform as transform$2, build as build$3, formatMessages } from 'esbuild';
|
|
8
|
-
import
|
|
9
|
-
import process$1 from 'node:process';
|
|
10
|
-
import { format as format$2, inspect, promisify as promisify$4 } from 'node:util';
|
|
11
|
-
import require$$0$4, { sep, resolve as resolve$5, posix as posix$1, relative as relative$1, basename as basename$1, extname, dirname as dirname$1, join as join$1, win32 as win32$1, isAbsolute as isAbsolute$1, normalize } from 'path';
|
|
8
|
+
import require$$0$4, { sep, resolve as resolve$4, posix as posix$1, relative as relative$1, basename as basename$1, extname, dirname as dirname$1, join as join$1, win32 as win32$1, isAbsolute as isAbsolute$1, normalize } from 'path';
|
|
12
9
|
import * as require$$0$2 from 'fs';
|
|
13
|
-
import require$$0__default, { existsSync, readFileSync, statSync as statSync$
|
|
10
|
+
import require$$0__default, { existsSync, readFileSync, statSync as statSync$1, promises as promises$1, readdirSync } from 'fs';
|
|
14
11
|
import require$$0$5 from 'events';
|
|
15
|
-
import assert$
|
|
16
|
-
import require$$0$6, { format as format$
|
|
12
|
+
import assert$1 from 'assert';
|
|
13
|
+
import require$$0$6, { format as format$2, inspect } from 'util';
|
|
17
14
|
import require$$3$1 from 'net';
|
|
18
|
-
import require$$0$9, { pathToFileURL
|
|
15
|
+
import require$$0$9, { pathToFileURL } from 'url';
|
|
19
16
|
import require$$1$1 from 'http';
|
|
20
17
|
import require$$0$7 from 'stream';
|
|
21
18
|
import require$$2 from 'os';
|
|
22
19
|
import require$$2$1 from 'child_process';
|
|
23
20
|
import os$3 from 'node:os';
|
|
24
21
|
import { createHash as createHash$2 } from 'node:crypto';
|
|
22
|
+
import { promisify as promisify$4 } from 'node:util';
|
|
25
23
|
import { promises } from 'node:dns';
|
|
26
|
-
import resolve$
|
|
27
|
-
import { CLIENT_ENTRY, OPTIMIZABLE_ENTRY_RE, DEFAULT_EXTENSIONS as DEFAULT_EXTENSIONS$1, wildcardHosts, loopbackHosts, VALID_ID_PREFIX, NULL_BYTE_PLACEHOLDER, FS_PREFIX, CLIENT_PUBLIC_PATH, ENV_PUBLIC_PATH, ENV_ENTRY,
|
|
24
|
+
import resolve$5 from 'resolve';
|
|
25
|
+
import { CLIENT_ENTRY, OPTIMIZABLE_ENTRY_RE, DEFAULT_EXTENSIONS as DEFAULT_EXTENSIONS$1, wildcardHosts, loopbackHosts, VALID_ID_PREFIX, NULL_BYTE_PLACEHOLDER, FS_PREFIX, CLIENT_PUBLIC_PATH, ENV_PUBLIC_PATH, ENV_ENTRY, DEFAULT_MAIN_FIELDS, SPECIAL_QUERY_RE, DEP_VERSION_RE, KNOWN_ASSET_TYPES, CLIENT_DIR, JS_TYPES_RE, ESBUILD_MODULES_TARGET, VERSION, VITE_PACKAGE_DIR, DEFAULT_ASSETS_RE, DEFAULT_CONFIG_FILES } from '../constants.js';
|
|
28
26
|
import require$$5 from 'crypto';
|
|
29
27
|
import { Buffer as Buffer$1 } from 'node:buffer';
|
|
30
28
|
import require$$0$8, { createRequire as createRequire$2 } from 'module';
|
|
@@ -215,1761 +213,6 @@ function alias$1(options = {}) {
|
|
|
215
213
|
};
|
|
216
214
|
}
|
|
217
215
|
|
|
218
|
-
// Manually “tree shaken” from:
|
|
219
|
-
|
|
220
|
-
const reader$2 = {read: read$5};
|
|
221
|
-
var packageJsonReader = reader$2;
|
|
222
|
-
|
|
223
|
-
/**
|
|
224
|
-
* @param {string} jsonPath
|
|
225
|
-
* @returns {{string: string|undefined}}
|
|
226
|
-
*/
|
|
227
|
-
function read$5(jsonPath) {
|
|
228
|
-
try {
|
|
229
|
-
const string = fs$l.readFileSync(
|
|
230
|
-
path$n.toNamespacedPath(path$n.join(path$n.dirname(jsonPath), 'package.json')),
|
|
231
|
-
'utf8'
|
|
232
|
-
);
|
|
233
|
-
return {string}
|
|
234
|
-
} catch (error) {
|
|
235
|
-
const exception = /** @type {ErrnoException} */ (error);
|
|
236
|
-
|
|
237
|
-
if (exception.code === 'ENOENT') {
|
|
238
|
-
return {string: undefined}
|
|
239
|
-
// Throw all other errors.
|
|
240
|
-
/* c8 ignore next 4 */
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
throw exception
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
/**
|
|
248
|
-
* @typedef ErrnoExceptionFields
|
|
249
|
-
* @property {number|undefined} [errnode]
|
|
250
|
-
* @property {string|undefined} [code]
|
|
251
|
-
* @property {string|undefined} [path]
|
|
252
|
-
* @property {string|undefined} [syscall]
|
|
253
|
-
* @property {string|undefined} [url]
|
|
254
|
-
*
|
|
255
|
-
* @typedef {Error & ErrnoExceptionFields} ErrnoException
|
|
256
|
-
*/
|
|
257
|
-
|
|
258
|
-
const isWindows$6 = process$1.platform === 'win32';
|
|
259
|
-
|
|
260
|
-
const own$2 = {}.hasOwnProperty;
|
|
261
|
-
|
|
262
|
-
const codes$1 = {};
|
|
263
|
-
|
|
264
|
-
/** @type {Map<string, MessageFunction|string>} */
|
|
265
|
-
const messages$1 = new Map();
|
|
266
|
-
const nodeInternalPrefix$1 = '__node_internal_';
|
|
267
|
-
/** @type {number} */
|
|
268
|
-
let userStackTraceLimit$1;
|
|
269
|
-
|
|
270
|
-
codes$1.ERR_INVALID_MODULE_SPECIFIER = createError$1(
|
|
271
|
-
'ERR_INVALID_MODULE_SPECIFIER',
|
|
272
|
-
/**
|
|
273
|
-
* @param {string} request
|
|
274
|
-
* @param {string} reason
|
|
275
|
-
* @param {string} [base]
|
|
276
|
-
*/
|
|
277
|
-
(request, reason, base = undefined) => {
|
|
278
|
-
return `Invalid module "${request}" ${reason}${
|
|
279
|
-
base ? ` imported from ${base}` : ''
|
|
280
|
-
}`
|
|
281
|
-
},
|
|
282
|
-
TypeError
|
|
283
|
-
);
|
|
284
|
-
|
|
285
|
-
codes$1.ERR_INVALID_PACKAGE_CONFIG = createError$1(
|
|
286
|
-
'ERR_INVALID_PACKAGE_CONFIG',
|
|
287
|
-
/**
|
|
288
|
-
* @param {string} path
|
|
289
|
-
* @param {string} [base]
|
|
290
|
-
* @param {string} [message]
|
|
291
|
-
*/
|
|
292
|
-
(path, base, message) => {
|
|
293
|
-
return `Invalid package config ${path}${
|
|
294
|
-
base ? ` while importing ${base}` : ''
|
|
295
|
-
}${message ? `. ${message}` : ''}`
|
|
296
|
-
},
|
|
297
|
-
Error
|
|
298
|
-
);
|
|
299
|
-
|
|
300
|
-
codes$1.ERR_INVALID_PACKAGE_TARGET = createError$1(
|
|
301
|
-
'ERR_INVALID_PACKAGE_TARGET',
|
|
302
|
-
/**
|
|
303
|
-
* @param {string} pkgPath
|
|
304
|
-
* @param {string} key
|
|
305
|
-
* @param {unknown} target
|
|
306
|
-
* @param {boolean} [isImport=false]
|
|
307
|
-
* @param {string} [base]
|
|
308
|
-
*/
|
|
309
|
-
(pkgPath, key, target, isImport = false, base = undefined) => {
|
|
310
|
-
const relError =
|
|
311
|
-
typeof target === 'string' &&
|
|
312
|
-
!isImport &&
|
|
313
|
-
target.length > 0 &&
|
|
314
|
-
!target.startsWith('./');
|
|
315
|
-
if (key === '.') {
|
|
316
|
-
assert$1(isImport === false);
|
|
317
|
-
return (
|
|
318
|
-
`Invalid "exports" main target ${JSON.stringify(target)} defined ` +
|
|
319
|
-
`in the package config ${pkgPath}package.json${
|
|
320
|
-
base ? ` imported from ${base}` : ''
|
|
321
|
-
}${relError ? '; targets must start with "./"' : ''}`
|
|
322
|
-
)
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
return `Invalid "${
|
|
326
|
-
isImport ? 'imports' : 'exports'
|
|
327
|
-
}" target ${JSON.stringify(
|
|
328
|
-
target
|
|
329
|
-
)} defined for '${key}' in the package config ${pkgPath}package.json${
|
|
330
|
-
base ? ` imported from ${base}` : ''
|
|
331
|
-
}${relError ? '; targets must start with "./"' : ''}`
|
|
332
|
-
},
|
|
333
|
-
Error
|
|
334
|
-
);
|
|
335
|
-
|
|
336
|
-
codes$1.ERR_MODULE_NOT_FOUND = createError$1(
|
|
337
|
-
'ERR_MODULE_NOT_FOUND',
|
|
338
|
-
/**
|
|
339
|
-
* @param {string} path
|
|
340
|
-
* @param {string} base
|
|
341
|
-
* @param {string} [type]
|
|
342
|
-
*/
|
|
343
|
-
(path, base, type = 'package') => {
|
|
344
|
-
return `Cannot find ${type} '${path}' imported from ${base}`
|
|
345
|
-
},
|
|
346
|
-
Error
|
|
347
|
-
);
|
|
348
|
-
|
|
349
|
-
codes$1.ERR_NETWORK_IMPORT_DISALLOWED = createError$1(
|
|
350
|
-
'ERR_NETWORK_IMPORT_DISALLOWED',
|
|
351
|
-
"import of '%s' by %s is not supported: %s",
|
|
352
|
-
Error
|
|
353
|
-
);
|
|
354
|
-
|
|
355
|
-
codes$1.ERR_PACKAGE_IMPORT_NOT_DEFINED = createError$1(
|
|
356
|
-
'ERR_PACKAGE_IMPORT_NOT_DEFINED',
|
|
357
|
-
/**
|
|
358
|
-
* @param {string} specifier
|
|
359
|
-
* @param {string} packagePath
|
|
360
|
-
* @param {string} base
|
|
361
|
-
*/
|
|
362
|
-
(specifier, packagePath, base) => {
|
|
363
|
-
return `Package import specifier "${specifier}" is not defined${
|
|
364
|
-
packagePath ? ` in package ${packagePath}package.json` : ''
|
|
365
|
-
} imported from ${base}`
|
|
366
|
-
},
|
|
367
|
-
TypeError
|
|
368
|
-
);
|
|
369
|
-
|
|
370
|
-
codes$1.ERR_PACKAGE_PATH_NOT_EXPORTED = createError$1(
|
|
371
|
-
'ERR_PACKAGE_PATH_NOT_EXPORTED',
|
|
372
|
-
/**
|
|
373
|
-
* @param {string} pkgPath
|
|
374
|
-
* @param {string} subpath
|
|
375
|
-
* @param {string} [base]
|
|
376
|
-
*/
|
|
377
|
-
(pkgPath, subpath, base = undefined) => {
|
|
378
|
-
if (subpath === '.')
|
|
379
|
-
return `No "exports" main defined in ${pkgPath}package.json${
|
|
380
|
-
base ? ` imported from ${base}` : ''
|
|
381
|
-
}`
|
|
382
|
-
return `Package subpath '${subpath}' is not defined by "exports" in ${pkgPath}package.json${
|
|
383
|
-
base ? ` imported from ${base}` : ''
|
|
384
|
-
}`
|
|
385
|
-
},
|
|
386
|
-
Error
|
|
387
|
-
);
|
|
388
|
-
|
|
389
|
-
codes$1.ERR_UNSUPPORTED_DIR_IMPORT = createError$1(
|
|
390
|
-
'ERR_UNSUPPORTED_DIR_IMPORT',
|
|
391
|
-
"Directory import '%s' is not supported " +
|
|
392
|
-
'resolving ES modules imported from %s',
|
|
393
|
-
Error
|
|
394
|
-
);
|
|
395
|
-
|
|
396
|
-
codes$1.ERR_UNKNOWN_FILE_EXTENSION = createError$1(
|
|
397
|
-
'ERR_UNKNOWN_FILE_EXTENSION',
|
|
398
|
-
/**
|
|
399
|
-
* @param {string} ext
|
|
400
|
-
* @param {string} path
|
|
401
|
-
*/
|
|
402
|
-
(ext, path) => {
|
|
403
|
-
return `Unknown file extension "${ext}" for ${path}`
|
|
404
|
-
},
|
|
405
|
-
TypeError
|
|
406
|
-
);
|
|
407
|
-
|
|
408
|
-
codes$1.ERR_INVALID_ARG_VALUE = createError$1(
|
|
409
|
-
'ERR_INVALID_ARG_VALUE',
|
|
410
|
-
/**
|
|
411
|
-
* @param {string} name
|
|
412
|
-
* @param {unknown} value
|
|
413
|
-
* @param {string} [reason='is invalid']
|
|
414
|
-
*/
|
|
415
|
-
(name, value, reason = 'is invalid') => {
|
|
416
|
-
let inspected = inspect(value);
|
|
417
|
-
|
|
418
|
-
if (inspected.length > 128) {
|
|
419
|
-
inspected = `${inspected.slice(0, 128)}...`;
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
const type = name.includes('.') ? 'property' : 'argument';
|
|
423
|
-
|
|
424
|
-
return `The ${type} '${name}' ${reason}. Received ${inspected}`
|
|
425
|
-
},
|
|
426
|
-
TypeError
|
|
427
|
-
// Note: extra classes have been shaken out.
|
|
428
|
-
// , RangeError
|
|
429
|
-
);
|
|
430
|
-
|
|
431
|
-
codes$1.ERR_UNSUPPORTED_ESM_URL_SCHEME = createError$1(
|
|
432
|
-
'ERR_UNSUPPORTED_ESM_URL_SCHEME',
|
|
433
|
-
/**
|
|
434
|
-
* @param {URL} url
|
|
435
|
-
* @param {Array<string>} supported
|
|
436
|
-
*/
|
|
437
|
-
(url, supported) => {
|
|
438
|
-
let message = `Only URLs with a scheme in: ${supported.join(
|
|
439
|
-
', '
|
|
440
|
-
)} are supported by the default ESM loader`;
|
|
441
|
-
// Let message =
|
|
442
|
-
// 'Only file and data URLs are supported by the default ESM loader'
|
|
443
|
-
|
|
444
|
-
if (isWindows$6 && url.protocol.length === 2) {
|
|
445
|
-
message += '. On Windows, absolute paths must be valid file:// URLs';
|
|
446
|
-
}
|
|
447
|
-
|
|
448
|
-
message += `. Received protocol '${url.protocol}'`;
|
|
449
|
-
return message
|
|
450
|
-
},
|
|
451
|
-
Error
|
|
452
|
-
);
|
|
453
|
-
|
|
454
|
-
/**
|
|
455
|
-
* Utility function for registering the error codes. Only used here. Exported
|
|
456
|
-
* *only* to allow for testing.
|
|
457
|
-
* @param {string} sym
|
|
458
|
-
* @param {MessageFunction|string} value
|
|
459
|
-
* @param {ErrorConstructor} def
|
|
460
|
-
* @returns {new (...args: Array<any>) => Error}
|
|
461
|
-
*/
|
|
462
|
-
function createError$1(sym, value, def) {
|
|
463
|
-
// Special case for SystemError that formats the error message differently
|
|
464
|
-
// The SystemErrors only have SystemError as their base classes.
|
|
465
|
-
messages$1.set(sym, value);
|
|
466
|
-
|
|
467
|
-
return makeNodeErrorWithCode$1(def, sym)
|
|
468
|
-
}
|
|
469
|
-
|
|
470
|
-
/**
|
|
471
|
-
* @param {ErrorConstructor} Base
|
|
472
|
-
* @param {string} key
|
|
473
|
-
* @returns {ErrorConstructor}
|
|
474
|
-
*/
|
|
475
|
-
function makeNodeErrorWithCode$1(Base, key) {
|
|
476
|
-
// @ts-expect-error It’s a Node error.
|
|
477
|
-
return NodeError
|
|
478
|
-
/**
|
|
479
|
-
* @param {Array<unknown>} args
|
|
480
|
-
*/
|
|
481
|
-
function NodeError(...args) {
|
|
482
|
-
const limit = Error.stackTraceLimit;
|
|
483
|
-
if (isErrorStackTraceLimitWritable$1()) Error.stackTraceLimit = 0;
|
|
484
|
-
const error = new Base();
|
|
485
|
-
// Reset the limit and setting the name property.
|
|
486
|
-
if (isErrorStackTraceLimitWritable$1()) Error.stackTraceLimit = limit;
|
|
487
|
-
const message = getMessage$1(key, args, error);
|
|
488
|
-
Object.defineProperties(error, {
|
|
489
|
-
// Note: no need to implement `kIsNodeError` symbol, would be hard,
|
|
490
|
-
// probably.
|
|
491
|
-
message: {
|
|
492
|
-
value: message,
|
|
493
|
-
enumerable: false,
|
|
494
|
-
writable: true,
|
|
495
|
-
configurable: true
|
|
496
|
-
},
|
|
497
|
-
toString: {
|
|
498
|
-
/** @this {Error} */
|
|
499
|
-
value() {
|
|
500
|
-
return `${this.name} [${key}]: ${this.message}`
|
|
501
|
-
},
|
|
502
|
-
enumerable: false,
|
|
503
|
-
writable: true,
|
|
504
|
-
configurable: true
|
|
505
|
-
}
|
|
506
|
-
});
|
|
507
|
-
|
|
508
|
-
captureLargerStackTrace$1(error);
|
|
509
|
-
// @ts-expect-error It’s a Node error.
|
|
510
|
-
error.code = key;
|
|
511
|
-
return error
|
|
512
|
-
}
|
|
513
|
-
}
|
|
514
|
-
|
|
515
|
-
/**
|
|
516
|
-
* @returns {boolean}
|
|
517
|
-
*/
|
|
518
|
-
function isErrorStackTraceLimitWritable$1() {
|
|
519
|
-
const desc = Object.getOwnPropertyDescriptor(Error, 'stackTraceLimit');
|
|
520
|
-
if (desc === undefined) {
|
|
521
|
-
return Object.isExtensible(Error)
|
|
522
|
-
}
|
|
523
|
-
|
|
524
|
-
return own$2.call(desc, 'writable') && desc.writable !== undefined
|
|
525
|
-
? desc.writable
|
|
526
|
-
: desc.set !== undefined
|
|
527
|
-
}
|
|
528
|
-
|
|
529
|
-
/**
|
|
530
|
-
* This function removes unnecessary frames from Node.js core errors.
|
|
531
|
-
* @template {(...args: Array<any>) => unknown} T
|
|
532
|
-
* @type {(fn: T) => T}
|
|
533
|
-
*/
|
|
534
|
-
function hideStackFrames$1(fn) {
|
|
535
|
-
// We rename the functions that will be hidden to cut off the stacktrace
|
|
536
|
-
// at the outermost one
|
|
537
|
-
const hidden = nodeInternalPrefix$1 + fn.name;
|
|
538
|
-
Object.defineProperty(fn, 'name', {value: hidden});
|
|
539
|
-
return fn
|
|
540
|
-
}
|
|
541
|
-
|
|
542
|
-
const captureLargerStackTrace$1 = hideStackFrames$1(
|
|
543
|
-
/**
|
|
544
|
-
* @param {Error} error
|
|
545
|
-
* @returns {Error}
|
|
546
|
-
*/
|
|
547
|
-
function (error) {
|
|
548
|
-
const stackTraceLimitIsWritable = isErrorStackTraceLimitWritable$1();
|
|
549
|
-
if (stackTraceLimitIsWritable) {
|
|
550
|
-
userStackTraceLimit$1 = Error.stackTraceLimit;
|
|
551
|
-
Error.stackTraceLimit = Number.POSITIVE_INFINITY;
|
|
552
|
-
}
|
|
553
|
-
|
|
554
|
-
Error.captureStackTrace(error);
|
|
555
|
-
|
|
556
|
-
// Reset the limit
|
|
557
|
-
if (stackTraceLimitIsWritable) Error.stackTraceLimit = userStackTraceLimit$1;
|
|
558
|
-
|
|
559
|
-
return error
|
|
560
|
-
}
|
|
561
|
-
);
|
|
562
|
-
|
|
563
|
-
/**
|
|
564
|
-
* @param {string} key
|
|
565
|
-
* @param {Array<unknown>} args
|
|
566
|
-
* @param {Error} self
|
|
567
|
-
* @returns {string}
|
|
568
|
-
*/
|
|
569
|
-
function getMessage$1(key, args, self) {
|
|
570
|
-
const message = messages$1.get(key);
|
|
571
|
-
assert$1(typeof message !== 'undefined', 'expected `message` to be found');
|
|
572
|
-
|
|
573
|
-
if (typeof message === 'function') {
|
|
574
|
-
assert$1(
|
|
575
|
-
message.length <= args.length, // Default options do not count.
|
|
576
|
-
`Code: ${key}; The provided arguments length (${args.length}) does not ` +
|
|
577
|
-
`match the required ones (${message.length}).`
|
|
578
|
-
);
|
|
579
|
-
return Reflect.apply(message, self, args)
|
|
580
|
-
}
|
|
581
|
-
|
|
582
|
-
const expectedLength = (message.match(/%[dfijoOs]/g) || []).length;
|
|
583
|
-
assert$1(
|
|
584
|
-
expectedLength === args.length,
|
|
585
|
-
`Code: ${key}; The provided arguments length (${args.length}) does not ` +
|
|
586
|
-
`match the required ones (${expectedLength}).`
|
|
587
|
-
);
|
|
588
|
-
if (args.length === 0) return message
|
|
589
|
-
|
|
590
|
-
args.unshift(message);
|
|
591
|
-
return Reflect.apply(format$2, null, args)
|
|
592
|
-
}
|
|
593
|
-
|
|
594
|
-
// Manually “tree shaken” from:
|
|
595
|
-
|
|
596
|
-
const {ERR_UNKNOWN_FILE_EXTENSION} = codes$1;
|
|
597
|
-
|
|
598
|
-
const hasOwnProperty$2 = {}.hasOwnProperty;
|
|
599
|
-
|
|
600
|
-
/** @type {Record<string, string>} */
|
|
601
|
-
const extensionFormatMap = {
|
|
602
|
-
// @ts-expect-error: hush.
|
|
603
|
-
__proto__: null,
|
|
604
|
-
'.cjs': 'commonjs',
|
|
605
|
-
'.js': 'module',
|
|
606
|
-
'.json': 'json',
|
|
607
|
-
'.mjs': 'module'
|
|
608
|
-
};
|
|
609
|
-
|
|
610
|
-
/**
|
|
611
|
-
* @param {string|null} mime
|
|
612
|
-
* @returns {string | null}
|
|
613
|
-
*/
|
|
614
|
-
function mimeToFormat(mime) {
|
|
615
|
-
if (
|
|
616
|
-
mime &&
|
|
617
|
-
/\s*(text|application)\/javascript\s*(;\s*charset=utf-?8\s*)?/i.test(mime)
|
|
618
|
-
)
|
|
619
|
-
return 'module'
|
|
620
|
-
if (mime === 'application/json') return 'json'
|
|
621
|
-
return null
|
|
622
|
-
}
|
|
623
|
-
|
|
624
|
-
/**
|
|
625
|
-
* @callback ProtocolHandler
|
|
626
|
-
* @param {URL} parsed
|
|
627
|
-
* @param {{parentURL: string}} context
|
|
628
|
-
* @param {boolean} ignoreErrors
|
|
629
|
-
* @returns {string|null}
|
|
630
|
-
*/
|
|
631
|
-
|
|
632
|
-
/**
|
|
633
|
-
* @type {Record<string, ProtocolHandler>}
|
|
634
|
-
*/
|
|
635
|
-
const protocolHandlers = Object.assign(Object.create(null), {
|
|
636
|
-
'data:': getDataProtocolModuleFormat,
|
|
637
|
-
'file:': getFileProtocolModuleFormat,
|
|
638
|
-
'http:': getHttpProtocolModuleFormat,
|
|
639
|
-
'https:': getHttpProtocolModuleFormat,
|
|
640
|
-
'node:'() {
|
|
641
|
-
return 'builtin'
|
|
642
|
-
}
|
|
643
|
-
});
|
|
644
|
-
|
|
645
|
-
/**
|
|
646
|
-
* @param {URL} parsed
|
|
647
|
-
*/
|
|
648
|
-
function getDataProtocolModuleFormat(parsed) {
|
|
649
|
-
const {1: mime} = /^([^/]+\/[^;,]+)[^,]*?(;base64)?,/.exec(
|
|
650
|
-
parsed.pathname
|
|
651
|
-
) || [null, null, null];
|
|
652
|
-
return mimeToFormat(mime)
|
|
653
|
-
}
|
|
654
|
-
|
|
655
|
-
/**
|
|
656
|
-
* @type {ProtocolHandler}
|
|
657
|
-
*/
|
|
658
|
-
function getFileProtocolModuleFormat(url, _context, ignoreErrors) {
|
|
659
|
-
const filepath = fileURLToPath(url);
|
|
660
|
-
const ext = path$n.extname(filepath);
|
|
661
|
-
if (ext === '.js') {
|
|
662
|
-
return getPackageType(url) === 'module' ? 'module' : 'commonjs'
|
|
663
|
-
}
|
|
664
|
-
|
|
665
|
-
const format = extensionFormatMap[ext];
|
|
666
|
-
if (format) return format
|
|
667
|
-
if (ignoreErrors) return null
|
|
668
|
-
|
|
669
|
-
throw new ERR_UNKNOWN_FILE_EXTENSION(ext, filepath)
|
|
670
|
-
}
|
|
671
|
-
|
|
672
|
-
function getHttpProtocolModuleFormat() {
|
|
673
|
-
// To do: HTTPS imports.
|
|
674
|
-
}
|
|
675
|
-
|
|
676
|
-
/**
|
|
677
|
-
* @param {URL} url
|
|
678
|
-
* @param {{parentURL: string}} context
|
|
679
|
-
* @returns {string|null}
|
|
680
|
-
*/
|
|
681
|
-
function defaultGetFormatWithoutErrors(url, context) {
|
|
682
|
-
if (!hasOwnProperty$2.call(protocolHandlers, url.protocol)) {
|
|
683
|
-
return null
|
|
684
|
-
}
|
|
685
|
-
|
|
686
|
-
return protocolHandlers[url.protocol](url, context, true)
|
|
687
|
-
}
|
|
688
|
-
|
|
689
|
-
// Manually “tree shaken” from:
|
|
690
|
-
|
|
691
|
-
const RegExpPrototypeSymbolReplace = RegExp.prototype[Symbol.replace];
|
|
692
|
-
|
|
693
|
-
// To do: potentially enable?
|
|
694
|
-
const experimentalNetworkImports = false;
|
|
695
|
-
|
|
696
|
-
const {
|
|
697
|
-
ERR_NETWORK_IMPORT_DISALLOWED,
|
|
698
|
-
ERR_INVALID_MODULE_SPECIFIER,
|
|
699
|
-
ERR_INVALID_PACKAGE_CONFIG,
|
|
700
|
-
ERR_INVALID_PACKAGE_TARGET,
|
|
701
|
-
ERR_MODULE_NOT_FOUND,
|
|
702
|
-
ERR_PACKAGE_IMPORT_NOT_DEFINED,
|
|
703
|
-
ERR_PACKAGE_PATH_NOT_EXPORTED,
|
|
704
|
-
ERR_UNSUPPORTED_DIR_IMPORT,
|
|
705
|
-
ERR_UNSUPPORTED_ESM_URL_SCHEME,
|
|
706
|
-
ERR_INVALID_ARG_VALUE
|
|
707
|
-
} = codes$1;
|
|
708
|
-
|
|
709
|
-
const own = {}.hasOwnProperty;
|
|
710
|
-
|
|
711
|
-
const DEFAULT_CONDITIONS = Object.freeze(['node', 'import']);
|
|
712
|
-
const DEFAULT_CONDITIONS_SET = new Set(DEFAULT_CONDITIONS);
|
|
713
|
-
|
|
714
|
-
const invalidSegmentRegEx =
|
|
715
|
-
/(^|\\|\/)((\.|%2e)(\.|%2e)?|(n|%6e|%4e)(o|%6f|%4f)(d|%64|%44)(e|%65|%45)(_|%5f)(m|%6d|%4d)(o|%6f|%4f)(d|%64|%44)(u|%75|%55)(l|%6c|%4c)(e|%65|%45)(s|%73|%53))(\\|\/|$)/i;
|
|
716
|
-
const invalidPackageNameRegEx = /^\.|%|\\/;
|
|
717
|
-
const patternRegEx = /\*/g;
|
|
718
|
-
const encodedSepRegEx = /%2f|%5c/i;
|
|
719
|
-
/** @type {Set<string>} */
|
|
720
|
-
const emittedPackageWarnings = new Set();
|
|
721
|
-
/** @type {Map<string, PackageConfig>} */
|
|
722
|
-
const packageJsonCache = new Map();
|
|
723
|
-
|
|
724
|
-
/**
|
|
725
|
-
* @param {URL} url
|
|
726
|
-
* @param {URL} packageJsonUrl
|
|
727
|
-
* @param {URL} base
|
|
728
|
-
* @param {unknown} [main]
|
|
729
|
-
* @returns {void}
|
|
730
|
-
*/
|
|
731
|
-
function emitLegacyIndexDeprecation(url, packageJsonUrl, base, main) {
|
|
732
|
-
const format = defaultGetFormatWithoutErrors(url, {parentURL: base.href});
|
|
733
|
-
if (format !== 'module') return
|
|
734
|
-
const path = fileURLToPath(url.href);
|
|
735
|
-
const pkgPath = fileURLToPath(new URL$3('.', packageJsonUrl));
|
|
736
|
-
const basePath = fileURLToPath(base);
|
|
737
|
-
if (main)
|
|
738
|
-
process$1.emitWarning(
|
|
739
|
-
`Package ${pkgPath} has a "main" field set to ${JSON.stringify(main)}, ` +
|
|
740
|
-
`excluding the full filename and extension to the resolved file at "${path.slice(
|
|
741
|
-
pkgPath.length
|
|
742
|
-
)}", imported from ${basePath}.\n Automatic extension resolution of the "main" field is` +
|
|
743
|
-
'deprecated for ES modules.',
|
|
744
|
-
'DeprecationWarning',
|
|
745
|
-
'DEP0151'
|
|
746
|
-
);
|
|
747
|
-
else
|
|
748
|
-
process$1.emitWarning(
|
|
749
|
-
`No "main" or "exports" field defined in the package.json for ${pkgPath} resolving the main entry point "${path.slice(
|
|
750
|
-
pkgPath.length
|
|
751
|
-
)}", imported from ${basePath}.\nDefault "index" lookups for the main are deprecated for ES modules.`,
|
|
752
|
-
'DeprecationWarning',
|
|
753
|
-
'DEP0151'
|
|
754
|
-
);
|
|
755
|
-
}
|
|
756
|
-
|
|
757
|
-
/**
|
|
758
|
-
* @param {Array<string>} [conditions]
|
|
759
|
-
* @returns {Set<string>}
|
|
760
|
-
*/
|
|
761
|
-
function getConditionsSet(conditions) {
|
|
762
|
-
if (conditions !== undefined && conditions !== DEFAULT_CONDITIONS) {
|
|
763
|
-
if (!Array.isArray(conditions)) {
|
|
764
|
-
throw new ERR_INVALID_ARG_VALUE(
|
|
765
|
-
'conditions',
|
|
766
|
-
conditions,
|
|
767
|
-
'expected an array'
|
|
768
|
-
)
|
|
769
|
-
}
|
|
770
|
-
|
|
771
|
-
return new Set(conditions)
|
|
772
|
-
}
|
|
773
|
-
|
|
774
|
-
return DEFAULT_CONDITIONS_SET
|
|
775
|
-
}
|
|
776
|
-
|
|
777
|
-
/**
|
|
778
|
-
* @param {string} path
|
|
779
|
-
* @returns {Stats}
|
|
780
|
-
*/
|
|
781
|
-
function tryStatSync(path) {
|
|
782
|
-
// Note: from Node 15 onwards we can use `throwIfNoEntry: false` instead.
|
|
783
|
-
try {
|
|
784
|
-
return statSync$1(path)
|
|
785
|
-
} catch {
|
|
786
|
-
return new Stats$1()
|
|
787
|
-
}
|
|
788
|
-
}
|
|
789
|
-
|
|
790
|
-
/**
|
|
791
|
-
* @param {string} path
|
|
792
|
-
* @param {string|URL} specifier Note: `specifier` is actually optional, not base.
|
|
793
|
-
* @param {URL} [base]
|
|
794
|
-
* @returns {PackageConfig}
|
|
795
|
-
*/
|
|
796
|
-
function getPackageConfig(path, specifier, base) {
|
|
797
|
-
const existing = packageJsonCache.get(path);
|
|
798
|
-
if (existing !== undefined) {
|
|
799
|
-
return existing
|
|
800
|
-
}
|
|
801
|
-
|
|
802
|
-
const source = packageJsonReader.read(path).string;
|
|
803
|
-
|
|
804
|
-
if (source === undefined) {
|
|
805
|
-
/** @type {PackageConfig} */
|
|
806
|
-
const packageConfig = {
|
|
807
|
-
pjsonPath: path,
|
|
808
|
-
exists: false,
|
|
809
|
-
main: undefined,
|
|
810
|
-
name: undefined,
|
|
811
|
-
type: 'none',
|
|
812
|
-
exports: undefined,
|
|
813
|
-
imports: undefined
|
|
814
|
-
};
|
|
815
|
-
packageJsonCache.set(path, packageConfig);
|
|
816
|
-
return packageConfig
|
|
817
|
-
}
|
|
818
|
-
|
|
819
|
-
/** @type {Record<string, unknown>} */
|
|
820
|
-
let packageJson;
|
|
821
|
-
try {
|
|
822
|
-
packageJson = JSON.parse(source);
|
|
823
|
-
} catch (error) {
|
|
824
|
-
const exception = /** @type {ErrnoException} */ (error);
|
|
825
|
-
|
|
826
|
-
throw new ERR_INVALID_PACKAGE_CONFIG(
|
|
827
|
-
path,
|
|
828
|
-
(base ? `"${specifier}" from ` : '') + fileURLToPath(base || specifier),
|
|
829
|
-
exception.message
|
|
830
|
-
)
|
|
831
|
-
}
|
|
832
|
-
|
|
833
|
-
const {exports, imports, main, name, type} = packageJson;
|
|
834
|
-
|
|
835
|
-
/** @type {PackageConfig} */
|
|
836
|
-
const packageConfig = {
|
|
837
|
-
pjsonPath: path,
|
|
838
|
-
exists: true,
|
|
839
|
-
main: typeof main === 'string' ? main : undefined,
|
|
840
|
-
name: typeof name === 'string' ? name : undefined,
|
|
841
|
-
type: type === 'module' || type === 'commonjs' ? type : 'none',
|
|
842
|
-
// @ts-expect-error Assume `Record<string, unknown>`.
|
|
843
|
-
exports,
|
|
844
|
-
// @ts-expect-error Assume `Record<string, unknown>`.
|
|
845
|
-
imports: imports && typeof imports === 'object' ? imports : undefined
|
|
846
|
-
};
|
|
847
|
-
packageJsonCache.set(path, packageConfig);
|
|
848
|
-
return packageConfig
|
|
849
|
-
}
|
|
850
|
-
|
|
851
|
-
/**
|
|
852
|
-
* @param {URL} resolved
|
|
853
|
-
* @returns {PackageConfig}
|
|
854
|
-
*/
|
|
855
|
-
function getPackageScopeConfig(resolved) {
|
|
856
|
-
let packageJsonUrl = new URL$3('package.json', resolved);
|
|
857
|
-
|
|
858
|
-
while (true) {
|
|
859
|
-
const packageJsonPath = packageJsonUrl.pathname;
|
|
860
|
-
|
|
861
|
-
if (packageJsonPath.endsWith('node_modules/package.json')) break
|
|
862
|
-
|
|
863
|
-
const packageConfig = getPackageConfig(
|
|
864
|
-
fileURLToPath(packageJsonUrl),
|
|
865
|
-
resolved
|
|
866
|
-
);
|
|
867
|
-
if (packageConfig.exists) return packageConfig
|
|
868
|
-
|
|
869
|
-
const lastPackageJsonUrl = packageJsonUrl;
|
|
870
|
-
packageJsonUrl = new URL$3('../package.json', packageJsonUrl);
|
|
871
|
-
|
|
872
|
-
// Terminates at root where ../package.json equals ../../package.json
|
|
873
|
-
// (can't just check "/package.json" for Windows support).
|
|
874
|
-
if (packageJsonUrl.pathname === lastPackageJsonUrl.pathname) break
|
|
875
|
-
}
|
|
876
|
-
|
|
877
|
-
const packageJsonPath = fileURLToPath(packageJsonUrl);
|
|
878
|
-
/** @type {PackageConfig} */
|
|
879
|
-
const packageConfig = {
|
|
880
|
-
pjsonPath: packageJsonPath,
|
|
881
|
-
exists: false,
|
|
882
|
-
main: undefined,
|
|
883
|
-
name: undefined,
|
|
884
|
-
type: 'none',
|
|
885
|
-
exports: undefined,
|
|
886
|
-
imports: undefined
|
|
887
|
-
};
|
|
888
|
-
packageJsonCache.set(packageJsonPath, packageConfig);
|
|
889
|
-
return packageConfig
|
|
890
|
-
}
|
|
891
|
-
|
|
892
|
-
/**
|
|
893
|
-
* Legacy CommonJS main resolution:
|
|
894
|
-
* 1. let M = pkg_url + (json main field)
|
|
895
|
-
* 2. TRY(M, M.js, M.json, M.node)
|
|
896
|
-
* 3. TRY(M/index.js, M/index.json, M/index.node)
|
|
897
|
-
* 4. TRY(pkg_url/index.js, pkg_url/index.json, pkg_url/index.node)
|
|
898
|
-
* 5. NOT_FOUND
|
|
899
|
-
*
|
|
900
|
-
* @param {URL} url
|
|
901
|
-
* @returns {boolean}
|
|
902
|
-
*/
|
|
903
|
-
function fileExists(url) {
|
|
904
|
-
const stats = statSync$1(url, {throwIfNoEntry: false});
|
|
905
|
-
const isFile = stats ? stats.isFile() : undefined;
|
|
906
|
-
return isFile === null || isFile === undefined ? false : isFile
|
|
907
|
-
}
|
|
908
|
-
|
|
909
|
-
/**
|
|
910
|
-
* @param {URL} packageJsonUrl
|
|
911
|
-
* @param {PackageConfig} packageConfig
|
|
912
|
-
* @param {URL} base
|
|
913
|
-
* @returns {URL}
|
|
914
|
-
*/
|
|
915
|
-
function legacyMainResolve(packageJsonUrl, packageConfig, base) {
|
|
916
|
-
/** @type {URL|undefined} */
|
|
917
|
-
let guess;
|
|
918
|
-
if (packageConfig.main !== undefined) {
|
|
919
|
-
guess = new URL$3(packageConfig.main, packageJsonUrl);
|
|
920
|
-
// Note: fs check redundances will be handled by Descriptor cache here.
|
|
921
|
-
if (fileExists(guess)) return guess
|
|
922
|
-
|
|
923
|
-
const tries = [
|
|
924
|
-
`./${packageConfig.main}.js`,
|
|
925
|
-
`./${packageConfig.main}.json`,
|
|
926
|
-
`./${packageConfig.main}.node`,
|
|
927
|
-
`./${packageConfig.main}/index.js`,
|
|
928
|
-
`./${packageConfig.main}/index.json`,
|
|
929
|
-
`./${packageConfig.main}/index.node`
|
|
930
|
-
];
|
|
931
|
-
let i = -1;
|
|
932
|
-
|
|
933
|
-
while (++i < tries.length) {
|
|
934
|
-
guess = new URL$3(tries[i], packageJsonUrl);
|
|
935
|
-
if (fileExists(guess)) break
|
|
936
|
-
guess = undefined;
|
|
937
|
-
}
|
|
938
|
-
|
|
939
|
-
if (guess) {
|
|
940
|
-
emitLegacyIndexDeprecation(
|
|
941
|
-
guess,
|
|
942
|
-
packageJsonUrl,
|
|
943
|
-
base,
|
|
944
|
-
packageConfig.main
|
|
945
|
-
);
|
|
946
|
-
return guess
|
|
947
|
-
}
|
|
948
|
-
// Fallthrough.
|
|
949
|
-
}
|
|
950
|
-
|
|
951
|
-
const tries = ['./index.js', './index.json', './index.node'];
|
|
952
|
-
let i = -1;
|
|
953
|
-
|
|
954
|
-
while (++i < tries.length) {
|
|
955
|
-
guess = new URL$3(tries[i], packageJsonUrl);
|
|
956
|
-
if (fileExists(guess)) break
|
|
957
|
-
guess = undefined;
|
|
958
|
-
}
|
|
959
|
-
|
|
960
|
-
if (guess) {
|
|
961
|
-
emitLegacyIndexDeprecation(guess, packageJsonUrl, base, packageConfig.main);
|
|
962
|
-
return guess
|
|
963
|
-
}
|
|
964
|
-
|
|
965
|
-
// Not found.
|
|
966
|
-
throw new ERR_MODULE_NOT_FOUND(
|
|
967
|
-
fileURLToPath(new URL$3('.', packageJsonUrl)),
|
|
968
|
-
fileURLToPath(base)
|
|
969
|
-
)
|
|
970
|
-
}
|
|
971
|
-
|
|
972
|
-
/**
|
|
973
|
-
* @param {URL} resolved
|
|
974
|
-
* @param {URL} base
|
|
975
|
-
* @param {boolean} [preserveSymlinks]
|
|
976
|
-
* @returns {URL}
|
|
977
|
-
*/
|
|
978
|
-
function finalizeResolution(resolved, base, preserveSymlinks) {
|
|
979
|
-
if (encodedSepRegEx.test(resolved.pathname))
|
|
980
|
-
throw new ERR_INVALID_MODULE_SPECIFIER(
|
|
981
|
-
resolved.pathname,
|
|
982
|
-
'must not include encoded "/" or "\\" characters',
|
|
983
|
-
fileURLToPath(base)
|
|
984
|
-
)
|
|
985
|
-
|
|
986
|
-
const filePath = fileURLToPath(resolved);
|
|
987
|
-
|
|
988
|
-
const stats = tryStatSync(
|
|
989
|
-
filePath.endsWith('/') ? filePath.slice(-1) : filePath
|
|
990
|
-
);
|
|
991
|
-
|
|
992
|
-
if (stats.isDirectory()) {
|
|
993
|
-
const error = new ERR_UNSUPPORTED_DIR_IMPORT(filePath, fileURLToPath(base));
|
|
994
|
-
// @ts-expect-error Add this for `import.meta.resolve`.
|
|
995
|
-
error.url = String(resolved);
|
|
996
|
-
throw error
|
|
997
|
-
}
|
|
998
|
-
|
|
999
|
-
if (!stats.isFile()) {
|
|
1000
|
-
throw new ERR_MODULE_NOT_FOUND(
|
|
1001
|
-
filePath || resolved.pathname,
|
|
1002
|
-
base && fileURLToPath(base),
|
|
1003
|
-
'module'
|
|
1004
|
-
)
|
|
1005
|
-
}
|
|
1006
|
-
|
|
1007
|
-
if (!preserveSymlinks) {
|
|
1008
|
-
const real = realpathSync$1(filePath);
|
|
1009
|
-
const {search, hash} = resolved;
|
|
1010
|
-
resolved = pathToFileURL(real + (filePath.endsWith(path$n.sep) ? '/' : ''));
|
|
1011
|
-
resolved.search = search;
|
|
1012
|
-
resolved.hash = hash;
|
|
1013
|
-
}
|
|
1014
|
-
|
|
1015
|
-
return resolved
|
|
1016
|
-
}
|
|
1017
|
-
|
|
1018
|
-
/**
|
|
1019
|
-
* @param {string} specifier
|
|
1020
|
-
* @param {URL|undefined} packageJsonUrl
|
|
1021
|
-
* @param {URL} base
|
|
1022
|
-
* @returns {never}
|
|
1023
|
-
*/
|
|
1024
|
-
function throwImportNotDefined(specifier, packageJsonUrl, base) {
|
|
1025
|
-
throw new ERR_PACKAGE_IMPORT_NOT_DEFINED(
|
|
1026
|
-
specifier,
|
|
1027
|
-
packageJsonUrl && fileURLToPath(new URL$3('.', packageJsonUrl)),
|
|
1028
|
-
fileURLToPath(base)
|
|
1029
|
-
)
|
|
1030
|
-
}
|
|
1031
|
-
|
|
1032
|
-
/**
|
|
1033
|
-
* @param {string} subpath
|
|
1034
|
-
* @param {URL} packageJsonUrl
|
|
1035
|
-
* @param {URL} base
|
|
1036
|
-
* @returns {never}
|
|
1037
|
-
*/
|
|
1038
|
-
function throwExportsNotFound(subpath, packageJsonUrl, base) {
|
|
1039
|
-
throw new ERR_PACKAGE_PATH_NOT_EXPORTED(
|
|
1040
|
-
fileURLToPath(new URL$3('.', packageJsonUrl)),
|
|
1041
|
-
subpath,
|
|
1042
|
-
base && fileURLToPath(base)
|
|
1043
|
-
)
|
|
1044
|
-
}
|
|
1045
|
-
|
|
1046
|
-
/**
|
|
1047
|
-
* @param {string} subpath
|
|
1048
|
-
* @param {URL} packageJsonUrl
|
|
1049
|
-
* @param {boolean} internal
|
|
1050
|
-
* @param {URL} [base]
|
|
1051
|
-
* @returns {never}
|
|
1052
|
-
*/
|
|
1053
|
-
function throwInvalidSubpath(subpath, packageJsonUrl, internal, base) {
|
|
1054
|
-
const reason = `request is not a valid subpath for the "${
|
|
1055
|
-
internal ? 'imports' : 'exports'
|
|
1056
|
-
}" resolution of ${fileURLToPath(packageJsonUrl)}`;
|
|
1057
|
-
|
|
1058
|
-
throw new ERR_INVALID_MODULE_SPECIFIER(
|
|
1059
|
-
subpath,
|
|
1060
|
-
reason,
|
|
1061
|
-
base && fileURLToPath(base)
|
|
1062
|
-
)
|
|
1063
|
-
}
|
|
1064
|
-
|
|
1065
|
-
/**
|
|
1066
|
-
* @param {string} subpath
|
|
1067
|
-
* @param {unknown} target
|
|
1068
|
-
* @param {URL} packageJsonUrl
|
|
1069
|
-
* @param {boolean} internal
|
|
1070
|
-
* @param {URL} [base]
|
|
1071
|
-
* @returns {never}
|
|
1072
|
-
*/
|
|
1073
|
-
function throwInvalidPackageTarget(
|
|
1074
|
-
subpath,
|
|
1075
|
-
target,
|
|
1076
|
-
packageJsonUrl,
|
|
1077
|
-
internal,
|
|
1078
|
-
base
|
|
1079
|
-
) {
|
|
1080
|
-
target =
|
|
1081
|
-
typeof target === 'object' && target !== null
|
|
1082
|
-
? JSON.stringify(target, null, '')
|
|
1083
|
-
: `${target}`;
|
|
1084
|
-
|
|
1085
|
-
throw new ERR_INVALID_PACKAGE_TARGET(
|
|
1086
|
-
fileURLToPath(new URL$3('.', packageJsonUrl)),
|
|
1087
|
-
subpath,
|
|
1088
|
-
target,
|
|
1089
|
-
internal,
|
|
1090
|
-
base && fileURLToPath(base)
|
|
1091
|
-
)
|
|
1092
|
-
}
|
|
1093
|
-
|
|
1094
|
-
/**
|
|
1095
|
-
* @param {string} target
|
|
1096
|
-
* @param {string} subpath
|
|
1097
|
-
* @param {string} match
|
|
1098
|
-
* @param {URL} packageJsonUrl
|
|
1099
|
-
* @param {URL} base
|
|
1100
|
-
* @param {boolean} pattern
|
|
1101
|
-
* @param {boolean} internal
|
|
1102
|
-
* @param {Set<string>|undefined} conditions
|
|
1103
|
-
* @returns {URL}
|
|
1104
|
-
*/
|
|
1105
|
-
function resolvePackageTargetString(
|
|
1106
|
-
target,
|
|
1107
|
-
subpath,
|
|
1108
|
-
match,
|
|
1109
|
-
packageJsonUrl,
|
|
1110
|
-
base,
|
|
1111
|
-
pattern,
|
|
1112
|
-
internal,
|
|
1113
|
-
conditions
|
|
1114
|
-
) {
|
|
1115
|
-
if (subpath !== '' && !pattern && target[target.length - 1] !== '/')
|
|
1116
|
-
throwInvalidPackageTarget(match, target, packageJsonUrl, internal, base);
|
|
1117
|
-
|
|
1118
|
-
if (!target.startsWith('./')) {
|
|
1119
|
-
if (internal && !target.startsWith('../') && !target.startsWith('/')) {
|
|
1120
|
-
let isURL = false;
|
|
1121
|
-
|
|
1122
|
-
try {
|
|
1123
|
-
new URL$3(target);
|
|
1124
|
-
isURL = true;
|
|
1125
|
-
} catch {
|
|
1126
|
-
// Continue regardless of error.
|
|
1127
|
-
}
|
|
1128
|
-
|
|
1129
|
-
if (!isURL) {
|
|
1130
|
-
const exportTarget = pattern
|
|
1131
|
-
? RegExpPrototypeSymbolReplace.call(
|
|
1132
|
-
patternRegEx,
|
|
1133
|
-
target,
|
|
1134
|
-
() => subpath
|
|
1135
|
-
)
|
|
1136
|
-
: target + subpath;
|
|
1137
|
-
|
|
1138
|
-
return packageResolve(exportTarget, packageJsonUrl, conditions)
|
|
1139
|
-
}
|
|
1140
|
-
}
|
|
1141
|
-
|
|
1142
|
-
throwInvalidPackageTarget(match, target, packageJsonUrl, internal, base);
|
|
1143
|
-
}
|
|
1144
|
-
|
|
1145
|
-
if (invalidSegmentRegEx.test(target.slice(2)))
|
|
1146
|
-
throwInvalidPackageTarget(match, target, packageJsonUrl, internal, base);
|
|
1147
|
-
|
|
1148
|
-
const resolved = new URL$3(target, packageJsonUrl);
|
|
1149
|
-
const resolvedPath = resolved.pathname;
|
|
1150
|
-
const packagePath = new URL$3('.', packageJsonUrl).pathname;
|
|
1151
|
-
|
|
1152
|
-
if (!resolvedPath.startsWith(packagePath))
|
|
1153
|
-
throwInvalidPackageTarget(match, target, packageJsonUrl, internal, base);
|
|
1154
|
-
|
|
1155
|
-
if (subpath === '') return resolved
|
|
1156
|
-
|
|
1157
|
-
if (invalidSegmentRegEx.test(subpath)) {
|
|
1158
|
-
const request = pattern
|
|
1159
|
-
? match.replace('*', () => subpath)
|
|
1160
|
-
: match + subpath;
|
|
1161
|
-
throwInvalidSubpath(request, packageJsonUrl, internal, base);
|
|
1162
|
-
}
|
|
1163
|
-
|
|
1164
|
-
if (pattern) {
|
|
1165
|
-
return new URL$3(
|
|
1166
|
-
RegExpPrototypeSymbolReplace.call(
|
|
1167
|
-
patternRegEx,
|
|
1168
|
-
resolved.href,
|
|
1169
|
-
() => subpath
|
|
1170
|
-
)
|
|
1171
|
-
)
|
|
1172
|
-
}
|
|
1173
|
-
|
|
1174
|
-
return new URL$3(subpath, resolved)
|
|
1175
|
-
}
|
|
1176
|
-
|
|
1177
|
-
/**
|
|
1178
|
-
* @param {string} key
|
|
1179
|
-
* @returns {boolean}
|
|
1180
|
-
*/
|
|
1181
|
-
function isArrayIndex(key) {
|
|
1182
|
-
const keyNumber = Number(key);
|
|
1183
|
-
if (`${keyNumber}` !== key) return false
|
|
1184
|
-
return keyNumber >= 0 && keyNumber < 0xff_ff_ff_ff
|
|
1185
|
-
}
|
|
1186
|
-
|
|
1187
|
-
/**
|
|
1188
|
-
* @param {URL} packageJsonUrl
|
|
1189
|
-
* @param {unknown} target
|
|
1190
|
-
* @param {string} subpath
|
|
1191
|
-
* @param {string} packageSubpath
|
|
1192
|
-
* @param {URL} base
|
|
1193
|
-
* @param {boolean} pattern
|
|
1194
|
-
* @param {boolean} internal
|
|
1195
|
-
* @param {Set<string>|undefined} conditions
|
|
1196
|
-
* @returns {URL|null}
|
|
1197
|
-
*/
|
|
1198
|
-
function resolvePackageTarget(
|
|
1199
|
-
packageJsonUrl,
|
|
1200
|
-
target,
|
|
1201
|
-
subpath,
|
|
1202
|
-
packageSubpath,
|
|
1203
|
-
base,
|
|
1204
|
-
pattern,
|
|
1205
|
-
internal,
|
|
1206
|
-
conditions
|
|
1207
|
-
) {
|
|
1208
|
-
if (typeof target === 'string') {
|
|
1209
|
-
return resolvePackageTargetString(
|
|
1210
|
-
target,
|
|
1211
|
-
subpath,
|
|
1212
|
-
packageSubpath,
|
|
1213
|
-
packageJsonUrl,
|
|
1214
|
-
base,
|
|
1215
|
-
pattern,
|
|
1216
|
-
internal,
|
|
1217
|
-
conditions
|
|
1218
|
-
)
|
|
1219
|
-
}
|
|
1220
|
-
|
|
1221
|
-
if (Array.isArray(target)) {
|
|
1222
|
-
/** @type {Array<unknown>} */
|
|
1223
|
-
const targetList = target;
|
|
1224
|
-
if (targetList.length === 0) return null
|
|
1225
|
-
|
|
1226
|
-
/** @type {ErrnoException|null|undefined} */
|
|
1227
|
-
let lastException;
|
|
1228
|
-
let i = -1;
|
|
1229
|
-
|
|
1230
|
-
while (++i < targetList.length) {
|
|
1231
|
-
const targetItem = targetList[i];
|
|
1232
|
-
/** @type {URL|null} */
|
|
1233
|
-
let resolveResult;
|
|
1234
|
-
try {
|
|
1235
|
-
resolveResult = resolvePackageTarget(
|
|
1236
|
-
packageJsonUrl,
|
|
1237
|
-
targetItem,
|
|
1238
|
-
subpath,
|
|
1239
|
-
packageSubpath,
|
|
1240
|
-
base,
|
|
1241
|
-
pattern,
|
|
1242
|
-
internal,
|
|
1243
|
-
conditions
|
|
1244
|
-
);
|
|
1245
|
-
} catch (error) {
|
|
1246
|
-
const exception = /** @type {ErrnoException} */ (error);
|
|
1247
|
-
lastException = exception;
|
|
1248
|
-
if (exception.code === 'ERR_INVALID_PACKAGE_TARGET') continue
|
|
1249
|
-
throw error
|
|
1250
|
-
}
|
|
1251
|
-
|
|
1252
|
-
if (resolveResult === undefined) continue
|
|
1253
|
-
|
|
1254
|
-
if (resolveResult === null) {
|
|
1255
|
-
lastException = null;
|
|
1256
|
-
continue
|
|
1257
|
-
}
|
|
1258
|
-
|
|
1259
|
-
return resolveResult
|
|
1260
|
-
}
|
|
1261
|
-
|
|
1262
|
-
if (lastException === undefined || lastException === null) {
|
|
1263
|
-
return null
|
|
1264
|
-
}
|
|
1265
|
-
|
|
1266
|
-
throw lastException
|
|
1267
|
-
}
|
|
1268
|
-
|
|
1269
|
-
if (typeof target === 'object' && target !== null) {
|
|
1270
|
-
const keys = Object.getOwnPropertyNames(target);
|
|
1271
|
-
let i = -1;
|
|
1272
|
-
|
|
1273
|
-
while (++i < keys.length) {
|
|
1274
|
-
const key = keys[i];
|
|
1275
|
-
if (isArrayIndex(key)) {
|
|
1276
|
-
throw new ERR_INVALID_PACKAGE_CONFIG(
|
|
1277
|
-
fileURLToPath(packageJsonUrl),
|
|
1278
|
-
base,
|
|
1279
|
-
'"exports" cannot contain numeric property keys.'
|
|
1280
|
-
)
|
|
1281
|
-
}
|
|
1282
|
-
}
|
|
1283
|
-
|
|
1284
|
-
i = -1;
|
|
1285
|
-
|
|
1286
|
-
while (++i < keys.length) {
|
|
1287
|
-
const key = keys[i];
|
|
1288
|
-
if (key === 'default' || (conditions && conditions.has(key))) {
|
|
1289
|
-
// @ts-expect-error: indexable.
|
|
1290
|
-
const conditionalTarget = /** @type {unknown} */ (target[key]);
|
|
1291
|
-
const resolveResult = resolvePackageTarget(
|
|
1292
|
-
packageJsonUrl,
|
|
1293
|
-
conditionalTarget,
|
|
1294
|
-
subpath,
|
|
1295
|
-
packageSubpath,
|
|
1296
|
-
base,
|
|
1297
|
-
pattern,
|
|
1298
|
-
internal,
|
|
1299
|
-
conditions
|
|
1300
|
-
);
|
|
1301
|
-
if (resolveResult === undefined) continue
|
|
1302
|
-
return resolveResult
|
|
1303
|
-
}
|
|
1304
|
-
}
|
|
1305
|
-
|
|
1306
|
-
return null
|
|
1307
|
-
}
|
|
1308
|
-
|
|
1309
|
-
if (target === null) {
|
|
1310
|
-
return null
|
|
1311
|
-
}
|
|
1312
|
-
|
|
1313
|
-
throwInvalidPackageTarget(
|
|
1314
|
-
packageSubpath,
|
|
1315
|
-
target,
|
|
1316
|
-
packageJsonUrl,
|
|
1317
|
-
internal,
|
|
1318
|
-
base
|
|
1319
|
-
);
|
|
1320
|
-
}
|
|
1321
|
-
|
|
1322
|
-
/**
|
|
1323
|
-
* @param {unknown} exports
|
|
1324
|
-
* @param {URL} packageJsonUrl
|
|
1325
|
-
* @param {URL} base
|
|
1326
|
-
* @returns {boolean}
|
|
1327
|
-
*/
|
|
1328
|
-
function isConditionalExportsMainSugar(exports, packageJsonUrl, base) {
|
|
1329
|
-
if (typeof exports === 'string' || Array.isArray(exports)) return true
|
|
1330
|
-
if (typeof exports !== 'object' || exports === null) return false
|
|
1331
|
-
|
|
1332
|
-
const keys = Object.getOwnPropertyNames(exports);
|
|
1333
|
-
let isConditionalSugar = false;
|
|
1334
|
-
let i = 0;
|
|
1335
|
-
let j = -1;
|
|
1336
|
-
while (++j < keys.length) {
|
|
1337
|
-
const key = keys[j];
|
|
1338
|
-
const curIsConditionalSugar = key === '' || key[0] !== '.';
|
|
1339
|
-
if (i++ === 0) {
|
|
1340
|
-
isConditionalSugar = curIsConditionalSugar;
|
|
1341
|
-
} else if (isConditionalSugar !== curIsConditionalSugar) {
|
|
1342
|
-
throw new ERR_INVALID_PACKAGE_CONFIG(
|
|
1343
|
-
fileURLToPath(packageJsonUrl),
|
|
1344
|
-
base,
|
|
1345
|
-
'"exports" cannot contain some keys starting with \'.\' and some not.' +
|
|
1346
|
-
' The exports object must either be an object of package subpath keys' +
|
|
1347
|
-
' or an object of main entry condition name keys only.'
|
|
1348
|
-
)
|
|
1349
|
-
}
|
|
1350
|
-
}
|
|
1351
|
-
|
|
1352
|
-
return isConditionalSugar
|
|
1353
|
-
}
|
|
1354
|
-
|
|
1355
|
-
/**
|
|
1356
|
-
* @param {string} match
|
|
1357
|
-
* @param {URL} pjsonUrl
|
|
1358
|
-
* @param {URL} base
|
|
1359
|
-
*/
|
|
1360
|
-
function emitTrailingSlashPatternDeprecation(match, pjsonUrl, base) {
|
|
1361
|
-
const pjsonPath = fileURLToPath(pjsonUrl);
|
|
1362
|
-
if (emittedPackageWarnings.has(pjsonPath + '|' + match)) return
|
|
1363
|
-
emittedPackageWarnings.add(pjsonPath + '|' + match);
|
|
1364
|
-
process$1.emitWarning(
|
|
1365
|
-
`Use of deprecated trailing slash pattern mapping "${match}" in the ` +
|
|
1366
|
-
`"exports" field module resolution of the package at ${pjsonPath}${
|
|
1367
|
-
base ? ` imported from ${fileURLToPath(base)}` : ''
|
|
1368
|
-
}. Mapping specifiers ending in "/" is no longer supported.`,
|
|
1369
|
-
'DeprecationWarning',
|
|
1370
|
-
'DEP0155'
|
|
1371
|
-
);
|
|
1372
|
-
}
|
|
1373
|
-
|
|
1374
|
-
/**
|
|
1375
|
-
* @param {URL} packageJsonUrl
|
|
1376
|
-
* @param {string} packageSubpath
|
|
1377
|
-
* @param {Record<string, unknown>} packageConfig
|
|
1378
|
-
* @param {URL} base
|
|
1379
|
-
* @param {Set<string>|undefined} conditions
|
|
1380
|
-
* @returns {URL}
|
|
1381
|
-
*/
|
|
1382
|
-
function packageExportsResolve(
|
|
1383
|
-
packageJsonUrl,
|
|
1384
|
-
packageSubpath,
|
|
1385
|
-
packageConfig,
|
|
1386
|
-
base,
|
|
1387
|
-
conditions
|
|
1388
|
-
) {
|
|
1389
|
-
let exports = packageConfig.exports;
|
|
1390
|
-
|
|
1391
|
-
if (isConditionalExportsMainSugar(exports, packageJsonUrl, base)) {
|
|
1392
|
-
exports = {'.': exports};
|
|
1393
|
-
}
|
|
1394
|
-
|
|
1395
|
-
if (
|
|
1396
|
-
own.call(exports, packageSubpath) &&
|
|
1397
|
-
!packageSubpath.includes('*') &&
|
|
1398
|
-
!packageSubpath.endsWith('/')
|
|
1399
|
-
) {
|
|
1400
|
-
// @ts-expect-error: indexable.
|
|
1401
|
-
const target = exports[packageSubpath];
|
|
1402
|
-
const resolveResult = resolvePackageTarget(
|
|
1403
|
-
packageJsonUrl,
|
|
1404
|
-
target,
|
|
1405
|
-
'',
|
|
1406
|
-
packageSubpath,
|
|
1407
|
-
base,
|
|
1408
|
-
false,
|
|
1409
|
-
false,
|
|
1410
|
-
conditions
|
|
1411
|
-
);
|
|
1412
|
-
if (resolveResult === null || resolveResult === undefined) {
|
|
1413
|
-
throwExportsNotFound(packageSubpath, packageJsonUrl, base);
|
|
1414
|
-
}
|
|
1415
|
-
|
|
1416
|
-
return resolveResult
|
|
1417
|
-
}
|
|
1418
|
-
|
|
1419
|
-
let bestMatch = '';
|
|
1420
|
-
let bestMatchSubpath = '';
|
|
1421
|
-
const keys = Object.getOwnPropertyNames(exports);
|
|
1422
|
-
let i = -1;
|
|
1423
|
-
|
|
1424
|
-
while (++i < keys.length) {
|
|
1425
|
-
const key = keys[i];
|
|
1426
|
-
const patternIndex = key.indexOf('*');
|
|
1427
|
-
|
|
1428
|
-
if (
|
|
1429
|
-
patternIndex !== -1 &&
|
|
1430
|
-
packageSubpath.startsWith(key.slice(0, patternIndex))
|
|
1431
|
-
) {
|
|
1432
|
-
// When this reaches EOL, this can throw at the top of the whole function:
|
|
1433
|
-
//
|
|
1434
|
-
// if (StringPrototypeEndsWith(packageSubpath, '/'))
|
|
1435
|
-
// throwInvalidSubpath(packageSubpath)
|
|
1436
|
-
//
|
|
1437
|
-
// To match "imports" and the spec.
|
|
1438
|
-
if (packageSubpath.endsWith('/')) {
|
|
1439
|
-
emitTrailingSlashPatternDeprecation(
|
|
1440
|
-
packageSubpath,
|
|
1441
|
-
packageJsonUrl,
|
|
1442
|
-
base
|
|
1443
|
-
);
|
|
1444
|
-
}
|
|
1445
|
-
|
|
1446
|
-
const patternTrailer = key.slice(patternIndex + 1);
|
|
1447
|
-
|
|
1448
|
-
if (
|
|
1449
|
-
packageSubpath.length >= key.length &&
|
|
1450
|
-
packageSubpath.endsWith(patternTrailer) &&
|
|
1451
|
-
patternKeyCompare(bestMatch, key) === 1 &&
|
|
1452
|
-
key.lastIndexOf('*') === patternIndex
|
|
1453
|
-
) {
|
|
1454
|
-
bestMatch = key;
|
|
1455
|
-
bestMatchSubpath = packageSubpath.slice(
|
|
1456
|
-
patternIndex,
|
|
1457
|
-
packageSubpath.length - patternTrailer.length
|
|
1458
|
-
);
|
|
1459
|
-
}
|
|
1460
|
-
}
|
|
1461
|
-
}
|
|
1462
|
-
|
|
1463
|
-
if (bestMatch) {
|
|
1464
|
-
// @ts-expect-error: indexable.
|
|
1465
|
-
const target = /** @type {unknown} */ (exports[bestMatch]);
|
|
1466
|
-
const resolveResult = resolvePackageTarget(
|
|
1467
|
-
packageJsonUrl,
|
|
1468
|
-
target,
|
|
1469
|
-
bestMatchSubpath,
|
|
1470
|
-
bestMatch,
|
|
1471
|
-
base,
|
|
1472
|
-
true,
|
|
1473
|
-
false,
|
|
1474
|
-
conditions
|
|
1475
|
-
);
|
|
1476
|
-
|
|
1477
|
-
if (resolveResult === null || resolveResult === undefined) {
|
|
1478
|
-
throwExportsNotFound(packageSubpath, packageJsonUrl, base);
|
|
1479
|
-
}
|
|
1480
|
-
|
|
1481
|
-
return resolveResult
|
|
1482
|
-
}
|
|
1483
|
-
|
|
1484
|
-
throwExportsNotFound(packageSubpath, packageJsonUrl, base);
|
|
1485
|
-
}
|
|
1486
|
-
|
|
1487
|
-
/**
|
|
1488
|
-
* @param {string} a
|
|
1489
|
-
* @param {string} b
|
|
1490
|
-
*/
|
|
1491
|
-
function patternKeyCompare(a, b) {
|
|
1492
|
-
const aPatternIndex = a.indexOf('*');
|
|
1493
|
-
const bPatternIndex = b.indexOf('*');
|
|
1494
|
-
const baseLengthA = aPatternIndex === -1 ? a.length : aPatternIndex + 1;
|
|
1495
|
-
const baseLengthB = bPatternIndex === -1 ? b.length : bPatternIndex + 1;
|
|
1496
|
-
if (baseLengthA > baseLengthB) return -1
|
|
1497
|
-
if (baseLengthB > baseLengthA) return 1
|
|
1498
|
-
if (aPatternIndex === -1) return 1
|
|
1499
|
-
if (bPatternIndex === -1) return -1
|
|
1500
|
-
if (a.length > b.length) return -1
|
|
1501
|
-
if (b.length > a.length) return 1
|
|
1502
|
-
return 0
|
|
1503
|
-
}
|
|
1504
|
-
|
|
1505
|
-
/**
|
|
1506
|
-
* @param {string} name
|
|
1507
|
-
* @param {URL} base
|
|
1508
|
-
* @param {Set<string>} [conditions]
|
|
1509
|
-
* @returns {URL}
|
|
1510
|
-
*/
|
|
1511
|
-
function packageImportsResolve(name, base, conditions) {
|
|
1512
|
-
if (name === '#' || name.startsWith('#/') || name.endsWith('/')) {
|
|
1513
|
-
const reason = 'is not a valid internal imports specifier name';
|
|
1514
|
-
throw new ERR_INVALID_MODULE_SPECIFIER(name, reason, fileURLToPath(base))
|
|
1515
|
-
}
|
|
1516
|
-
|
|
1517
|
-
/** @type {URL|undefined} */
|
|
1518
|
-
let packageJsonUrl;
|
|
1519
|
-
|
|
1520
|
-
const packageConfig = getPackageScopeConfig(base);
|
|
1521
|
-
|
|
1522
|
-
if (packageConfig.exists) {
|
|
1523
|
-
packageJsonUrl = pathToFileURL(packageConfig.pjsonPath);
|
|
1524
|
-
const imports = packageConfig.imports;
|
|
1525
|
-
if (imports) {
|
|
1526
|
-
if (own.call(imports, name) && !name.includes('*')) {
|
|
1527
|
-
const resolveResult = resolvePackageTarget(
|
|
1528
|
-
packageJsonUrl,
|
|
1529
|
-
imports[name],
|
|
1530
|
-
'',
|
|
1531
|
-
name,
|
|
1532
|
-
base,
|
|
1533
|
-
false,
|
|
1534
|
-
true,
|
|
1535
|
-
conditions
|
|
1536
|
-
);
|
|
1537
|
-
if (resolveResult !== null && resolveResult !== undefined) {
|
|
1538
|
-
return resolveResult
|
|
1539
|
-
}
|
|
1540
|
-
} else {
|
|
1541
|
-
let bestMatch = '';
|
|
1542
|
-
let bestMatchSubpath = '';
|
|
1543
|
-
const keys = Object.getOwnPropertyNames(imports);
|
|
1544
|
-
let i = -1;
|
|
1545
|
-
|
|
1546
|
-
while (++i < keys.length) {
|
|
1547
|
-
const key = keys[i];
|
|
1548
|
-
const patternIndex = key.indexOf('*');
|
|
1549
|
-
|
|
1550
|
-
if (patternIndex !== -1 && name.startsWith(key.slice(0, -1))) {
|
|
1551
|
-
const patternTrailer = key.slice(patternIndex + 1);
|
|
1552
|
-
if (
|
|
1553
|
-
name.length >= key.length &&
|
|
1554
|
-
name.endsWith(patternTrailer) &&
|
|
1555
|
-
patternKeyCompare(bestMatch, key) === 1 &&
|
|
1556
|
-
key.lastIndexOf('*') === patternIndex
|
|
1557
|
-
) {
|
|
1558
|
-
bestMatch = key;
|
|
1559
|
-
bestMatchSubpath = name.slice(
|
|
1560
|
-
patternIndex,
|
|
1561
|
-
name.length - patternTrailer.length
|
|
1562
|
-
);
|
|
1563
|
-
}
|
|
1564
|
-
}
|
|
1565
|
-
}
|
|
1566
|
-
|
|
1567
|
-
if (bestMatch) {
|
|
1568
|
-
const target = imports[bestMatch];
|
|
1569
|
-
const resolveResult = resolvePackageTarget(
|
|
1570
|
-
packageJsonUrl,
|
|
1571
|
-
target,
|
|
1572
|
-
bestMatchSubpath,
|
|
1573
|
-
bestMatch,
|
|
1574
|
-
base,
|
|
1575
|
-
true,
|
|
1576
|
-
true,
|
|
1577
|
-
conditions
|
|
1578
|
-
);
|
|
1579
|
-
|
|
1580
|
-
if (resolveResult !== null && resolveResult !== undefined) {
|
|
1581
|
-
return resolveResult
|
|
1582
|
-
}
|
|
1583
|
-
}
|
|
1584
|
-
}
|
|
1585
|
-
}
|
|
1586
|
-
}
|
|
1587
|
-
|
|
1588
|
-
throwImportNotDefined(name, packageJsonUrl, base);
|
|
1589
|
-
}
|
|
1590
|
-
|
|
1591
|
-
/**
|
|
1592
|
-
* @param {URL} url
|
|
1593
|
-
* @returns {PackageType}
|
|
1594
|
-
*/
|
|
1595
|
-
function getPackageType(url) {
|
|
1596
|
-
const packageConfig = getPackageScopeConfig(url);
|
|
1597
|
-
return packageConfig.type
|
|
1598
|
-
}
|
|
1599
|
-
|
|
1600
|
-
/**
|
|
1601
|
-
* @param {string} specifier
|
|
1602
|
-
* @param {URL} base
|
|
1603
|
-
*/
|
|
1604
|
-
function parsePackageName(specifier, base) {
|
|
1605
|
-
let separatorIndex = specifier.indexOf('/');
|
|
1606
|
-
let validPackageName = true;
|
|
1607
|
-
let isScoped = false;
|
|
1608
|
-
if (specifier[0] === '@') {
|
|
1609
|
-
isScoped = true;
|
|
1610
|
-
if (separatorIndex === -1 || specifier.length === 0) {
|
|
1611
|
-
validPackageName = false;
|
|
1612
|
-
} else {
|
|
1613
|
-
separatorIndex = specifier.indexOf('/', separatorIndex + 1);
|
|
1614
|
-
}
|
|
1615
|
-
}
|
|
1616
|
-
|
|
1617
|
-
const packageName =
|
|
1618
|
-
separatorIndex === -1 ? specifier : specifier.slice(0, separatorIndex);
|
|
1619
|
-
|
|
1620
|
-
// Package name cannot have leading . and cannot have percent-encoding or
|
|
1621
|
-
// \\ separators.
|
|
1622
|
-
if (invalidPackageNameRegEx.exec(packageName) !== null) {
|
|
1623
|
-
validPackageName = false;
|
|
1624
|
-
}
|
|
1625
|
-
|
|
1626
|
-
if (!validPackageName) {
|
|
1627
|
-
throw new ERR_INVALID_MODULE_SPECIFIER(
|
|
1628
|
-
specifier,
|
|
1629
|
-
'is not a valid package name',
|
|
1630
|
-
fileURLToPath(base)
|
|
1631
|
-
)
|
|
1632
|
-
}
|
|
1633
|
-
|
|
1634
|
-
const packageSubpath =
|
|
1635
|
-
'.' + (separatorIndex === -1 ? '' : specifier.slice(separatorIndex));
|
|
1636
|
-
|
|
1637
|
-
return {packageName, packageSubpath, isScoped}
|
|
1638
|
-
}
|
|
1639
|
-
|
|
1640
|
-
/**
|
|
1641
|
-
* @param {string} specifier
|
|
1642
|
-
* @param {URL} base
|
|
1643
|
-
* @param {Set<string>|undefined} conditions
|
|
1644
|
-
* @returns {URL}
|
|
1645
|
-
*/
|
|
1646
|
-
function packageResolve(specifier, base, conditions) {
|
|
1647
|
-
if (builtinModules.includes(specifier)) {
|
|
1648
|
-
return new URL$3('node:' + specifier)
|
|
1649
|
-
}
|
|
1650
|
-
|
|
1651
|
-
const {packageName, packageSubpath, isScoped} = parsePackageName(
|
|
1652
|
-
specifier,
|
|
1653
|
-
base
|
|
1654
|
-
);
|
|
1655
|
-
|
|
1656
|
-
// ResolveSelf
|
|
1657
|
-
const packageConfig = getPackageScopeConfig(base);
|
|
1658
|
-
|
|
1659
|
-
// Can’t test.
|
|
1660
|
-
/* c8 ignore next 16 */
|
|
1661
|
-
if (packageConfig.exists) {
|
|
1662
|
-
const packageJsonUrl = pathToFileURL(packageConfig.pjsonPath);
|
|
1663
|
-
if (
|
|
1664
|
-
packageConfig.name === packageName &&
|
|
1665
|
-
packageConfig.exports !== undefined &&
|
|
1666
|
-
packageConfig.exports !== null
|
|
1667
|
-
) {
|
|
1668
|
-
return packageExportsResolve(
|
|
1669
|
-
packageJsonUrl,
|
|
1670
|
-
packageSubpath,
|
|
1671
|
-
packageConfig,
|
|
1672
|
-
base,
|
|
1673
|
-
conditions
|
|
1674
|
-
)
|
|
1675
|
-
}
|
|
1676
|
-
}
|
|
1677
|
-
|
|
1678
|
-
let packageJsonUrl = new URL$3(
|
|
1679
|
-
'./node_modules/' + packageName + '/package.json',
|
|
1680
|
-
base
|
|
1681
|
-
);
|
|
1682
|
-
let packageJsonPath = fileURLToPath(packageJsonUrl);
|
|
1683
|
-
/** @type {string} */
|
|
1684
|
-
let lastPath;
|
|
1685
|
-
do {
|
|
1686
|
-
const stat = tryStatSync(packageJsonPath.slice(0, -13));
|
|
1687
|
-
if (!stat.isDirectory()) {
|
|
1688
|
-
lastPath = packageJsonPath;
|
|
1689
|
-
packageJsonUrl = new URL$3(
|
|
1690
|
-
(isScoped ? '../../../../node_modules/' : '../../../node_modules/') +
|
|
1691
|
-
packageName +
|
|
1692
|
-
'/package.json',
|
|
1693
|
-
packageJsonUrl
|
|
1694
|
-
);
|
|
1695
|
-
packageJsonPath = fileURLToPath(packageJsonUrl);
|
|
1696
|
-
continue
|
|
1697
|
-
}
|
|
1698
|
-
|
|
1699
|
-
// Package match.
|
|
1700
|
-
const packageConfig = getPackageConfig(packageJsonPath, specifier, base);
|
|
1701
|
-
if (packageConfig.exports !== undefined && packageConfig.exports !== null) {
|
|
1702
|
-
return packageExportsResolve(
|
|
1703
|
-
packageJsonUrl,
|
|
1704
|
-
packageSubpath,
|
|
1705
|
-
packageConfig,
|
|
1706
|
-
base,
|
|
1707
|
-
conditions
|
|
1708
|
-
)
|
|
1709
|
-
}
|
|
1710
|
-
|
|
1711
|
-
if (packageSubpath === '.') {
|
|
1712
|
-
return legacyMainResolve(packageJsonUrl, packageConfig, base)
|
|
1713
|
-
}
|
|
1714
|
-
|
|
1715
|
-
return new URL$3(packageSubpath, packageJsonUrl)
|
|
1716
|
-
// Cross-platform root check.
|
|
1717
|
-
} while (packageJsonPath.length !== lastPath.length)
|
|
1718
|
-
|
|
1719
|
-
throw new ERR_MODULE_NOT_FOUND(packageName, fileURLToPath(base))
|
|
1720
|
-
}
|
|
1721
|
-
|
|
1722
|
-
/**
|
|
1723
|
-
* @param {string} specifier
|
|
1724
|
-
* @returns {boolean}
|
|
1725
|
-
*/
|
|
1726
|
-
function isRelativeSpecifier(specifier) {
|
|
1727
|
-
if (specifier[0] === '.') {
|
|
1728
|
-
if (specifier.length === 1 || specifier[1] === '/') return true
|
|
1729
|
-
if (
|
|
1730
|
-
specifier[1] === '.' &&
|
|
1731
|
-
(specifier.length === 2 || specifier[2] === '/')
|
|
1732
|
-
) {
|
|
1733
|
-
return true
|
|
1734
|
-
}
|
|
1735
|
-
}
|
|
1736
|
-
|
|
1737
|
-
return false
|
|
1738
|
-
}
|
|
1739
|
-
|
|
1740
|
-
/**
|
|
1741
|
-
* @param {string} specifier
|
|
1742
|
-
* @returns {boolean}
|
|
1743
|
-
*/
|
|
1744
|
-
function shouldBeTreatedAsRelativeOrAbsolutePath(specifier) {
|
|
1745
|
-
if (specifier === '') return false
|
|
1746
|
-
if (specifier[0] === '/') return true
|
|
1747
|
-
return isRelativeSpecifier(specifier)
|
|
1748
|
-
}
|
|
1749
|
-
|
|
1750
|
-
/**
|
|
1751
|
-
* The “Resolver Algorithm Specification” as detailed in the Node docs (which is
|
|
1752
|
-
* sync and slightly lower-level than `resolve`).
|
|
1753
|
-
*
|
|
1754
|
-
* @param {string} specifier
|
|
1755
|
-
* @param {URL} base
|
|
1756
|
-
* @param {Set<string>} [conditions]
|
|
1757
|
-
* @param {boolean} [preserveSymlinks]
|
|
1758
|
-
* @returns {URL}
|
|
1759
|
-
*/
|
|
1760
|
-
function moduleResolve(specifier, base, conditions, preserveSymlinks) {
|
|
1761
|
-
const isRemote = base.protocol === 'http:' || base.protocol === 'https:';
|
|
1762
|
-
// Order swapped from spec for minor perf gain.
|
|
1763
|
-
// Ok since relative URLs cannot parse as URLs.
|
|
1764
|
-
/** @type {URL|undefined} */
|
|
1765
|
-
let resolved;
|
|
1766
|
-
|
|
1767
|
-
if (shouldBeTreatedAsRelativeOrAbsolutePath(specifier)) {
|
|
1768
|
-
resolved = new URL$3(specifier, base);
|
|
1769
|
-
} else if (!isRemote && specifier[0] === '#') {
|
|
1770
|
-
resolved = packageImportsResolve(specifier, base, conditions);
|
|
1771
|
-
} else {
|
|
1772
|
-
try {
|
|
1773
|
-
resolved = new URL$3(specifier);
|
|
1774
|
-
} catch {
|
|
1775
|
-
if (!isRemote) {
|
|
1776
|
-
resolved = packageResolve(specifier, base, conditions);
|
|
1777
|
-
}
|
|
1778
|
-
}
|
|
1779
|
-
}
|
|
1780
|
-
|
|
1781
|
-
assert$1(typeof resolved !== 'undefined', 'expected to be defined');
|
|
1782
|
-
|
|
1783
|
-
if (resolved.protocol !== 'file:') {
|
|
1784
|
-
return resolved
|
|
1785
|
-
}
|
|
1786
|
-
|
|
1787
|
-
return finalizeResolution(resolved, base, preserveSymlinks)
|
|
1788
|
-
}
|
|
1789
|
-
|
|
1790
|
-
/**
|
|
1791
|
-
* @param {string} specifier
|
|
1792
|
-
* @param {URL|undefined} parsed
|
|
1793
|
-
* @param {URL|undefined} parsedParentURL
|
|
1794
|
-
*/
|
|
1795
|
-
function checkIfDisallowedImport(specifier, parsed, parsedParentURL) {
|
|
1796
|
-
if (
|
|
1797
|
-
parsed &&
|
|
1798
|
-
parsedParentURL &&
|
|
1799
|
-
(parsedParentURL.protocol === 'http:' ||
|
|
1800
|
-
parsedParentURL.protocol === 'https:')
|
|
1801
|
-
) {
|
|
1802
|
-
if (shouldBeTreatedAsRelativeOrAbsolutePath(specifier)) {
|
|
1803
|
-
// Data: and blob: disallowed due to allowing file: access via
|
|
1804
|
-
// indirection
|
|
1805
|
-
if (
|
|
1806
|
-
parsed &&
|
|
1807
|
-
parsed.protocol !== 'https:' &&
|
|
1808
|
-
parsed.protocol !== 'http:'
|
|
1809
|
-
) {
|
|
1810
|
-
throw new ERR_NETWORK_IMPORT_DISALLOWED(
|
|
1811
|
-
specifier,
|
|
1812
|
-
parsedParentURL,
|
|
1813
|
-
'remote imports cannot import from a local location.'
|
|
1814
|
-
)
|
|
1815
|
-
}
|
|
1816
|
-
|
|
1817
|
-
return {url: parsed.href}
|
|
1818
|
-
}
|
|
1819
|
-
|
|
1820
|
-
if (builtinModules.includes(specifier)) {
|
|
1821
|
-
throw new ERR_NETWORK_IMPORT_DISALLOWED(
|
|
1822
|
-
specifier,
|
|
1823
|
-
parsedParentURL,
|
|
1824
|
-
'remote imports cannot import from a local location.'
|
|
1825
|
-
)
|
|
1826
|
-
}
|
|
1827
|
-
|
|
1828
|
-
throw new ERR_NETWORK_IMPORT_DISALLOWED(
|
|
1829
|
-
specifier,
|
|
1830
|
-
parsedParentURL,
|
|
1831
|
-
'only relative and absolute specifiers are supported.'
|
|
1832
|
-
)
|
|
1833
|
-
}
|
|
1834
|
-
}
|
|
1835
|
-
|
|
1836
|
-
/**
|
|
1837
|
-
* @param {URL} url
|
|
1838
|
-
*/
|
|
1839
|
-
function throwIfUnsupportedURLProtocol(url) {
|
|
1840
|
-
if (
|
|
1841
|
-
url.protocol !== 'file:' &&
|
|
1842
|
-
url.protocol !== 'data:' &&
|
|
1843
|
-
url.protocol !== 'node:'
|
|
1844
|
-
) {
|
|
1845
|
-
throw new ERR_UNSUPPORTED_ESM_URL_SCHEME(url)
|
|
1846
|
-
}
|
|
1847
|
-
}
|
|
1848
|
-
|
|
1849
|
-
/**
|
|
1850
|
-
* @param {URL|undefined} parsed
|
|
1851
|
-
* @param {boolean} experimentalNetworkImports
|
|
1852
|
-
*/
|
|
1853
|
-
function throwIfUnsupportedURLScheme(parsed, experimentalNetworkImports) {
|
|
1854
|
-
if (
|
|
1855
|
-
parsed &&
|
|
1856
|
-
parsed.protocol !== 'file:' &&
|
|
1857
|
-
parsed.protocol !== 'data:' &&
|
|
1858
|
-
(!experimentalNetworkImports ||
|
|
1859
|
-
(parsed.protocol !== 'https:' && parsed.protocol !== 'http:'))
|
|
1860
|
-
) {
|
|
1861
|
-
throw new ERR_UNSUPPORTED_ESM_URL_SCHEME(
|
|
1862
|
-
parsed,
|
|
1863
|
-
['file', 'data'].concat(
|
|
1864
|
-
experimentalNetworkImports ? ['https', 'http'] : []
|
|
1865
|
-
)
|
|
1866
|
-
)
|
|
1867
|
-
}
|
|
1868
|
-
}
|
|
1869
|
-
|
|
1870
|
-
/**
|
|
1871
|
-
* @param {string} specifier
|
|
1872
|
-
* @param {{parentURL?: string, conditions?: Array<string>}} context
|
|
1873
|
-
* @returns {{url: string, format?: string|null}}
|
|
1874
|
-
*/
|
|
1875
|
-
function defaultResolve(specifier, context = {}) {
|
|
1876
|
-
const {parentURL} = context;
|
|
1877
|
-
assert$1(typeof parentURL !== 'undefined', 'expected `parentURL` to be defined');
|
|
1878
|
-
|
|
1879
|
-
/** @type {URL|undefined} */
|
|
1880
|
-
let parsedParentURL;
|
|
1881
|
-
if (parentURL) {
|
|
1882
|
-
try {
|
|
1883
|
-
parsedParentURL = new URL$3(parentURL);
|
|
1884
|
-
} catch {
|
|
1885
|
-
// Ignore exception
|
|
1886
|
-
}
|
|
1887
|
-
}
|
|
1888
|
-
|
|
1889
|
-
/** @type {URL|undefined} */
|
|
1890
|
-
let parsed;
|
|
1891
|
-
try {
|
|
1892
|
-
parsed = shouldBeTreatedAsRelativeOrAbsolutePath(specifier)
|
|
1893
|
-
? new URL$3(specifier, parsedParentURL)
|
|
1894
|
-
: new URL$3(specifier);
|
|
1895
|
-
|
|
1896
|
-
if (
|
|
1897
|
-
parsed.protocol === 'data:' ||
|
|
1898
|
-
(experimentalNetworkImports )
|
|
1899
|
-
) {
|
|
1900
|
-
return {url: parsed.href, format: null}
|
|
1901
|
-
}
|
|
1902
|
-
} catch {
|
|
1903
|
-
// Ignore exception
|
|
1904
|
-
}
|
|
1905
|
-
|
|
1906
|
-
// There are multiple deep branches that can either throw or return; instead
|
|
1907
|
-
// of duplicating that deeply nested logic for the possible returns, DRY and
|
|
1908
|
-
// check for a return. This seems the least gnarly.
|
|
1909
|
-
const maybeReturn = checkIfDisallowedImport(
|
|
1910
|
-
specifier,
|
|
1911
|
-
parsed,
|
|
1912
|
-
parsedParentURL
|
|
1913
|
-
);
|
|
1914
|
-
|
|
1915
|
-
if (maybeReturn) return maybeReturn
|
|
1916
|
-
|
|
1917
|
-
// This must come after checkIfDisallowedImport
|
|
1918
|
-
if (parsed && parsed.protocol === 'node:') return {url: specifier}
|
|
1919
|
-
|
|
1920
|
-
throwIfUnsupportedURLScheme(parsed, experimentalNetworkImports);
|
|
1921
|
-
|
|
1922
|
-
const conditions = getConditionsSet(context.conditions);
|
|
1923
|
-
|
|
1924
|
-
const url = moduleResolve(specifier, new URL$3(parentURL), conditions, false);
|
|
1925
|
-
|
|
1926
|
-
throwIfUnsupportedURLProtocol(url);
|
|
1927
|
-
|
|
1928
|
-
return {
|
|
1929
|
-
// Do NOT cast `url` to a string: that will work even when there are real
|
|
1930
|
-
// problems, silencing them
|
|
1931
|
-
url: url.href,
|
|
1932
|
-
format: defaultGetFormatWithoutErrors(url, {parentURL})
|
|
1933
|
-
}
|
|
1934
|
-
}
|
|
1935
|
-
|
|
1936
|
-
/**
|
|
1937
|
-
* @typedef {import('./lib/errors.js').ErrnoException} ErrnoException
|
|
1938
|
-
*/
|
|
1939
|
-
|
|
1940
|
-
/**
|
|
1941
|
-
* Provides a module-relative resolution function scoped to each module,
|
|
1942
|
-
* returning the URL string.
|
|
1943
|
-
* `import.meta.resolve` also accepts a second argument which is the parent
|
|
1944
|
-
* module from which to resolve from.
|
|
1945
|
-
*
|
|
1946
|
-
* This function is asynchronous because the ES module resolver in Node.js is
|
|
1947
|
-
* allowed to be asynchronous.
|
|
1948
|
-
*
|
|
1949
|
-
* @param {string} specifier The module specifier to resolve relative to parent.
|
|
1950
|
-
* @param {string} parent The absolute parent module URL to resolve from.
|
|
1951
|
-
* You should pass `import.meta.url` or something else
|
|
1952
|
-
* @returns {Promise<string>}
|
|
1953
|
-
*/
|
|
1954
|
-
async function resolve$4(specifier, parent) {
|
|
1955
|
-
if (!parent) {
|
|
1956
|
-
throw new Error(
|
|
1957
|
-
'Please pass `parent`: `import-meta-resolve` cannot ponyfill that'
|
|
1958
|
-
)
|
|
1959
|
-
}
|
|
1960
|
-
|
|
1961
|
-
try {
|
|
1962
|
-
return defaultResolve(specifier, {parentURL: parent}).url
|
|
1963
|
-
} catch (error) {
|
|
1964
|
-
const exception = /** @type {ErrnoException} */ (error);
|
|
1965
|
-
|
|
1966
|
-
return exception.code === 'ERR_UNSUPPORTED_DIR_IMPORT' &&
|
|
1967
|
-
typeof exception.url === 'string'
|
|
1968
|
-
? exception.url
|
|
1969
|
-
: Promise.reject(error)
|
|
1970
|
-
}
|
|
1971
|
-
}
|
|
1972
|
-
|
|
1973
216
|
var picomatch$5 = {exports: {}};
|
|
1974
217
|
|
|
1975
218
|
var utils$k = {};
|
|
@@ -4317,7 +2560,7 @@ function getMatcherString$1(id, resolutionBase) {
|
|
|
4317
2560
|
return id;
|
|
4318
2561
|
}
|
|
4319
2562
|
// resolve('') is valid and will default to process.cwd()
|
|
4320
|
-
const basePath = resolve$
|
|
2563
|
+
const basePath = resolve$4(resolutionBase || '')
|
|
4321
2564
|
.split(sep)
|
|
4322
2565
|
.join('/')
|
|
4323
2566
|
// escape all possible (posix + win) path characters that might interfere with regex
|
|
@@ -6322,7 +4565,7 @@ function requireSync () {
|
|
|
6322
4565
|
var minimatch = minimatch_1;
|
|
6323
4566
|
requireGlob().Glob;
|
|
6324
4567
|
var path = require$$0$4;
|
|
6325
|
-
var assert = assert$
|
|
4568
|
+
var assert = assert$1;
|
|
6326
4569
|
var isAbsolute = pathIsAbsolute.exports;
|
|
6327
4570
|
var common = common$c;
|
|
6328
4571
|
var setopts = common.setopts;
|
|
@@ -6982,7 +5225,7 @@ function requireGlob () {
|
|
|
6982
5225
|
var inherits$1 = inherits.exports;
|
|
6983
5226
|
var EE = require$$0$5.EventEmitter;
|
|
6984
5227
|
var path = require$$0$4;
|
|
6985
|
-
var assert = assert$
|
|
5228
|
+
var assert = assert$1;
|
|
6986
5229
|
var isAbsolute = pathIsAbsolute.exports;
|
|
6987
5230
|
var globSync = requireSync();
|
|
6988
5231
|
var common = common$c;
|
|
@@ -9165,7 +7408,7 @@ function getPackageEntryPoint(dirPath) {
|
|
|
9165
7408
|
|
|
9166
7409
|
function isDirectory(path) {
|
|
9167
7410
|
try {
|
|
9168
|
-
if (statSync$
|
|
7411
|
+
if (statSync$1(path).isDirectory()) return true;
|
|
9169
7412
|
} catch (ignored) {
|
|
9170
7413
|
// Nothing to do here
|
|
9171
7414
|
}
|
|
@@ -9182,11 +7425,11 @@ function getDynamicRequireModules(patterns, dynamicRequireRoot) {
|
|
|
9182
7425
|
? dynamicRequireModules.delete(targetPath)
|
|
9183
7426
|
: dynamicRequireModules.set(targetPath, resolvedPath);
|
|
9184
7427
|
for (const path of globExports.sync(isNegated ? pattern.substr(1) : pattern)) {
|
|
9185
|
-
const resolvedPath = resolve$
|
|
7428
|
+
const resolvedPath = resolve$4(path);
|
|
9186
7429
|
const requirePath = normalizePathSlashes(resolvedPath);
|
|
9187
7430
|
if (isDirectory(resolvedPath)) {
|
|
9188
7431
|
dirNames.add(resolvedPath);
|
|
9189
|
-
const modulePath = resolve$
|
|
7432
|
+
const modulePath = resolve$4(join$1(resolvedPath, getPackageEntryPoint(path)));
|
|
9190
7433
|
modifyMap(requirePath, modulePath);
|
|
9191
7434
|
modifyMap(normalizePathSlashes(modulePath), modulePath);
|
|
9192
7435
|
} else {
|
|
@@ -9483,12 +7726,12 @@ function resolveExtensions(importee, importer, extensions) {
|
|
|
9483
7726
|
// not our problem
|
|
9484
7727
|
if (importee[0] !== '.' || !importer) return undefined;
|
|
9485
7728
|
|
|
9486
|
-
const resolved = resolve$
|
|
7729
|
+
const resolved = resolve$4(dirname$1(importer), importee);
|
|
9487
7730
|
const candidates = getCandidates(resolved, extensions);
|
|
9488
7731
|
|
|
9489
7732
|
for (let i = 0; i < candidates.length; i += 1) {
|
|
9490
7733
|
try {
|
|
9491
|
-
const stats = statSync$
|
|
7734
|
+
const stats = statSync$1(candidates[i]);
|
|
9492
7735
|
if (stats.isFile()) return { id: candidates[i] };
|
|
9493
7736
|
} catch (err) {
|
|
9494
7737
|
/* noop */
|
|
@@ -10996,7 +9239,7 @@ function commonjs(options = {}) {
|
|
|
10996
9239
|
|
|
10997
9240
|
const dynamicRequireRoot =
|
|
10998
9241
|
typeof options.dynamicRequireRoot === 'string'
|
|
10999
|
-
? resolve$
|
|
9242
|
+
? resolve$4(options.dynamicRequireRoot)
|
|
11000
9243
|
: process.cwd();
|
|
11001
9244
|
const { commonDir, dynamicRequireModules } = getDynamicRequireModules(
|
|
11002
9245
|
options.dynamicRequireTargets,
|
|
@@ -13286,7 +11529,7 @@ function getMatcherString(id, resolutionBase) {
|
|
|
13286
11529
|
return normalizePath$4(id);
|
|
13287
11530
|
}
|
|
13288
11531
|
// resolve('') is valid and will default to process.cwd()
|
|
13289
|
-
const basePath = normalizePath$4(resolve$
|
|
11532
|
+
const basePath = normalizePath$4(resolve$4(resolutionBase || ''))
|
|
13290
11533
|
// escape all possible (posix + win) path characters that might interfere with regex
|
|
13291
11534
|
.replace(/[-^$*+?.()|[\]{}]/g, '\\$&');
|
|
13292
11535
|
// Note that we use posix.join because:
|
|
@@ -13493,7 +11736,7 @@ try {
|
|
|
13493
11736
|
catch { }
|
|
13494
11737
|
const ssrExtensions = ['.js', '.cjs', '.json', '.node'];
|
|
13495
11738
|
function resolveFrom(id, basedir, preserveSymlinks = false, ssr = false) {
|
|
13496
|
-
return resolve$
|
|
11739
|
+
return resolve$5.sync(id, {
|
|
13497
11740
|
basedir,
|
|
13498
11741
|
paths: [],
|
|
13499
11742
|
extensions: ssr ? ssrExtensions : DEFAULT_EXTENSIONS$1,
|
|
@@ -13585,7 +11828,7 @@ const dataUrlRE = /^\s*data:/i;
|
|
|
13585
11828
|
const isDataUrl = (url) => dataUrlRE.test(url);
|
|
13586
11829
|
const virtualModuleRE = /^virtual-module:.*/;
|
|
13587
11830
|
const virtualModulePrefix = 'virtual-module:';
|
|
13588
|
-
const knownJsSrcRE = /\.((j|t)sx?|m[jt]s|vue|marko|svelte|astro)($|\?)/;
|
|
11831
|
+
const knownJsSrcRE = /\.((j|t)sx?|m[jt]s|vue|marko|svelte|astro|imba)($|\?)/;
|
|
13589
11832
|
const isJSRequest = (url) => {
|
|
13590
11833
|
url = cleanUrl(url);
|
|
13591
11834
|
if (knownJsSrcRE.test(url)) {
|
|
@@ -14299,6 +12542,18 @@ const isNonDriveRelativeAbsolutePath = (p) => {
|
|
|
14299
12542
|
return p.startsWith('/');
|
|
14300
12543
|
return windowsDrivePathPrefixRE.test(p);
|
|
14301
12544
|
};
|
|
12545
|
+
function joinUrlSegments(a, b) {
|
|
12546
|
+
if (!a || !b) {
|
|
12547
|
+
return a || b || '';
|
|
12548
|
+
}
|
|
12549
|
+
if (a.endsWith('/')) {
|
|
12550
|
+
a = a.substring(0, a.length - 1);
|
|
12551
|
+
}
|
|
12552
|
+
if (!b.startsWith('/')) {
|
|
12553
|
+
b = '/' + b;
|
|
12554
|
+
}
|
|
12555
|
+
return a + b;
|
|
12556
|
+
}
|
|
14302
12557
|
|
|
14303
12558
|
/* eslint no-console: 0 */
|
|
14304
12559
|
const LogLevels = {
|
|
@@ -15124,15 +13379,12 @@ async function transformWithEsbuild(code, filename, options, inMap) {
|
|
|
15124
13379
|
// these fields would affect the compilation result
|
|
15125
13380
|
// https://esbuild.github.io/content-types/#tsconfig-json
|
|
15126
13381
|
const meaningfulFields = [
|
|
15127
|
-
'
|
|
15128
|
-
'importsNotUsedAsValues',
|
|
15129
|
-
'jsx',
|
|
13382
|
+
'target',
|
|
15130
13383
|
'jsxFactory',
|
|
15131
13384
|
'jsxFragmentFactory',
|
|
15132
|
-
'
|
|
15133
|
-
'
|
|
15134
|
-
'
|
|
15135
|
-
'useDefineForClassFields'
|
|
13385
|
+
'useDefineForClassFields',
|
|
13386
|
+
'importsNotUsedAsValues',
|
|
13387
|
+
'preserveValueImports'
|
|
15136
13388
|
];
|
|
15137
13389
|
const compilerOptionsForFile = {};
|
|
15138
13390
|
if (loader === 'ts' || loader === 'tsx') {
|
|
@@ -35378,9 +33630,8 @@ function fileToDevUrl(id, config) {
|
|
|
35378
33630
|
// (this is special handled by the serve static middleware
|
|
35379
33631
|
rtn = path$n.posix.join(FS_PREFIX + id);
|
|
35380
33632
|
}
|
|
35381
|
-
const
|
|
35382
|
-
|
|
35383
|
-
return origin + devBase + rtn.replace(/^\//, '');
|
|
33633
|
+
const base = joinUrlSegments(config.server?.origin ?? '', config.base);
|
|
33634
|
+
return joinUrlSegments(base, rtn.replace(/^\//, ''));
|
|
35384
33635
|
}
|
|
35385
33636
|
function getAssetFilename(hash, config) {
|
|
35386
33637
|
return assetHashToFilenameMap.get(config)?.get(hash);
|
|
@@ -35479,7 +33730,7 @@ const publicAssetUrlRE = /__VITE_PUBLIC_ASSET__([a-z\d]{8})__/g;
|
|
|
35479
33730
|
function publicFileToBuiltUrl(url, config) {
|
|
35480
33731
|
if (config.command !== 'build') {
|
|
35481
33732
|
// We don't need relative base or renderBuiltUrl support during dev
|
|
35482
|
-
return config.base
|
|
33733
|
+
return joinUrlSegments(config.base, url);
|
|
35483
33734
|
}
|
|
35484
33735
|
const hash = getHash(url);
|
|
35485
33736
|
let cache = publicAssetUrlCache.get(config);
|
|
@@ -35771,7 +34022,7 @@ createError(
|
|
|
35771
34022
|
(pkgPath, key, target, isImport = false, base = void 0) => {
|
|
35772
34023
|
const relError = typeof target === "string" && !isImport && target.length > 0 && !target.startsWith("./");
|
|
35773
34024
|
if (key === ".") {
|
|
35774
|
-
assert$
|
|
34025
|
+
assert$1(isImport === false);
|
|
35775
34026
|
return `Invalid "exports" main target ${JSON.stringify(target)} defined in the package config ${pkgPath}package.json${base ? ` imported from ${base}` : ""}${relError ? '; targets must start with "./"' : ""}`;
|
|
35776
34027
|
}
|
|
35777
34028
|
return `Invalid "${isImport ? "imports" : "exports"}" target ${JSON.stringify(
|
|
@@ -35817,7 +34068,7 @@ createError(
|
|
|
35817
34068
|
createError(
|
|
35818
34069
|
"ERR_INVALID_ARG_VALUE",
|
|
35819
34070
|
(name, value, reason = "is invalid") => {
|
|
35820
|
-
let inspected = inspect
|
|
34071
|
+
let inspected = inspect(value);
|
|
35821
34072
|
if (inspected.length > 128) {
|
|
35822
34073
|
inspected = `${inspected.slice(0, 128)}...`;
|
|
35823
34074
|
}
|
|
@@ -35918,14 +34169,14 @@ const captureLargerStackTrace = hideStackFrames(
|
|
|
35918
34169
|
function getMessage(key, args, self) {
|
|
35919
34170
|
const message = messages.get(key);
|
|
35920
34171
|
if (typeof message === "function") {
|
|
35921
|
-
assert$
|
|
34172
|
+
assert$1(
|
|
35922
34173
|
message.length <= args.length,
|
|
35923
34174
|
`Code: ${key}; The provided arguments length (${args.length}) does not match the required ones (${message.length}).`
|
|
35924
34175
|
);
|
|
35925
34176
|
return Reflect.apply(message, self, args);
|
|
35926
34177
|
}
|
|
35927
34178
|
const expectedLength = (message.match(/%[dfijoOs]/g) || []).length;
|
|
35928
|
-
assert$
|
|
34179
|
+
assert$1(
|
|
35929
34180
|
expectedLength === args.length,
|
|
35930
34181
|
`Code: ${key}; The provided arguments length (${args.length}) does not match the required ones (${expectedLength}).`
|
|
35931
34182
|
);
|
|
@@ -35933,10 +34184,10 @@ function getMessage(key, args, self) {
|
|
|
35933
34184
|
return message;
|
|
35934
34185
|
}
|
|
35935
34186
|
args.unshift(message);
|
|
35936
|
-
return Reflect.apply(format$
|
|
34187
|
+
return Reflect.apply(format$2, null, args);
|
|
35937
34188
|
}
|
|
35938
34189
|
Object.freeze(["node", "import"]);
|
|
35939
|
-
pathToFileURL
|
|
34190
|
+
pathToFileURL(process.cwd());
|
|
35940
34191
|
|
|
35941
34192
|
const ESM_STATIC_IMPORT_RE = /(?<=\s|^|;)import\s*(["'\s]*(?<imports>[\w*${}\n\r\t, /]+)from\s*)?["']\s*(?<specifier>(?<="\s*)[^"]*[^"\s](?=\s*")|(?<='\s*)[^']*[^'\s](?=\s*'))\s*["'][\s;]*/gm;
|
|
35942
34193
|
function findStaticImports(code) {
|
|
@@ -37043,12 +35294,28 @@ function packageEntryFailure(id, details) {
|
|
|
37043
35294
|
`The package may have incorrect main/module/exports specified in its package.json` +
|
|
37044
35295
|
(details ? ': ' + details : '.'));
|
|
37045
35296
|
}
|
|
35297
|
+
const conditionalConditions = new Set(['production', 'development', 'module']);
|
|
37046
35298
|
function resolveExports(pkg, key, options, targetWeb) {
|
|
37047
|
-
const
|
|
37048
|
-
|
|
35299
|
+
const overrideConditions = options.overrideConditions
|
|
35300
|
+
? new Set(options.overrideConditions)
|
|
35301
|
+
: undefined;
|
|
35302
|
+
const conditions = [];
|
|
35303
|
+
if ((!overrideConditions || overrideConditions.has('production')) &&
|
|
35304
|
+
options.isProduction) {
|
|
35305
|
+
conditions.push('production');
|
|
35306
|
+
}
|
|
35307
|
+
if ((!overrideConditions || overrideConditions.has('development')) &&
|
|
35308
|
+
!options.isProduction) {
|
|
35309
|
+
conditions.push('development');
|
|
35310
|
+
}
|
|
35311
|
+
if ((!overrideConditions || overrideConditions.has('module')) &&
|
|
35312
|
+
!options.isRequire) {
|
|
37049
35313
|
conditions.push('module');
|
|
37050
35314
|
}
|
|
37051
|
-
if (options.
|
|
35315
|
+
if (options.overrideConditions) {
|
|
35316
|
+
conditions.push(...options.overrideConditions.filter((condition) => conditionalConditions.has(condition)));
|
|
35317
|
+
}
|
|
35318
|
+
else if (options.conditions.length > 0) {
|
|
37052
35319
|
conditions.push(...options.conditions);
|
|
37053
35320
|
}
|
|
37054
35321
|
return resolve(pkg, key, {
|
|
@@ -37211,6 +35478,7 @@ const externalTypes = [
|
|
|
37211
35478
|
'svelte',
|
|
37212
35479
|
'marko',
|
|
37213
35480
|
'astro',
|
|
35481
|
+
'imba',
|
|
37214
35482
|
// JSX/TSX may be configured to be compiled differently from how esbuild
|
|
37215
35483
|
// handles it by default, so exclude them as well
|
|
37216
35484
|
'jsx',
|
|
@@ -38982,12 +37250,12 @@ var convertSourceMap = {};
|
|
|
38982
37250
|
} (convertSourceMap));
|
|
38983
37251
|
|
|
38984
37252
|
function totalist(dir, callback, pre='') {
|
|
38985
|
-
dir = resolve$
|
|
37253
|
+
dir = resolve$4('.', dir);
|
|
38986
37254
|
let arr = readdirSync(dir);
|
|
38987
37255
|
let i=0, abs, stats;
|
|
38988
37256
|
for (; i < arr.length; i++) {
|
|
38989
37257
|
abs = join$1(dir, arr[i]);
|
|
38990
|
-
stats = statSync$
|
|
37258
|
+
stats = statSync$1(abs);
|
|
38991
37259
|
stats.isDirectory()
|
|
38992
37260
|
? totalist(abs, callback, join$1(pre, arr[i]))
|
|
38993
37261
|
: callback(join$1(pre, arr[i]), abs, stats);
|
|
@@ -39141,7 +37409,7 @@ function toHeaders(name, stats, isEtag) {
|
|
|
39141
37409
|
}
|
|
39142
37410
|
|
|
39143
37411
|
function sirv (dir, opts={}) {
|
|
39144
|
-
dir = resolve$
|
|
37412
|
+
dir = resolve$4(dir || '.');
|
|
39145
37413
|
|
|
39146
37414
|
let isNotFound = opts.onNoMatch || is404;
|
|
39147
37415
|
let setHeaders = opts.setHeaders || noop$2;
|
|
@@ -39502,6 +37770,7 @@ async function loadAndTransform(id, url, server, options, timestamp) {
|
|
|
39502
37770
|
try {
|
|
39503
37771
|
map = (convertSourceMap.fromSource(code) ||
|
|
39504
37772
|
convertSourceMap.fromMapFileSource(code, path$n.dirname(file)))?.toObject();
|
|
37773
|
+
code = code.replace(convertSourceMap.mapFileCommentRegex, blankReplacer);
|
|
39505
37774
|
}
|
|
39506
37775
|
catch (e) {
|
|
39507
37776
|
logger.warn(`Failed to load source map for ${url}.`, {
|
|
@@ -42754,7 +41023,7 @@ async function createPluginContainer(config, moduleGraph, watcher) {
|
|
|
42754
41023
|
// TODO: use import()
|
|
42755
41024
|
const _require = createRequire$1(import.meta.url);
|
|
42756
41025
|
// get rollup version
|
|
42757
|
-
const rollupPkgPath = resolve$
|
|
41026
|
+
const rollupPkgPath = resolve$6(_require.resolve('rollup'), '../../package.json');
|
|
42758
41027
|
const minimalContext = {
|
|
42759
41028
|
meta: {
|
|
42760
41029
|
rollupVersion: JSON.parse(fs$l.readFileSync(rollupPkgPath, 'utf-8'))
|
|
@@ -42979,6 +41248,10 @@ async function createPluginContainer(config, moduleGraph, watcher) {
|
|
|
42979
41248
|
this.filename = filename;
|
|
42980
41249
|
this.originalCode = code;
|
|
42981
41250
|
if (inMap) {
|
|
41251
|
+
if (isDebugSourcemapCombineFocused) {
|
|
41252
|
+
// @ts-expect-error inject name for debug purpose
|
|
41253
|
+
inMap.name = '$inMap';
|
|
41254
|
+
}
|
|
42982
41255
|
this.sourcemapChain.push(inMap);
|
|
42983
41256
|
}
|
|
42984
41257
|
}
|
|
@@ -43189,7 +41462,7 @@ async function createPluginContainer(config, moduleGraph, watcher) {
|
|
|
43189
41462
|
}
|
|
43190
41463
|
|
|
43191
41464
|
const debug$8 = createDebugger('vite:deps');
|
|
43192
|
-
const htmlTypesRE = /\.(html|vue|svelte|astro)$/;
|
|
41465
|
+
const htmlTypesRE = /\.(html|vue|svelte|astro|imba)$/;
|
|
43193
41466
|
// A simple regex to detect import sources. This is only used on
|
|
43194
41467
|
// <script lang="ts"> blocks in vue (setup only) or svelte files, since
|
|
43195
41468
|
// seemingly unused imports are dropped by esbuild when transpiling TS which
|
|
@@ -46205,7 +44478,7 @@ function cssPlugin(config) {
|
|
|
46205
44478
|
return publicFileToBuiltUrl(url, config);
|
|
46206
44479
|
}
|
|
46207
44480
|
else {
|
|
46208
|
-
return config.base
|
|
44481
|
+
return joinUrlSegments(config.base, url);
|
|
46209
44482
|
}
|
|
46210
44483
|
}
|
|
46211
44484
|
const resolved = await resolveUrl(url, importer);
|
|
@@ -46233,7 +44506,6 @@ function cssPlugin(config) {
|
|
|
46233
44506
|
// server only logic for handling CSS @import dependency hmr
|
|
46234
44507
|
const { moduleGraph } = server;
|
|
46235
44508
|
const thisModule = moduleGraph.getModuleById(id);
|
|
46236
|
-
const devBase = config.base;
|
|
46237
44509
|
if (thisModule) {
|
|
46238
44510
|
// CSS modules cannot self-accept since it exports values
|
|
46239
44511
|
const isSelfAccepting = !modules && !inlineRE.test(id) && !htmlProxyRE.test(id);
|
|
@@ -46241,6 +44513,7 @@ function cssPlugin(config) {
|
|
|
46241
44513
|
// record deps in the module graph so edits to @import css can trigger
|
|
46242
44514
|
// main import to hot update
|
|
46243
44515
|
const depModules = new Set();
|
|
44516
|
+
const devBase = config.base;
|
|
46244
44517
|
for (const file of deps) {
|
|
46245
44518
|
depModules.add(isCSSRequest(file)
|
|
46246
44519
|
? moduleGraph.createFileOnlyEntry(file)
|
|
@@ -46339,9 +44612,8 @@ function cssPostPlugin(config) {
|
|
|
46339
44612
|
return `export default ${JSON.stringify(css)}`;
|
|
46340
44613
|
}
|
|
46341
44614
|
const cssContent = await getContentWithSourcemap(css);
|
|
46342
|
-
const devBase = config.base;
|
|
46343
44615
|
const code = [
|
|
46344
|
-
`import { updateStyle as __vite__updateStyle, removeStyle as __vite__removeStyle } from ${JSON.stringify(path$n.posix.join(
|
|
44616
|
+
`import { updateStyle as __vite__updateStyle, removeStyle as __vite__removeStyle } from ${JSON.stringify(path$n.posix.join(config.base, CLIENT_PUBLIC_PATH))}`,
|
|
46345
44617
|
`const __vite__id = ${JSON.stringify(id)}`,
|
|
46346
44618
|
`const __vite__css = ${JSON.stringify(cssContent)}`,
|
|
46347
44619
|
`__vite__updateStyle(__vite__id, __vite__css)`,
|
|
@@ -46698,7 +44970,7 @@ async function compileCSS(id, code, config, urlReplacer) {
|
|
|
46698
44970
|
}));
|
|
46699
44971
|
}
|
|
46700
44972
|
if (isModule) {
|
|
46701
|
-
postcssPlugins.unshift((await import('./dep-
|
|
44973
|
+
postcssPlugins.unshift((await import('./dep-6873f27c.js').then(function (n) { return n.i; })).default({
|
|
46702
44974
|
...modulesOptions,
|
|
46703
44975
|
getJSON(cssFileName, _modules, outputFileName) {
|
|
46704
44976
|
modules = _modules;
|
|
@@ -47559,15 +45831,15 @@ function ssrManifestPlugin(config) {
|
|
|
47559
45831
|
const normalizedId = normalizePath$3(relative$2(config.root, id));
|
|
47560
45832
|
const mappedChunks = ssrManifest[normalizedId] ?? (ssrManifest[normalizedId] = []);
|
|
47561
45833
|
if (!chunk.isEntry) {
|
|
47562
|
-
mappedChunks.push(base
|
|
45834
|
+
mappedChunks.push(joinUrlSegments(base, chunk.fileName));
|
|
47563
45835
|
// <link> tags for entry chunks are already generated in static HTML,
|
|
47564
45836
|
// so we only need to record info for non-entry chunks.
|
|
47565
45837
|
chunk.viteMetadata.importedCss.forEach((file) => {
|
|
47566
|
-
mappedChunks.push(base
|
|
45838
|
+
mappedChunks.push(joinUrlSegments(base, file));
|
|
47567
45839
|
});
|
|
47568
45840
|
}
|
|
47569
45841
|
chunk.viteMetadata.importedAssets.forEach((file) => {
|
|
47570
|
-
mappedChunks.push(base
|
|
45842
|
+
mappedChunks.push(joinUrlSegments(base, file));
|
|
47571
45843
|
});
|
|
47572
45844
|
}
|
|
47573
45845
|
if (chunk.code.includes(preloadMethod)) {
|
|
@@ -47598,7 +45870,7 @@ function ssrManifestPlugin(config) {
|
|
|
47598
45870
|
const chunk = bundle[filename];
|
|
47599
45871
|
if (chunk) {
|
|
47600
45872
|
chunk.viteMetadata.importedCss.forEach((file) => {
|
|
47601
|
-
deps.push(
|
|
45873
|
+
deps.push(joinUrlSegments(base, file)); // TODO:base
|
|
47602
45874
|
});
|
|
47603
45875
|
chunk.imports.forEach(addDeps);
|
|
47604
45876
|
}
|
|
@@ -47969,14 +46241,6 @@ function loadEnv(mode, envDir, prefixes = 'VITE_') {
|
|
|
47969
46241
|
/** mode file */ `.env.${mode}`,
|
|
47970
46242
|
/** mode local file */ `.env.${mode}.local`
|
|
47971
46243
|
];
|
|
47972
|
-
// check if there are actual env variables starting with VITE_*
|
|
47973
|
-
// these are typically provided inline and should be prioritized
|
|
47974
|
-
for (const key in process.env) {
|
|
47975
|
-
if (prefixes.some((prefix) => key.startsWith(prefix)) &&
|
|
47976
|
-
env[key] === undefined) {
|
|
47977
|
-
env[key] = process.env[key];
|
|
47978
|
-
}
|
|
47979
|
-
}
|
|
47980
46244
|
const parsed = Object.fromEntries(envFiles.flatMap((file) => {
|
|
47981
46245
|
const path = lookupFile(envDir, [file], {
|
|
47982
46246
|
pathOnly: true,
|
|
@@ -48005,6 +46269,13 @@ function loadEnv(mode, envDir, prefixes = 'VITE_') {
|
|
|
48005
46269
|
process.env.VITE_USER_NODE_ENV = value;
|
|
48006
46270
|
}
|
|
48007
46271
|
}
|
|
46272
|
+
// check if there are actual env variables starting with VITE_*
|
|
46273
|
+
// these are typically provided inline and should be prioritized
|
|
46274
|
+
for (const key in process.env) {
|
|
46275
|
+
if (prefixes.some((prefix) => key.startsWith(prefix))) {
|
|
46276
|
+
env[key] = process.env[key];
|
|
46277
|
+
}
|
|
46278
|
+
}
|
|
48008
46279
|
return env;
|
|
48009
46280
|
}
|
|
48010
46281
|
function resolveEnvPrefix({ envPrefix = 'VITE_' }) {
|
|
@@ -48613,7 +46884,7 @@ function toOutputFilePathInJS(filename, type, hostId, hostType, config, toRelati
|
|
|
48613
46884
|
if (relative && !config.build.ssr) {
|
|
48614
46885
|
return toRelative(filename, hostId);
|
|
48615
46886
|
}
|
|
48616
|
-
return config.base
|
|
46887
|
+
return joinUrlSegments(config.base, filename);
|
|
48617
46888
|
}
|
|
48618
46889
|
function createToImportMetaURLBasedRelativeRuntime(format) {
|
|
48619
46890
|
const toRelativePath = relativeUrlMechanisms[format];
|
|
@@ -55891,7 +54162,7 @@ async function instantiateModule(url, server, context = { global }, urlStack = [
|
|
|
55891
54162
|
mod.ssrModule = ssrModule;
|
|
55892
54163
|
const ssrImportMeta = {
|
|
55893
54164
|
// The filesystem URL, matching native Node.js modules
|
|
55894
|
-
url: pathToFileURL(mod.file).toString()
|
|
54165
|
+
url: pathToFileURL$1(mod.file).toString()
|
|
55895
54166
|
};
|
|
55896
54167
|
urlStack = urlStack.concat(url);
|
|
55897
54168
|
const isCircular = (url) => urlStack.includes(url);
|
|
@@ -56036,7 +54307,7 @@ async function nodeImport(id, importer, resolveOptions) {
|
|
|
56036
54307
|
? { ...resolveOptions, tryEsmOnly: true }
|
|
56037
54308
|
: resolveOptions);
|
|
56038
54309
|
if (usingDynamicImport) {
|
|
56039
|
-
url = pathToFileURL(url).toString();
|
|
54310
|
+
url = pathToFileURL$1(url).toString();
|
|
56040
54311
|
}
|
|
56041
54312
|
}
|
|
56042
54313
|
try {
|
|
@@ -60555,7 +58826,7 @@ function createWebSocketServer(server, config, httpsOptions) {
|
|
|
60555
58826
|
|
|
60556
58827
|
// this middleware is only active when (config.base !== '/')
|
|
60557
58828
|
function baseMiddleware({ config }) {
|
|
60558
|
-
const devBase = config.base;
|
|
58829
|
+
const devBase = config.base.endsWith('/') ? config.base : config.base + '/';
|
|
60559
58830
|
// Keep the named function. The name is visible in debug logs via `DEBUG=connect:dispatcher ...`
|
|
60560
58831
|
return function viteBaseMiddleware(req, res, next) {
|
|
60561
58832
|
const url = req.url;
|
|
@@ -60574,18 +58845,18 @@ function baseMiddleware({ config }) {
|
|
|
60574
58845
|
if (path === '/' || path === '/index.html') {
|
|
60575
58846
|
// redirect root visit to based url with search and hash
|
|
60576
58847
|
res.writeHead(302, {
|
|
60577
|
-
Location:
|
|
58848
|
+
Location: config.base + (parsed.search || '') + (parsed.hash || '')
|
|
60578
58849
|
});
|
|
60579
58850
|
res.end();
|
|
60580
58851
|
return;
|
|
60581
58852
|
}
|
|
60582
58853
|
else if (req.headers.accept?.includes('text/html')) {
|
|
60583
58854
|
// non-based page visit
|
|
60584
|
-
const redirectPath =
|
|
58855
|
+
const redirectPath = joinUrlSegments(config.base, url);
|
|
60585
58856
|
res.writeHead(404, {
|
|
60586
58857
|
'Content-Type': 'text/html'
|
|
60587
58858
|
});
|
|
60588
|
-
res.end(`The server is configured with a public base URL of ${
|
|
58859
|
+
res.end(`The server is configured with a public base URL of ${config.base} - ` +
|
|
60589
58860
|
`did you mean to visit <a href="${redirectPath}">${redirectPath}</a> instead?`);
|
|
60590
58861
|
return;
|
|
60591
58862
|
}
|
|
@@ -61397,7 +59668,7 @@ var URL$1 = url.URL;
|
|
|
61397
59668
|
var http$1 = require$$1$1;
|
|
61398
59669
|
var https$1 = require$$1$2;
|
|
61399
59670
|
var Writable = require$$0$7.Writable;
|
|
61400
|
-
var assert = assert$
|
|
59671
|
+
var assert = assert$1;
|
|
61401
59672
|
var debug$2 = debug_1;
|
|
61402
59673
|
|
|
61403
59674
|
// Create handlers that pass events from native requests
|
|
@@ -63073,7 +61344,8 @@ const processNodeUrl = (attr, sourceCodeLocation, s, config, htmlPath, originalU
|
|
|
63073
61344
|
const devBase = config.base;
|
|
63074
61345
|
if (startsWithSingleSlashRE.test(url)) {
|
|
63075
61346
|
// prefix with base (dev only, base is never relative)
|
|
63076
|
-
|
|
61347
|
+
const fullUrl = joinUrlSegments(devBase, url);
|
|
61348
|
+
overwriteAttrValue(s, sourceCodeLocation, fullUrl);
|
|
63077
61349
|
}
|
|
63078
61350
|
else if (url.startsWith('.') &&
|
|
63079
61351
|
originalUrl &&
|
|
@@ -63098,7 +61370,7 @@ const devHtmlHook = async (html, { path: htmlPath, filename, server, originalUrl
|
|
|
63098
61370
|
const trailingSlash = htmlPath.endsWith('/');
|
|
63099
61371
|
if (!trailingSlash && fs$l.existsSync(filename)) {
|
|
63100
61372
|
proxyModulePath = htmlPath;
|
|
63101
|
-
proxyModuleUrl = base
|
|
61373
|
+
proxyModuleUrl = joinUrlSegments(base, htmlPath);
|
|
63102
61374
|
}
|
|
63103
61375
|
else {
|
|
63104
61376
|
// There are users of vite.transformIndexHtml calling it with url '/'
|
|
@@ -64736,8 +63008,7 @@ async function createServer(inlineConfig = {}) {
|
|
|
64736
63008
|
middlewares.use(proxyMiddleware(httpServer, proxy, config));
|
|
64737
63009
|
}
|
|
64738
63010
|
// base
|
|
64739
|
-
|
|
64740
|
-
if (devBase !== '/') {
|
|
63011
|
+
if (config.base !== '/') {
|
|
64741
63012
|
middlewares.use(baseMiddleware(server));
|
|
64742
63013
|
}
|
|
64743
63014
|
// open in editor support
|
|
@@ -64822,7 +63093,6 @@ async function startServer(server, inlinePort, isRestart = false) {
|
|
|
64822
63093
|
const hostname = await resolveHostname(options.host);
|
|
64823
63094
|
const protocol = options.https ? 'https' : 'http';
|
|
64824
63095
|
const info = server.config.logger.info;
|
|
64825
|
-
const devBase = server.config.base;
|
|
64826
63096
|
const serverPort = await httpServerStart(httpServer, {
|
|
64827
63097
|
port,
|
|
64828
63098
|
strictPort: options.strictPort,
|
|
@@ -64845,7 +63115,7 @@ async function startServer(server, inlinePort, isRestart = false) {
|
|
|
64845
63115
|
});
|
|
64846
63116
|
}
|
|
64847
63117
|
if (options.open && !isRestart) {
|
|
64848
|
-
const path = typeof options.open === 'string' ? options.open :
|
|
63118
|
+
const path = typeof options.open === 'string' ? options.open : server.config.base;
|
|
64849
63119
|
openBrowser(path.startsWith('http')
|
|
64850
63120
|
? path
|
|
64851
63121
|
: `${protocol}://${hostname.name}:${serverPort}${path}`, true, server.config.logger);
|
|
@@ -65666,27 +63936,40 @@ async function bundleConfigFile(fileName, isESM) {
|
|
|
65666
63936
|
{
|
|
65667
63937
|
name: 'externalize-deps',
|
|
65668
63938
|
setup(build) {
|
|
63939
|
+
const options = {
|
|
63940
|
+
root: path$n.dirname(fileName),
|
|
63941
|
+
isBuild: true,
|
|
63942
|
+
isProduction: true,
|
|
63943
|
+
isRequire: !isESM,
|
|
63944
|
+
preferRelative: false,
|
|
63945
|
+
tryIndex: true,
|
|
63946
|
+
mainFields: [],
|
|
63947
|
+
browserField: false,
|
|
63948
|
+
conditions: [],
|
|
63949
|
+
overrideConditions: ['node'],
|
|
63950
|
+
dedupe: [],
|
|
63951
|
+
extensions: DEFAULT_EXTENSIONS$1,
|
|
63952
|
+
preserveSymlinks: false
|
|
63953
|
+
};
|
|
65669
63954
|
// externalize bare imports
|
|
65670
63955
|
build.onResolve({ filter: /^[^.].*/ }, async ({ path: id, importer, kind }) => {
|
|
65671
|
-
if (kind === 'entry-point' ||
|
|
63956
|
+
if (kind === 'entry-point' ||
|
|
63957
|
+
path$n.isAbsolute(id) ||
|
|
63958
|
+
isBuiltin(id)) {
|
|
65672
63959
|
return;
|
|
65673
63960
|
}
|
|
65674
63961
|
// partial deno support as `npm:` does not work with esbuild
|
|
65675
63962
|
if (id.startsWith('npm:')) {
|
|
65676
63963
|
return { external: true };
|
|
65677
63964
|
}
|
|
65678
|
-
|
|
65679
|
-
|
|
65680
|
-
|
|
65681
|
-
let resolved;
|
|
65682
|
-
if (resolveWithRequire) {
|
|
65683
|
-
const require = createRequire$1(importer);
|
|
65684
|
-
resolved = require.resolve(id);
|
|
63965
|
+
let idFsPath = tryNodeResolve(id, importer, options, false)?.id;
|
|
63966
|
+
if (idFsPath && (isESM || kind === 'dynamic-import')) {
|
|
63967
|
+
idFsPath = pathToFileURL$1(idFsPath).href;
|
|
65685
63968
|
}
|
|
65686
|
-
|
|
65687
|
-
|
|
65688
|
-
|
|
65689
|
-
|
|
63969
|
+
return {
|
|
63970
|
+
path: idFsPath,
|
|
63971
|
+
external: true
|
|
63972
|
+
};
|
|
65690
63973
|
});
|
|
65691
63974
|
}
|
|
65692
63975
|
},
|
|
@@ -65697,7 +63980,7 @@ async function bundleConfigFile(fileName, isESM) {
|
|
|
65697
63980
|
const contents = await fs$l.promises.readFile(args.path, 'utf8');
|
|
65698
63981
|
const injectValues = `const ${dirnameVarName} = ${JSON.stringify(path$n.dirname(args.path))};` +
|
|
65699
63982
|
`const ${filenameVarName} = ${JSON.stringify(args.path)};` +
|
|
65700
|
-
`const ${importMetaUrlVarName} = ${JSON.stringify(pathToFileURL(args.path).href)};`;
|
|
63983
|
+
`const ${importMetaUrlVarName} = ${JSON.stringify(pathToFileURL$1(args.path).href)};`;
|
|
65701
63984
|
return {
|
|
65702
63985
|
loader: args.path.endsWith('ts') ? 'ts' : 'js',
|
|
65703
63986
|
contents: injectValues + contents
|
|
@@ -65721,7 +64004,7 @@ async function loadConfigFromBundledFile(fileName, bundledCode, isESM) {
|
|
|
65721
64004
|
if (isESM) {
|
|
65722
64005
|
const fileBase = `${fileName}.timestamp-${Date.now()}`;
|
|
65723
64006
|
const fileNameTmp = `${fileBase}.mjs`;
|
|
65724
|
-
const fileUrl = `${pathToFileURL(fileBase)}.mjs`;
|
|
64007
|
+
const fileUrl = `${pathToFileURL$1(fileBase)}.mjs`;
|
|
65725
64008
|
fs$l.writeFileSync(fileNameTmp, bundledCode);
|
|
65726
64009
|
try {
|
|
65727
64010
|
return (await dynamicImport(fileUrl)).default;
|