vite 5.1.0-beta.5 → 5.1.0-beta.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/client.mjs +8 -0
- package/dist/client/client.mjs.map +1 -1
- package/dist/node/chunks/{dep-Y86Adl1p.js → dep-G1t0FnMB.js} +249 -50
- package/dist/node/chunks/{dep-AgYU8wIQ.js → dep-go6jvlFO.js} +1 -1
- package/dist/node/chunks/{dep-JW1Wr5se.js → dep-ma2Y1b9q.js} +1 -1
- package/dist/node/cli.js +6 -6
- package/dist/node/index.d.ts +76 -3
- package/dist/node/index.js +110 -5
- package/dist/node/runtime.d.ts +12 -0
- package/dist/node/runtime.js +1614 -0
- package/dist/node/types.d-jgA8ss1A.d.ts +324 -0
- package/package.json +13 -2
- package/types/hmrPayload.d.ts +2 -0
@@ -32,10 +32,10 @@ import assert$1 from 'node:assert';
|
|
32
32
|
import v8 from 'node:v8';
|
33
33
|
import { Worker as Worker$1 } from 'node:worker_threads';
|
34
34
|
import { Buffer as Buffer$1 } from 'node:buffer';
|
35
|
+
import { EventEmitter as EventEmitter$4 } from 'node:events';
|
35
36
|
import { parseAst, parseAstAsync } from 'rollup/parseAst';
|
36
37
|
import * as qs from 'querystring';
|
37
38
|
import readline from 'node:readline';
|
38
|
-
import { EventEmitter as EventEmitter$4 } from 'node:events';
|
39
39
|
import require$$0$b from 'zlib';
|
40
40
|
import require$$0$c from 'buffer';
|
41
41
|
import require$$1$1 from 'https';
|
@@ -32002,8 +32002,8 @@ function createCachedImport(imp) {
|
|
32002
32002
|
return cached;
|
32003
32003
|
};
|
32004
32004
|
}
|
32005
|
-
const importPostcssImport = createCachedImport(() => import('./dep-
|
32006
|
-
const importPostcssModules = createCachedImport(() => import('./dep-
|
32005
|
+
const importPostcssImport = createCachedImport(() => import('./dep-ma2Y1b9q.js').then(function (n) { return n.i; }));
|
32006
|
+
const importPostcssModules = createCachedImport(() => import('./dep-go6jvlFO.js').then(function (n) { return n.i; }));
|
32007
32007
|
const importPostcss = createCachedImport(() => import('postcss'));
|
32008
32008
|
const preprocessorWorkerControllerCache = new WeakMap();
|
32009
32009
|
let alwaysFakeWorkerWorkerControllerCache;
|
@@ -46850,9 +46850,11 @@ const cachedFsUtilsMap = new WeakMap();
|
|
46850
46850
|
function getFsUtils(config) {
|
46851
46851
|
let fsUtils = cachedFsUtilsMap.get(config);
|
46852
46852
|
if (!fsUtils) {
|
46853
|
-
if (config.command !== 'serve' ||
|
46854
|
-
|
46855
|
-
|
46853
|
+
if (config.command !== 'serve' ||
|
46854
|
+
config.server.fs.cachedChecks === false ||
|
46855
|
+
config.server.watch?.ignored) {
|
46856
|
+
// cached fsUtils is only used in the dev server for now
|
46857
|
+
// it is enabled by default only when there aren't custom watcher ignored patterns configured
|
46856
46858
|
fsUtils = commonFsUtils;
|
46857
46859
|
}
|
46858
46860
|
else if (!config.resolve.preserveSymlinks &&
|
@@ -46931,11 +46933,11 @@ function createCachedFsUtils(config) {
|
|
46931
46933
|
return;
|
46932
46934
|
}
|
46933
46935
|
if (nextDirentCache.type === 'directory_maybe_symlink') {
|
46934
|
-
dirPath ??= pathUntilPart(root, parts, i);
|
46936
|
+
dirPath ??= pathUntilPart(root, parts, i + 1);
|
46935
46937
|
const isSymlink = fs$l
|
46936
46938
|
.lstatSync(dirPath, { throwIfNoEntry: false })
|
46937
46939
|
?.isSymbolicLink();
|
46938
|
-
|
46940
|
+
nextDirentCache.type = isSymlink ? 'symlink' : 'directory';
|
46939
46941
|
}
|
46940
46942
|
direntCache = nextDirentCache;
|
46941
46943
|
}
|
@@ -50935,15 +50937,16 @@ function orderedDependencies(deps) {
|
|
50935
50937
|
return Object.fromEntries(depsList);
|
50936
50938
|
}
|
50937
50939
|
function globEntries(pattern, config) {
|
50940
|
+
const rootPattern = glob.convertPathToPattern(config.root);
|
50938
50941
|
return glob(pattern, {
|
50939
50942
|
cwd: config.root,
|
50940
50943
|
ignore: [
|
50941
|
-
|
50942
|
-
|
50944
|
+
`${rootPattern}/**/node_modules/**`,
|
50945
|
+
`${rootPattern}/**/${config.build.outDir}/**`,
|
50943
50946
|
// if there aren't explicit entries, also ignore other common folders
|
50944
50947
|
...(config.optimizeDeps.entries
|
50945
50948
|
? []
|
50946
|
-
: [
|
50949
|
+
: [`${rootPattern}/**/__tests__/**`, `${rootPattern}/**/coverage/**`]),
|
50947
50950
|
],
|
50948
50951
|
absolute: true,
|
50949
50952
|
suppressErrors: true, // suppress EACCES errors
|
@@ -53371,12 +53374,37 @@ function transformRequest(url, server, options = {}) {
|
|
53371
53374
|
async function doTransform(url, server, options, timestamp) {
|
53372
53375
|
url = removeTimestampQuery(url);
|
53373
53376
|
const { config, pluginContainer } = server;
|
53374
|
-
const prettyUrl = debugCache$1 ? prettifyUrl(url, config.root) : '';
|
53375
53377
|
const ssr = !!options.ssr;
|
53376
53378
|
if (ssr && isDepsOptimizerEnabled(config, true)) {
|
53377
53379
|
await initDevSsrDepsOptimizer(config, server);
|
53378
53380
|
}
|
53379
|
-
|
53381
|
+
let module = await server.moduleGraph.getModuleByUrl(url, ssr);
|
53382
|
+
if (module) {
|
53383
|
+
// try use cache from url
|
53384
|
+
const cached = await getCachedTransformResult(url, module, server, ssr, timestamp);
|
53385
|
+
if (cached)
|
53386
|
+
return cached;
|
53387
|
+
}
|
53388
|
+
const resolved = module
|
53389
|
+
? undefined
|
53390
|
+
: (await pluginContainer.resolveId(url, undefined, { ssr })) ?? undefined;
|
53391
|
+
// resolve
|
53392
|
+
const id = module?.id ?? resolved?.id ?? url;
|
53393
|
+
module ??= server.moduleGraph.getModuleById(id);
|
53394
|
+
if (module) {
|
53395
|
+
// if a different url maps to an existing loaded id, make sure we relate this url to the id
|
53396
|
+
await server.moduleGraph._ensureEntryFromUrl(url, ssr, undefined, resolved);
|
53397
|
+
// try use cache from id
|
53398
|
+
const cached = await getCachedTransformResult(url, module, server, ssr, timestamp);
|
53399
|
+
if (cached)
|
53400
|
+
return cached;
|
53401
|
+
}
|
53402
|
+
const result = loadAndTransform(id, url, server, options, timestamp, module, resolved);
|
53403
|
+
getDepsOptimizer(config, ssr)?.delayDepsOptimizerUntil(id, () => result);
|
53404
|
+
return result;
|
53405
|
+
}
|
53406
|
+
async function getCachedTransformResult(url, module, server, ssr, timestamp) {
|
53407
|
+
const prettyUrl = debugCache$1 ? prettifyUrl(url, server.config.root) : '';
|
53380
53408
|
// tries to handle soft invalidation of the module if available,
|
53381
53409
|
// returns a boolean true is successful, or false if no handling is needed
|
53382
53410
|
const softInvalidatedTransformResult = module &&
|
@@ -53391,14 +53419,6 @@ async function doTransform(url, server, options, timestamp) {
|
|
53391
53419
|
debugCache$1?.(`[memory] ${prettyUrl}`);
|
53392
53420
|
return cached;
|
53393
53421
|
}
|
53394
|
-
const resolved = module
|
53395
|
-
? undefined
|
53396
|
-
: (await pluginContainer.resolveId(url, undefined, { ssr })) ?? undefined;
|
53397
|
-
// resolve
|
53398
|
-
const id = module?.id ?? resolved?.id ?? url;
|
53399
|
-
const result = loadAndTransform(id, url, server, options, timestamp, module, resolved);
|
53400
|
-
getDepsOptimizer(config, ssr)?.delayDepsOptimizerUntil(id, () => result);
|
53401
|
-
return result;
|
53402
53422
|
}
|
53403
53423
|
async function loadAndTransform(id, url, server, options, timestamp, mod, resolved) {
|
53404
53424
|
const { config, pluginContainer, moduleGraph } = server;
|
@@ -54456,12 +54476,12 @@ function ssrFixStacktrace(e, moduleGraph) {
|
|
54456
54476
|
}
|
54457
54477
|
|
54458
54478
|
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
54459
|
-
const AsyncFunction = async function () { }.constructor;
|
54460
|
-
let fnDeclarationLineCount = 0;
|
54479
|
+
const AsyncFunction$1 = async function () { }.constructor;
|
54480
|
+
let fnDeclarationLineCount$1 = 0;
|
54461
54481
|
{
|
54462
54482
|
const body = '/*code*/';
|
54463
|
-
const source = new AsyncFunction('a', 'b', body).toString();
|
54464
|
-
fnDeclarationLineCount =
|
54483
|
+
const source = new AsyncFunction$1('a', 'b', body).toString();
|
54484
|
+
fnDeclarationLineCount$1 =
|
54465
54485
|
source.slice(0, source.indexOf(body)).split('\n').length - 1;
|
54466
54486
|
}
|
54467
54487
|
const pendingModules = new Map();
|
@@ -54591,13 +54611,13 @@ async function instantiateModule(url, server, context = { global }, urlStack = [
|
|
54591
54611
|
const moduleSourceMap = Object.assign({}, result.map, {
|
54592
54612
|
// currently we need to offset the line
|
54593
54613
|
// https://github.com/nodejs/node/issues/43047#issuecomment-1180632750
|
54594
|
-
mappings: ';'.repeat(fnDeclarationLineCount) + result.map.mappings,
|
54614
|
+
mappings: ';'.repeat(fnDeclarationLineCount$1) + result.map.mappings,
|
54595
54615
|
});
|
54596
54616
|
sourceMapSuffix =
|
54597
54617
|
'\n//# sourceMappingURL=' + genSourceMapUrl(moduleSourceMap);
|
54598
54618
|
}
|
54599
54619
|
try {
|
54600
|
-
const initModule = new AsyncFunction(`global`, ssrModuleExportsKey, ssrImportMetaKey, ssrImportKey, ssrDynamicImportKey, ssrExportAllKey, '"use strict";' +
|
54620
|
+
const initModule = new AsyncFunction$1(`global`, ssrModuleExportsKey, ssrImportMetaKey, ssrImportKey, ssrDynamicImportKey, ssrExportAllKey, '"use strict";' +
|
54601
54621
|
result.code +
|
54602
54622
|
`\n//# sourceURL=${mod.id}${sourceMapSuffix}`);
|
54603
54623
|
await initModule(context.global, ssrModule, ssrImportMeta, ssrImport, ssrDynamicImport, ssrExportAll);
|
@@ -56027,6 +56047,12 @@ class NoopWatcher extends EventEmitter$4 {
|
|
56027
56047
|
getWatched() {
|
56028
56048
|
return {};
|
56029
56049
|
}
|
56050
|
+
ref() {
|
56051
|
+
return this;
|
56052
|
+
}
|
56053
|
+
unref() {
|
56054
|
+
return this;
|
56055
|
+
}
|
56030
56056
|
async close() {
|
56031
56057
|
// noop
|
56032
56058
|
}
|
@@ -56035,6 +56061,105 @@ function createNoopWatcher(options) {
|
|
56035
56061
|
return new NoopWatcher(options);
|
56036
56062
|
}
|
56037
56063
|
|
56064
|
+
/**
|
56065
|
+
* Fetch module information for Vite runtime.
|
56066
|
+
* @experimental
|
56067
|
+
*/
|
56068
|
+
async function fetchModule(server, url, importer, options = {}) {
|
56069
|
+
// builtins should always be externalized
|
56070
|
+
if (url.startsWith('data:') || isBuiltin(url)) {
|
56071
|
+
return { externalize: url, type: 'builtin' };
|
56072
|
+
}
|
56073
|
+
if (isExternalUrl(url)) {
|
56074
|
+
return { externalize: url, type: 'network' };
|
56075
|
+
}
|
56076
|
+
if (url[0] !== '.' && url[0] !== '/') {
|
56077
|
+
const { isProduction, resolve: { dedupe, preserveSymlinks }, root, ssr, } = server.config;
|
56078
|
+
const overrideConditions = ssr.resolve?.externalConditions || [];
|
56079
|
+
const resolveOptions = {
|
56080
|
+
mainFields: ['main'],
|
56081
|
+
conditions: [],
|
56082
|
+
overrideConditions: [...overrideConditions, 'production', 'development'],
|
56083
|
+
extensions: ['.js', '.cjs', '.json'],
|
56084
|
+
dedupe,
|
56085
|
+
preserveSymlinks,
|
56086
|
+
isBuild: false,
|
56087
|
+
isProduction,
|
56088
|
+
root,
|
56089
|
+
ssrConfig: ssr,
|
56090
|
+
legacyProxySsrExternalModules: server.config.legacy?.proxySsrExternalModules,
|
56091
|
+
packageCache: server.config.packageCache,
|
56092
|
+
};
|
56093
|
+
const resolved = tryNodeResolve(url, importer, { ...resolveOptions, tryEsmOnly: true }, false, undefined, true);
|
56094
|
+
if (!resolved) {
|
56095
|
+
const err = new Error(`Cannot find module '${url}' imported from '${importer}'`);
|
56096
|
+
err.code = 'ERR_MODULE_NOT_FOUND';
|
56097
|
+
throw err;
|
56098
|
+
}
|
56099
|
+
const file = pathToFileURL(resolved.id).toString();
|
56100
|
+
const type = isFilePathESM(file, server.config.packageCache)
|
56101
|
+
? 'module'
|
56102
|
+
: 'commonjs';
|
56103
|
+
return { externalize: file, type };
|
56104
|
+
}
|
56105
|
+
url = unwrapId(url);
|
56106
|
+
let result = await server.transformRequest(url, { ssr: true });
|
56107
|
+
if (!result) {
|
56108
|
+
throw new Error(`[vite] transform failed for module '${url}'${importer ? ` imported from '${importer}'` : ''}.`);
|
56109
|
+
}
|
56110
|
+
// module entry should be created by transformRequest
|
56111
|
+
const mod = await server.moduleGraph.getModuleByUrl(url, true);
|
56112
|
+
if (!mod) {
|
56113
|
+
throw new Error(`[vite] cannot find module '${url}' ${importer ? ` imported from '${importer}'` : ''}.`);
|
56114
|
+
}
|
56115
|
+
if (options.inlineSourceMap !== false) {
|
56116
|
+
result = inlineSourceMap(mod, result, options.processSourceMap);
|
56117
|
+
}
|
56118
|
+
// remove shebang
|
56119
|
+
if (result.code[0] === '#')
|
56120
|
+
result.code = result.code.replace(/^#!.*/, (s) => ' '.repeat(s.length));
|
56121
|
+
return { code: result.code, file: mod.file };
|
56122
|
+
}
|
56123
|
+
let SOURCEMAPPING_URL = 'sourceMa';
|
56124
|
+
SOURCEMAPPING_URL += 'ppingURL';
|
56125
|
+
const VITE_RUNTIME_SOURCEMAPPING_SOURCE = '//# sourceMappingSource=vite-runtime';
|
56126
|
+
const VITE_RUNTIME_SOURCEMAPPING_URL = `${SOURCEMAPPING_URL}=data:application/json;charset=utf-8`;
|
56127
|
+
function inlineSourceMap(mod, result, processSourceMap) {
|
56128
|
+
const map = result.map;
|
56129
|
+
let code = result.code;
|
56130
|
+
if (!map ||
|
56131
|
+
!('version' in map) ||
|
56132
|
+
code.includes(VITE_RUNTIME_SOURCEMAPPING_SOURCE))
|
56133
|
+
return result;
|
56134
|
+
// to reduce the payload size, we only inline vite node source map, because it's also the only one we use
|
56135
|
+
const OTHER_SOURCE_MAP_REGEXP = new RegExp(`//# ${SOURCEMAPPING_URL}=data:application/json[^,]+base64,([A-Za-z0-9+/=]+)$`, 'gm');
|
56136
|
+
while (OTHER_SOURCE_MAP_REGEXP.test(code))
|
56137
|
+
code = code.replace(OTHER_SOURCE_MAP_REGEXP, '');
|
56138
|
+
const sourceMap = Buffer.from(JSON.stringify(processSourceMap?.(map) || map), 'utf-8').toString('base64');
|
56139
|
+
result.code = `${code.trimEnd()}\n//# sourceURL=${mod.id}\n${VITE_RUNTIME_SOURCEMAPPING_SOURCE}\n//# ${VITE_RUNTIME_SOURCEMAPPING_URL};base64,${sourceMap}\n`;
|
56140
|
+
return result;
|
56141
|
+
}
|
56142
|
+
|
56143
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
56144
|
+
const AsyncFunction = async function () { }.constructor;
|
56145
|
+
const fnDeclarationLineCount = (() => {
|
56146
|
+
const body = '/*code*/';
|
56147
|
+
const source = new AsyncFunction('a', 'b', body).toString();
|
56148
|
+
return source.slice(0, source.indexOf(body)).split('\n').length - 1;
|
56149
|
+
})();
|
56150
|
+
function ssrFetchModule(server, id, importer) {
|
56151
|
+
return fetchModule(server, id, importer, {
|
56152
|
+
processSourceMap(map) {
|
56153
|
+
// this assumes that "new AsyncFunction" is used to create the module
|
56154
|
+
return Object.assign({}, map, {
|
56155
|
+
// currently we need to offset the line
|
56156
|
+
// https://github.com/nodejs/node/issues/43047#issuecomment-1180632750
|
56157
|
+
mappings: ';'.repeat(fnDeclarationLineCount) + map.mappings,
|
56158
|
+
});
|
56159
|
+
},
|
56160
|
+
});
|
56161
|
+
}
|
56162
|
+
|
56038
56163
|
var bufferUtil$1 = {exports: {}};
|
56039
56164
|
|
56040
56165
|
var constants = {
|
@@ -64027,7 +64152,9 @@ async function _createServer(inlineConfig = {}, options) {
|
|
64027
64152
|
? null
|
64028
64153
|
: await resolveHttpServer(serverConfig, middlewares, httpsOptions);
|
64029
64154
|
const ws = createWebSocketServer(httpServer, config, httpsOptions);
|
64030
|
-
const hot = createHMRBroadcaster()
|
64155
|
+
const hot = createHMRBroadcaster()
|
64156
|
+
.addChannel(ws)
|
64157
|
+
.addChannel(createServerHMRChannel());
|
64031
64158
|
if (typeof config.server.hmr === 'object' && config.server.hmr.channels) {
|
64032
64159
|
config.server.hmr.channels.forEach((channel) => hot.addChannel(channel));
|
64033
64160
|
}
|
@@ -64086,6 +64213,9 @@ async function _createServer(inlineConfig = {}, options) {
|
|
64086
64213
|
async ssrLoadModule(url, opts) {
|
64087
64214
|
return ssrLoadModule(url, server, undefined, undefined, opts?.fixStacktrace);
|
64088
64215
|
},
|
64216
|
+
async ssrFetchModule(url, importer) {
|
64217
|
+
return ssrFetchModule(server, url, importer);
|
64218
|
+
},
|
64089
64219
|
ssrFixStacktrace(e) {
|
64090
64220
|
ssrFixStacktrace(e, moduleGraph);
|
64091
64221
|
},
|
@@ -64493,7 +64623,7 @@ function resolveServerOptions(root, raw, logger) {
|
|
64493
64623
|
strict: server.fs?.strict ?? true,
|
64494
64624
|
allow: allowDirs,
|
64495
64625
|
deny,
|
64496
|
-
cachedChecks: server.fs?.cachedChecks
|
64626
|
+
cachedChecks: server.fs?.cachedChecks,
|
64497
64627
|
};
|
64498
64628
|
if (server.origin?.endsWith('/')) {
|
64499
64629
|
server.origin = server.origin.slice(0, -1);
|
@@ -64687,6 +64817,9 @@ function updateModules(file, modules, timestamp, { config, hot, moduleGraph }, a
|
|
64687
64817
|
? isExplicitImportRequired(acceptedVia.url)
|
64688
64818
|
: false,
|
64689
64819
|
isWithinCircularImport,
|
64820
|
+
// browser modules are invalidated by changing ?t= query,
|
64821
|
+
// but in ssr we control the module system, so we can directly remove them form cache
|
64822
|
+
ssrInvalidates: getSSRInvalidatedImporters(acceptedVia),
|
64690
64823
|
})));
|
64691
64824
|
}
|
64692
64825
|
if (needFullReload) {
|
@@ -64710,6 +64843,24 @@ function updateModules(file, modules, timestamp, { config, hot, moduleGraph }, a
|
|
64710
64843
|
updates,
|
64711
64844
|
});
|
64712
64845
|
}
|
64846
|
+
function populateSSRImporters(module, timestamp, seen) {
|
64847
|
+
module.ssrImportedModules.forEach((importer) => {
|
64848
|
+
if (seen.has(importer)) {
|
64849
|
+
return;
|
64850
|
+
}
|
64851
|
+
if (importer.lastHMRTimestamp === timestamp ||
|
64852
|
+
importer.lastInvalidationTimestamp === timestamp) {
|
64853
|
+
seen.add(importer);
|
64854
|
+
populateSSRImporters(importer, timestamp, seen);
|
64855
|
+
}
|
64856
|
+
});
|
64857
|
+
return seen;
|
64858
|
+
}
|
64859
|
+
function getSSRInvalidatedImporters(module) {
|
64860
|
+
return [
|
64861
|
+
...populateSSRImporters(module, module.lastHMRTimestamp, new Set()),
|
64862
|
+
].map((m) => m.file);
|
64863
|
+
}
|
64713
64864
|
async function handleFileAddUnlink(file, server, isUnlink) {
|
64714
64865
|
const modules = [...(server.moduleGraph.getModulesByFile(file) || [])];
|
64715
64866
|
if (isUnlink) {
|
@@ -65094,6 +65245,44 @@ function createHMRBroadcaster() {
|
|
65094
65245
|
};
|
65095
65246
|
return broadcaster;
|
65096
65247
|
}
|
65248
|
+
function createServerHMRChannel() {
|
65249
|
+
const innerEmitter = new EventEmitter$4();
|
65250
|
+
const outsideEmitter = new EventEmitter$4();
|
65251
|
+
return {
|
65252
|
+
name: 'ssr',
|
65253
|
+
send(...args) {
|
65254
|
+
let payload;
|
65255
|
+
if (typeof args[0] === 'string') {
|
65256
|
+
payload = {
|
65257
|
+
type: 'custom',
|
65258
|
+
event: args[0],
|
65259
|
+
data: args[1],
|
65260
|
+
};
|
65261
|
+
}
|
65262
|
+
else {
|
65263
|
+
payload = args[0];
|
65264
|
+
}
|
65265
|
+
outsideEmitter.emit('send', payload);
|
65266
|
+
},
|
65267
|
+
off(event, listener) {
|
65268
|
+
innerEmitter.off(event, listener);
|
65269
|
+
},
|
65270
|
+
on: ((event, listener) => {
|
65271
|
+
innerEmitter.on(event, listener);
|
65272
|
+
}),
|
65273
|
+
close() {
|
65274
|
+
innerEmitter.removeAllListeners();
|
65275
|
+
outsideEmitter.removeAllListeners();
|
65276
|
+
},
|
65277
|
+
listen() {
|
65278
|
+
innerEmitter.emit('connection');
|
65279
|
+
},
|
65280
|
+
api: {
|
65281
|
+
innerEmitter,
|
65282
|
+
outsideEmitter,
|
65283
|
+
},
|
65284
|
+
};
|
65285
|
+
}
|
65097
65286
|
|
65098
65287
|
const debug$1 = createDebugger('vite:import-analysis');
|
65099
65288
|
const clientDir = normalizePath$3(CLIENT_DIR);
|
@@ -65101,18 +65290,11 @@ const skipRE = /\.(?:map|json)(?:$|\?)/;
|
|
65101
65290
|
const canSkipImportAnalysis = (id) => skipRE.test(id) || isDirectCSSRequest(id);
|
65102
65291
|
const optimizedDepChunkRE = /\/chunk-[A-Z\d]{8}\.js/;
|
65103
65292
|
const optimizedDepDynamicRE = /-[A-Z\d]{8}\.js/;
|
65104
|
-
const hasImportInQueryParamsRE = /[?&]import=?\b/;
|
65105
65293
|
const hasViteIgnoreRE = /\/\*\s*@vite-ignore\s*\*\//;
|
65106
65294
|
const urlIsStringRE = /^(?:'.*'|".*"|`.*`)$/;
|
65107
65295
|
const templateLiteralRE = /^\s*`(.*)`\s*$/;
|
65108
65296
|
function isExplicitImportRequired(url) {
|
65109
|
-
return !isJSRequest(
|
65110
|
-
}
|
65111
|
-
function markExplicitImport(url) {
|
65112
|
-
if (isExplicitImportRequired(url)) {
|
65113
|
-
return injectQuery(url, 'import');
|
65114
|
-
}
|
65115
|
-
return url;
|
65297
|
+
return !isJSRequest(url) && !isCSSRequest(url);
|
65116
65298
|
}
|
65117
65299
|
function extractImportedBindings(id, source, importSpec, importedBindings) {
|
65118
65300
|
let bindings = importedBindings.get(id);
|
@@ -65329,15 +65511,16 @@ function importAnalysisPlugin(config) {
|
|
65329
65511
|
// make the URL browser-valid if not SSR
|
65330
65512
|
if (!ssr) {
|
65331
65513
|
// mark non-js/css imports with `?import`
|
65332
|
-
|
65333
|
-
|
65334
|
-
|
65335
|
-
|
65336
|
-
// do not do this for unknown type imports, otherwise the appended
|
65337
|
-
// query can break 3rd party plugin's extension checks.
|
65338
|
-
if ((isRelative || isSelfImport) &&
|
65339
|
-
!hasImportInQueryParamsRE.test(url) &&
|
65514
|
+
if (isExplicitImportRequired(url)) {
|
65515
|
+
url = injectQuery(url, 'import');
|
65516
|
+
}
|
65517
|
+
else if ((isRelative || isSelfImport) &&
|
65340
65518
|
!DEP_VERSION_RE.test(url)) {
|
65519
|
+
// If the url isn't a request for a pre-bundled common chunk,
|
65520
|
+
// for relative js/css imports, or self-module virtual imports
|
65521
|
+
// (e.g. vue blocks), inherit importer's version query
|
65522
|
+
// do not do this for unknown type imports, otherwise the appended
|
65523
|
+
// query can break 3rd party plugin's extension checks.
|
65341
65524
|
const versionMatch = importer.match(DEP_VERSION_RE);
|
65342
65525
|
if (versionMatch) {
|
65343
65526
|
url = injectQuery(url, versionMatch[1]);
|
@@ -67273,6 +67456,24 @@ const promisifiedRealpath = promisify$4(fs$l.realpath);
|
|
67273
67456
|
function defineConfig(config) {
|
67274
67457
|
return config;
|
67275
67458
|
}
|
67459
|
+
/**
|
67460
|
+
* Check and warn if `path` includes characters that don't work well in Vite,
|
67461
|
+
* such as `#` and `?`.
|
67462
|
+
*/
|
67463
|
+
function checkBadCharactersInPath(path, logger) {
|
67464
|
+
const badChars = [];
|
67465
|
+
if (path.includes('#')) {
|
67466
|
+
badChars.push('#');
|
67467
|
+
}
|
67468
|
+
if (path.includes('?')) {
|
67469
|
+
badChars.push('?');
|
67470
|
+
}
|
67471
|
+
if (badChars.length > 0) {
|
67472
|
+
const charString = badChars.map((c) => `"${c}"`).join(' and ');
|
67473
|
+
const inflectedChars = badChars.length > 1 ? 'characters' : 'character';
|
67474
|
+
logger.warn(colors$1.yellow(`The project root contains the ${charString} ${inflectedChars} (${colors$1.cyan(path)}), which may not work when running Vite. Consider renaming the directory to remove the characters.`));
|
67475
|
+
}
|
67476
|
+
}
|
67276
67477
|
async function resolveConfig(inlineConfig, command, defaultMode = 'development', defaultNodeEnv = 'development', isPreview = false) {
|
67277
67478
|
let config = inlineConfig;
|
67278
67479
|
let configFileDependencies = [];
|
@@ -67329,9 +67530,7 @@ async function resolveConfig(inlineConfig, command, defaultMode = 'development',
|
|
67329
67530
|
});
|
67330
67531
|
// resolve root
|
67331
67532
|
const resolvedRoot = normalizePath$3(config.root ? path$o.resolve(config.root) : process.cwd());
|
67332
|
-
|
67333
|
-
logger.warn(colors$1.yellow(`The project root contains the "#" character (${colors$1.cyan(resolvedRoot)}), which may not work when running Vite. Consider renaming the directory to remove the "#".`));
|
67334
|
-
}
|
67533
|
+
checkBadCharactersInPath(resolvedRoot, logger);
|
67335
67534
|
const clientAlias = [
|
67336
67535
|
{
|
67337
67536
|
find: /^\/?@vite\/env/,
|
@@ -67890,7 +68089,7 @@ function optimizeDepsDisabledBackwardCompatibility(resolved, optimizeDeps, optim
|
|
67890
68089
|
resolved.build.commonjsOptions.include = undefined;
|
67891
68090
|
}
|
67892
68091
|
resolved.logger.warn(colors$1.yellow(`(!) Experimental ${optimizeDepsPath}optimizeDeps.disabled and deps pre-bundling during build were removed in Vite 5.1.
|
67893
|
-
To disable the deps optimizer, set ${optimizeDepsPath}optimizeDeps.noDiscovery to true and ${optimizeDepsPath}optimizeDeps.include as undefined or empty.
|
68092
|
+
To disable the deps optimizer, set ${optimizeDepsPath}optimizeDeps.noDiscovery to true and ${optimizeDepsPath}optimizeDeps.include as undefined or empty.
|
67894
68093
|
Please remove ${optimizeDepsPath}optimizeDeps.disabled from your config.
|
67895
68094
|
${commonjsPluginDisabled
|
67896
68095
|
? 'Empty config.build.commonjsOptions.include will be ignored to support CJS during build. This config should also be removed.'
|
@@ -67907,4 +68106,4 @@ function optimizeDepsDisabledBackwardCompatibility(resolved, optimizeDeps, optim
|
|
67907
68106
|
}
|
67908
68107
|
}
|
67909
68108
|
|
67910
|
-
export {
|
68109
|
+
export { resolveEnvPrefix as A, getDefaultExportFromCjs as B, commonjsGlobal as C, index$1 as D, index as E, build$1 as F, preview$1 as G, createLogger as a, arraify as b, colors$1 as c, defineConfig as d, createServer as e, build as f, formatPostcssSourceMap as g, preprocessCSS as h, isInNodeModules$1 as i, buildErrorMessage as j, fetchModule as k, loadConfigFromFile as l, mergeConfig as m, normalizePath$3 as n, optimizeDeps as o, preview as p, mergeAlias as q, resolveConfig as r, sortUserPlugins as s, transformWithEsbuild as t, createFilter as u, rollupVersion as v, send as w, searchForWorkspaceRoot as x, isFileServingAllowed as y, loadEnv as z };
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import {
|
1
|
+
import { C as commonjsGlobal, B as getDefaultExportFromCjs } from './dep-G1t0FnMB.js';
|
2
2
|
import require$$0__default from 'fs';
|
3
3
|
import require$$0 from 'postcss';
|
4
4
|
import require$$0$1 from 'path';
|
package/dist/node/cli.js
CHANGED
@@ -2,7 +2,7 @@ import path from 'node:path';
|
|
2
2
|
import fs from 'node:fs';
|
3
3
|
import { performance } from 'node:perf_hooks';
|
4
4
|
import { EventEmitter } from 'events';
|
5
|
-
import {
|
5
|
+
import { c as colors, a as createLogger, r as resolveConfig } from './chunks/dep-G1t0FnMB.js';
|
6
6
|
import { VERSION } from './constants.js';
|
7
7
|
import 'node:fs/promises';
|
8
8
|
import 'node:url';
|
@@ -32,10 +32,10 @@ import 'node:assert';
|
|
32
32
|
import 'node:v8';
|
33
33
|
import 'node:worker_threads';
|
34
34
|
import 'node:buffer';
|
35
|
+
import 'node:events';
|
35
36
|
import 'rollup/parseAst';
|
36
37
|
import 'querystring';
|
37
38
|
import 'node:readline';
|
38
|
-
import 'node:events';
|
39
39
|
import 'zlib';
|
40
40
|
import 'buffer';
|
41
41
|
import 'https';
|
@@ -757,7 +757,7 @@ cli
|
|
757
757
|
filterDuplicateOptions(options);
|
758
758
|
// output structure is preserved even after bundling so require()
|
759
759
|
// is ok here
|
760
|
-
const { createServer } = await import('./chunks/dep-
|
760
|
+
const { createServer } = await import('./chunks/dep-G1t0FnMB.js').then(function (n) { return n.E; });
|
761
761
|
try {
|
762
762
|
const server = await createServer({
|
763
763
|
root,
|
@@ -837,7 +837,7 @@ cli
|
|
837
837
|
.option('-w, --watch', `[boolean] rebuilds when modules have changed on disk`)
|
838
838
|
.action(async (root, options) => {
|
839
839
|
filterDuplicateOptions(options);
|
840
|
-
const { build } = await import('./chunks/dep-
|
840
|
+
const { build } = await import('./chunks/dep-G1t0FnMB.js').then(function (n) { return n.F; });
|
841
841
|
const buildOptions = cleanOptions(options);
|
842
842
|
try {
|
843
843
|
await build({
|
@@ -865,7 +865,7 @@ cli
|
|
865
865
|
.option('--force', `[boolean] force the optimizer to ignore the cache and re-bundle`)
|
866
866
|
.action(async (root, options) => {
|
867
867
|
filterDuplicateOptions(options);
|
868
|
-
const { optimizeDeps } = await import('./chunks/dep-
|
868
|
+
const { optimizeDeps } = await import('./chunks/dep-G1t0FnMB.js').then(function (n) { return n.D; });
|
869
869
|
try {
|
870
870
|
const config = await resolveConfig({
|
871
871
|
root,
|
@@ -891,7 +891,7 @@ cli
|
|
891
891
|
.option('--outDir <dir>', `[string] output directory (default: dist)`)
|
892
892
|
.action(async (root, options) => {
|
893
893
|
filterDuplicateOptions(options);
|
894
|
-
const { preview } = await import('./chunks/dep-
|
894
|
+
const { preview } = await import('./chunks/dep-G1t0FnMB.js').then(function (n) { return n.G; });
|
895
895
|
try {
|
896
896
|
const server = await preview({
|
897
897
|
root,
|