vite 5.0.0-beta.14 → 5.0.0-beta.16
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/node/chunks/{dep-QFst3FNH.js → dep-WN9UKUor.js} +129 -137
- package/dist/node/chunks/{dep-L-2yzs6m.js → dep-ayAPZ1OT.js} +1 -1
- package/dist/node/chunks/{dep-OMqKnqdS.js → dep-wO2juHOz.js} +1 -1
- package/dist/node/cli.js +5 -5
- package/dist/node/constants.js +2 -1
- package/dist/node/index.d.ts +26 -13
- package/dist/node/index.js +3 -3
- package/package.json +2 -2
|
@@ -20,11 +20,11 @@ import require$$1$1 from 'http';
|
|
|
20
20
|
import require$$0$7 from 'stream';
|
|
21
21
|
import require$$2 from 'os';
|
|
22
22
|
import require$$2$1 from 'child_process';
|
|
23
|
+
import { CLIENT_ENTRY, VALID_ID_PREFIX, NULL_BYTE_PLACEHOLDER, OPTIMIZABLE_ENTRY_RE, FS_PREFIX, wildcardHosts, loopbackHosts, CLIENT_PUBLIC_PATH, ENV_PUBLIC_PATH, ENV_ENTRY, DEP_VERSION_RE, SPECIAL_QUERY_RE, DEFAULT_MAIN_FIELDS, DEFAULT_EXTENSIONS, CSS_LANGS_RE, ESBUILD_MODULES_TARGET, KNOWN_ASSET_TYPES, VITE_PACKAGE_DIR, ASYNC_DISPOSE, DEFAULT_DEV_PORT, CLIENT_DIR, JS_TYPES_RE, VERSION as VERSION$1, DEFAULT_PREVIEW_PORT, DEFAULT_ASSETS_RE, DEFAULT_CONFIG_FILES } from '../constants.js';
|
|
23
24
|
import os$4 from 'node:os';
|
|
24
25
|
import { exec } from 'node:child_process';
|
|
25
26
|
import { createHash as createHash$2 } from 'node:crypto';
|
|
26
27
|
import { promises } from 'node:dns';
|
|
27
|
-
import { CLIENT_ENTRY, VALID_ID_PREFIX, NULL_BYTE_PLACEHOLDER, OPTIMIZABLE_ENTRY_RE, FS_PREFIX, wildcardHosts, loopbackHosts, CLIENT_PUBLIC_PATH, ENV_PUBLIC_PATH, ENV_ENTRY, DEP_VERSION_RE, SPECIAL_QUERY_RE, DEFAULT_MAIN_FIELDS, DEFAULT_EXTENSIONS, CSS_LANGS_RE, ESBUILD_MODULES_TARGET, KNOWN_ASSET_TYPES, VITE_PACKAGE_DIR, DEFAULT_DEV_PORT, CLIENT_DIR, JS_TYPES_RE, VERSION as VERSION$1, DEFAULT_PREVIEW_PORT, DEFAULT_ASSETS_RE, DEFAULT_CONFIG_FILES } from '../constants.js';
|
|
28
28
|
import require$$0$a from 'crypto';
|
|
29
29
|
import { Buffer as Buffer$1 } from 'node:buffer';
|
|
30
30
|
import require$$0$8, { createRequire as createRequire$2 } from 'module';
|
|
@@ -32,7 +32,7 @@ import assert$1 from 'node:assert';
|
|
|
32
32
|
import process$1 from 'node:process';
|
|
33
33
|
import v8 from 'node:v8';
|
|
34
34
|
import { VERSION } from 'rollup';
|
|
35
|
-
import { parseAst } from 'rollup/parseAst';
|
|
35
|
+
import { parseAstAsync, parseAst } from 'rollup/parseAst';
|
|
36
36
|
import * as qs from 'querystring';
|
|
37
37
|
import readline from 'node:readline';
|
|
38
38
|
import { EventEmitter as EventEmitter$4 } from 'node:events';
|
|
@@ -38479,8 +38479,8 @@ function createCachedImport(imp) {
|
|
|
38479
38479
|
return cached;
|
|
38480
38480
|
};
|
|
38481
38481
|
}
|
|
38482
|
-
const importPostcssImport = createCachedImport(() => import('./dep-
|
|
38483
|
-
const importPostcssModules = createCachedImport(() => import('./dep-
|
|
38482
|
+
const importPostcssImport = createCachedImport(() => import('./dep-ayAPZ1OT.js').then(function (n) { return n.i; }));
|
|
38483
|
+
const importPostcssModules = createCachedImport(() => import('./dep-wO2juHOz.js').then(function (n) { return n.i; }));
|
|
38484
38484
|
const importPostcss = createCachedImport(() => import('postcss'));
|
|
38485
38485
|
/**
|
|
38486
38486
|
* @experimental
|
|
@@ -39757,7 +39757,6 @@ function optimizedDepsPlugin(config) {
|
|
|
39757
39757
|
// something unexpected has happened. In this case, Vite
|
|
39758
39758
|
// returns an empty response that will error.
|
|
39759
39759
|
throwProcessingError(id);
|
|
39760
|
-
return;
|
|
39761
39760
|
}
|
|
39762
39761
|
const newMetadata = depsOptimizer.metadata;
|
|
39763
39762
|
if (metadata !== newMetadata) {
|
|
@@ -47650,7 +47649,7 @@ async function doTransform(url, server, options, timestamp) {
|
|
|
47650
47649
|
// tries to handle soft invalidation of the module if available,
|
|
47651
47650
|
// returns a boolean true is successful, or false if no handling is needed
|
|
47652
47651
|
const softInvalidatedTransformResult = module &&
|
|
47653
|
-
(await handleModuleSoftInvalidation(module, ssr, timestamp, server
|
|
47652
|
+
(await handleModuleSoftInvalidation(module, ssr, timestamp, server));
|
|
47654
47653
|
if (softInvalidatedTransformResult) {
|
|
47655
47654
|
debugCache$1?.(`[memory-hmr] ${prettyUrl}`);
|
|
47656
47655
|
return softInvalidatedTransformResult;
|
|
@@ -47731,10 +47730,14 @@ async function loadAndTransform(id, url, server, options, timestamp, mod, resolv
|
|
|
47731
47730
|
}
|
|
47732
47731
|
if (code == null) {
|
|
47733
47732
|
const isPublicFile = checkPublicFile(url, config);
|
|
47733
|
+
let publicDirName = path$o.relative(config.root, config.publicDir);
|
|
47734
|
+
if (publicDirName[0] !== '.')
|
|
47735
|
+
publicDirName = '/' + publicDirName;
|
|
47734
47736
|
const msg = isPublicFile
|
|
47735
|
-
? `This file is in
|
|
47736
|
-
`going through the plugin transforms, and therefore
|
|
47737
|
-
`imported from source code. It can only be referenced
|
|
47737
|
+
? `This file is in ${publicDirName} and will be copied as-is during ` +
|
|
47738
|
+
`build without going through the plugin transforms, and therefore ` +
|
|
47739
|
+
`should not be imported from source code. It can only be referenced ` +
|
|
47740
|
+
`via HTML tags.`
|
|
47738
47741
|
: `Does the file exist?`;
|
|
47739
47742
|
const importerMod = server.moduleGraph.idToModuleMap
|
|
47740
47743
|
.get(id)
|
|
@@ -47827,7 +47830,7 @@ function createConvertSourceMapReadMap(originalFileName) {
|
|
|
47827
47830
|
* - Client: We need to transform the import specifiers with new timestamps
|
|
47828
47831
|
* - SSR: We don't need to change anything as `ssrLoadModule` controls it
|
|
47829
47832
|
*/
|
|
47830
|
-
async function handleModuleSoftInvalidation(mod, ssr, timestamp,
|
|
47833
|
+
async function handleModuleSoftInvalidation(mod, ssr, timestamp, server) {
|
|
47831
47834
|
const transformResult = ssr ? mod.ssrInvalidationState : mod.invalidationState;
|
|
47832
47835
|
// Reset invalidation state
|
|
47833
47836
|
if (ssr)
|
|
@@ -47838,7 +47841,7 @@ async function handleModuleSoftInvalidation(mod, ssr, timestamp, base) {
|
|
|
47838
47841
|
if (!transformResult || transformResult === 'HARD_INVALIDATED')
|
|
47839
47842
|
return;
|
|
47840
47843
|
if (ssr ? mod.ssrTransformResult : mod.transformResult) {
|
|
47841
|
-
throw new Error(`Internal server error: Soft-invalidated module "${mod.url}" should not have existing
|
|
47844
|
+
throw new Error(`Internal server error: Soft-invalidated module "${mod.url}" should not have existing transform result`);
|
|
47842
47845
|
}
|
|
47843
47846
|
let result;
|
|
47844
47847
|
// For SSR soft-invalidation, no transformation is needed
|
|
@@ -47861,7 +47864,7 @@ async function handleModuleSoftInvalidation(mod, ssr, timestamp, base) {
|
|
|
47861
47864
|
}
|
|
47862
47865
|
const urlWithoutTimestamp = removeTimestampQuery(rawUrl);
|
|
47863
47866
|
// hmrUrl must be derived the same way as importAnalysis
|
|
47864
|
-
const hmrUrl = unwrapId(stripBase(removeImportQuery(urlWithoutTimestamp), base));
|
|
47867
|
+
const hmrUrl = unwrapId(stripBase(removeImportQuery(urlWithoutTimestamp), server.config.base));
|
|
47865
47868
|
for (const importedMod of mod.clientImportedModules) {
|
|
47866
47869
|
if (importedMod.url !== hmrUrl)
|
|
47867
47870
|
continue;
|
|
@@ -47871,6 +47874,10 @@ async function handleModuleSoftInvalidation(mod, ssr, timestamp, base) {
|
|
|
47871
47874
|
const end = hasQuotes ? imp.e - 1 : imp.e;
|
|
47872
47875
|
s.overwrite(start, end, replacedUrl);
|
|
47873
47876
|
}
|
|
47877
|
+
if (imp.d === -1 && server.config.server.preTransformRequests) {
|
|
47878
|
+
// pre-transform known direct imports
|
|
47879
|
+
server.warmupRequest(hmrUrl, { ssr });
|
|
47880
|
+
}
|
|
47874
47881
|
break;
|
|
47875
47882
|
}
|
|
47876
47883
|
}
|
|
@@ -48207,7 +48214,7 @@ async function ssrTransformScript(code, inMap, url, originalCode) {
|
|
|
48207
48214
|
const s = new MagicString(code);
|
|
48208
48215
|
let ast;
|
|
48209
48216
|
try {
|
|
48210
|
-
ast =
|
|
48217
|
+
ast = await parseAstAsync(code);
|
|
48211
48218
|
}
|
|
48212
48219
|
catch (err) {
|
|
48213
48220
|
if (!err.loc || !err.loc.line)
|
|
@@ -54906,31 +54913,33 @@ function createWebSocketServer(server, config, httpsOptions) {
|
|
|
54906
54913
|
});
|
|
54907
54914
|
});
|
|
54908
54915
|
},
|
|
54916
|
+
[ASYNC_DISPOSE]() {
|
|
54917
|
+
return this.close();
|
|
54918
|
+
},
|
|
54909
54919
|
};
|
|
54910
54920
|
}
|
|
54911
54921
|
|
|
54912
54922
|
// this middleware is only active when (base !== '/')
|
|
54913
|
-
function baseMiddleware(
|
|
54923
|
+
function baseMiddleware(rawBase, middlewareMode) {
|
|
54914
54924
|
// Keep the named function. The name is visible in debug logs via `DEBUG=connect:dispatcher ...`
|
|
54915
54925
|
return function viteBaseMiddleware(req, res, next) {
|
|
54916
54926
|
const url = req.url;
|
|
54917
|
-
const
|
|
54918
|
-
const
|
|
54919
|
-
|
|
54920
|
-
if (path.startsWith(base)) {
|
|
54927
|
+
const pathname = cleanUrl(url);
|
|
54928
|
+
const base = rawBase;
|
|
54929
|
+
if (pathname.startsWith(base)) {
|
|
54921
54930
|
// rewrite url to remove base. this ensures that other middleware does
|
|
54922
54931
|
// not need to consider base being prepended or not
|
|
54923
54932
|
req.url = stripBase(url, base);
|
|
54924
54933
|
return next();
|
|
54925
54934
|
}
|
|
54926
54935
|
// skip redirect and error fallback on middleware mode, #4057
|
|
54927
|
-
if (
|
|
54936
|
+
if (middlewareMode) {
|
|
54928
54937
|
return next();
|
|
54929
54938
|
}
|
|
54930
|
-
if (
|
|
54939
|
+
if (pathname === '/' || pathname === '/index.html') {
|
|
54931
54940
|
// redirect root visit to based url with search and hash
|
|
54932
54941
|
res.writeHead(302, {
|
|
54933
|
-
Location: base +
|
|
54942
|
+
Location: base + url.slice(pathname.length),
|
|
54934
54943
|
});
|
|
54935
54944
|
res.end();
|
|
54936
54945
|
return;
|
|
@@ -57106,19 +57115,7 @@ function doesProxyContextMatchUrl(context, url) {
|
|
|
57106
57115
|
}
|
|
57107
57116
|
|
|
57108
57117
|
const debug$6 = createDebugger('vite:html-fallback');
|
|
57109
|
-
function htmlFallbackMiddleware(root, spaFallback
|
|
57110
|
-
// When this middleware is mounted on a route, we need to re-assign `req.url` with a
|
|
57111
|
-
// leading `.` to signal a relative rewrite. Returning with a leading `/` returns a
|
|
57112
|
-
// buggy `req.url`. e.g.:
|
|
57113
|
-
//
|
|
57114
|
-
// mount /foo/bar:
|
|
57115
|
-
// req.url = /index.html
|
|
57116
|
-
// final = /foo/barindex.html
|
|
57117
|
-
//
|
|
57118
|
-
// mount /foo/bar:
|
|
57119
|
-
// req.url = ./index.html
|
|
57120
|
-
// final = /foo/bar/index.html
|
|
57121
|
-
const prepend = mounted ? '.' : '';
|
|
57118
|
+
function htmlFallbackMiddleware(root, spaFallback) {
|
|
57122
57119
|
// Keep the named function. The name is visible in debug logs via `DEBUG=connect:dispatcher ...`
|
|
57123
57120
|
return function viteHtmlFallbackMiddleware(req, res, next) {
|
|
57124
57121
|
if (
|
|
@@ -57142,7 +57139,7 @@ function htmlFallbackMiddleware(root, spaFallback, mounted = false) {
|
|
|
57142
57139
|
const filePath = path$o.join(root, pathname);
|
|
57143
57140
|
if (fs$l.existsSync(filePath)) {
|
|
57144
57141
|
debug$6?.(`Rewriting ${req.method} ${req.url} to ${url}`);
|
|
57145
|
-
req.url =
|
|
57142
|
+
req.url = url;
|
|
57146
57143
|
return next();
|
|
57147
57144
|
}
|
|
57148
57145
|
}
|
|
@@ -57152,7 +57149,7 @@ function htmlFallbackMiddleware(root, spaFallback, mounted = false) {
|
|
|
57152
57149
|
if (fs$l.existsSync(filePath)) {
|
|
57153
57150
|
const newUrl = url + 'index.html';
|
|
57154
57151
|
debug$6?.(`Rewriting ${req.method} ${req.url} to ${newUrl}`);
|
|
57155
|
-
req.url =
|
|
57152
|
+
req.url = newUrl;
|
|
57156
57153
|
return next();
|
|
57157
57154
|
}
|
|
57158
57155
|
}
|
|
@@ -57162,13 +57159,13 @@ function htmlFallbackMiddleware(root, spaFallback, mounted = false) {
|
|
|
57162
57159
|
if (fs$l.existsSync(filePath)) {
|
|
57163
57160
|
const newUrl = url + '.html';
|
|
57164
57161
|
debug$6?.(`Rewriting ${req.method} ${req.url} to ${newUrl}`);
|
|
57165
|
-
req.url =
|
|
57162
|
+
req.url = newUrl;
|
|
57166
57163
|
return next();
|
|
57167
57164
|
}
|
|
57168
57165
|
}
|
|
57169
57166
|
if (spaFallback) {
|
|
57170
57167
|
debug$6?.(`Rewriting ${req.method} ${req.url} to /index.html`);
|
|
57171
|
-
req.url =
|
|
57168
|
+
req.url = '/index.html';
|
|
57172
57169
|
}
|
|
57173
57170
|
next();
|
|
57174
57171
|
};
|
|
@@ -57682,20 +57679,9 @@ function indexHtmlMiddleware(root, server) {
|
|
|
57682
57679
|
function preTransformRequest(server, url, base) {
|
|
57683
57680
|
if (!server.config.server.preTransformRequests)
|
|
57684
57681
|
return;
|
|
57685
|
-
url = unwrapId(stripBase(url, base));
|
|
57686
57682
|
// transform all url as non-ssr as html includes client-side assets only
|
|
57687
|
-
|
|
57688
|
-
|
|
57689
|
-
e?.code === ERR_CLOSED_SERVER) {
|
|
57690
|
-
// these are expected errors
|
|
57691
|
-
return;
|
|
57692
|
-
}
|
|
57693
|
-
// Unexpected error, log the issue but avoid an unhandled exception
|
|
57694
|
-
server.config.logger.error(`Pre-transform error: ${e.message}`, {
|
|
57695
|
-
error: e,
|
|
57696
|
-
timestamp: true,
|
|
57697
|
-
});
|
|
57698
|
-
});
|
|
57683
|
+
url = unwrapId(stripBase(url, base));
|
|
57684
|
+
server.warmupRequest(url);
|
|
57699
57685
|
}
|
|
57700
57686
|
|
|
57701
57687
|
const logTime = createDebugger('vite:time');
|
|
@@ -58258,26 +58244,29 @@ function warmupFiles(server) {
|
|
|
58258
58244
|
}
|
|
58259
58245
|
}
|
|
58260
58246
|
async function warmupFile(server, file, ssr) {
|
|
58261
|
-
|
|
58262
|
-
|
|
58263
|
-
|
|
58264
|
-
|
|
58265
|
-
|
|
58266
|
-
|
|
58267
|
-
|
|
58247
|
+
// transform html with the `transformIndexHtml` hook as Vite internals would
|
|
58248
|
+
// pre-transform the imported JS modules linked. this may cause `transformIndexHtml`
|
|
58249
|
+
// plugins to be executed twice, but that's probably fine.
|
|
58250
|
+
if (file.endsWith('.html')) {
|
|
58251
|
+
const url = htmlFileToUrl(file, server.config.root);
|
|
58252
|
+
if (url) {
|
|
58253
|
+
try {
|
|
58268
58254
|
const html = await fsp.readFile(file, 'utf-8');
|
|
58269
58255
|
await server.transformIndexHtml(url, html);
|
|
58270
58256
|
}
|
|
58271
|
-
|
|
58272
|
-
|
|
58273
|
-
|
|
58274
|
-
|
|
58275
|
-
|
|
58276
|
-
|
|
58257
|
+
catch (e) {
|
|
58258
|
+
// Unexpected error, log the issue but avoid an unhandled exception
|
|
58259
|
+
server.config.logger.error(`Pre-transform error (${colors$1.cyan(file)}): ${e.message}`, {
|
|
58260
|
+
error: e,
|
|
58261
|
+
timestamp: true,
|
|
58262
|
+
});
|
|
58263
|
+
}
|
|
58277
58264
|
}
|
|
58278
58265
|
}
|
|
58279
|
-
|
|
58280
|
-
|
|
58266
|
+
// for other files, pass it through `transformRequest` with warmup
|
|
58267
|
+
else {
|
|
58268
|
+
const url = fileToUrl(file, server.config.root);
|
|
58269
|
+
await server.warmupRequest(url, { ssr });
|
|
58281
58270
|
}
|
|
58282
58271
|
}
|
|
58283
58272
|
function htmlFileToUrl(file, root) {
|
|
@@ -58350,6 +58339,20 @@ async function _createServer(inlineConfig = {}, options) {
|
|
|
58350
58339
|
transformRequest(url, options) {
|
|
58351
58340
|
return transformRequest(url, server, options);
|
|
58352
58341
|
},
|
|
58342
|
+
async warmupRequest(url, options) {
|
|
58343
|
+
await transformRequest(url, server, options).catch((e) => {
|
|
58344
|
+
if (e?.code === ERR_OUTDATED_OPTIMIZED_DEP ||
|
|
58345
|
+
e?.code === ERR_CLOSED_SERVER) {
|
|
58346
|
+
// these are expected errors
|
|
58347
|
+
return;
|
|
58348
|
+
}
|
|
58349
|
+
// Unexpected error, log the issue but avoid an unhandled exception
|
|
58350
|
+
server.config.logger.error(`Pre-transform error: ${e.message}`, {
|
|
58351
|
+
error: e,
|
|
58352
|
+
timestamp: true,
|
|
58353
|
+
});
|
|
58354
|
+
});
|
|
58355
|
+
},
|
|
58353
58356
|
transformIndexHtml: null,
|
|
58354
58357
|
async ssrLoadModule(url, opts) {
|
|
58355
58358
|
if (isDepsOptimizerEnabled(config, true)) {
|
|
@@ -58439,6 +58442,9 @@ async function _createServer(inlineConfig = {}, options) {
|
|
|
58439
58442
|
}
|
|
58440
58443
|
server.resolvedUrls = null;
|
|
58441
58444
|
},
|
|
58445
|
+
[ASYNC_DISPOSE]() {
|
|
58446
|
+
return this.close();
|
|
58447
|
+
},
|
|
58442
58448
|
printUrls() {
|
|
58443
58449
|
if (server.resolvedUrls) {
|
|
58444
58450
|
printServerUrls(server.resolvedUrls, serverConfig.host, config.logger.info);
|
|
@@ -58500,11 +58506,13 @@ async function _createServer(inlineConfig = {}, options) {
|
|
|
58500
58506
|
};
|
|
58501
58507
|
const onFileAddUnlink = async (file, isUnlink) => {
|
|
58502
58508
|
file = normalizePath$3(file);
|
|
58509
|
+
await container.watchChange(file, { event: isUnlink ? 'delete' : 'create' });
|
|
58503
58510
|
await handleFileAddUnlink(file, server, isUnlink);
|
|
58504
58511
|
await onHMRUpdate(file, true);
|
|
58505
58512
|
};
|
|
58506
58513
|
watcher.on('change', async (file) => {
|
|
58507
58514
|
file = normalizePath$3(file);
|
|
58515
|
+
await container.watchChange(file, { event: 'update' });
|
|
58508
58516
|
// invalidate module graph cache on file change
|
|
58509
58517
|
moduleGraph.onFileChange(file);
|
|
58510
58518
|
await onHMRUpdate(file, false);
|
|
@@ -58549,7 +58557,7 @@ async function _createServer(inlineConfig = {}, options) {
|
|
|
58549
58557
|
}
|
|
58550
58558
|
// base
|
|
58551
58559
|
if (config.base !== '/') {
|
|
58552
|
-
middlewares.use(baseMiddleware(
|
|
58560
|
+
middlewares.use(baseMiddleware(config.rawBase, middlewareMode));
|
|
58553
58561
|
}
|
|
58554
58562
|
// open in editor support
|
|
58555
58563
|
middlewares.use('/__open-in-editor', launchEditorMiddleware$1());
|
|
@@ -59197,7 +59205,6 @@ function definePlugin(config) {
|
|
|
59197
59205
|
'process.env.NODE_ENV': JSON.stringify(nodeEnv),
|
|
59198
59206
|
'global.process.env.NODE_ENV': JSON.stringify(nodeEnv),
|
|
59199
59207
|
'globalThis.process.env.NODE_ENV': JSON.stringify(nodeEnv),
|
|
59200
|
-
__vite_process_env_NODE_ENV: JSON.stringify(nodeEnv),
|
|
59201
59208
|
});
|
|
59202
59209
|
}
|
|
59203
59210
|
// during dev, import.meta properties are handled by importAnalysis plugin.
|
|
@@ -59234,9 +59241,6 @@ function definePlugin(config) {
|
|
|
59234
59241
|
...(replaceProcessEnv ? processEnv : {}),
|
|
59235
59242
|
};
|
|
59236
59243
|
// Additional define fixes based on `ssr` value
|
|
59237
|
-
if (isBuild && !replaceProcessEnv) {
|
|
59238
|
-
define['__vite_process_env_NODE_ENV'] = 'process.env.NODE_ENV';
|
|
59239
|
-
}
|
|
59240
59244
|
if ('import.meta.env.SSR' in define) {
|
|
59241
59245
|
define['import.meta.env.SSR'] = ssr + '';
|
|
59242
59246
|
}
|
|
@@ -59247,16 +59251,16 @@ function definePlugin(config) {
|
|
|
59247
59251
|
...userDefineEnv,
|
|
59248
59252
|
});
|
|
59249
59253
|
}
|
|
59250
|
-
|
|
59251
|
-
const
|
|
59252
|
-
|
|
59253
|
-
|
|
59254
|
-
|
|
59255
|
-
|
|
59256
|
-
|
|
59257
|
-
|
|
59258
|
-
|
|
59259
|
-
|
|
59254
|
+
// Create regex pattern as a fast check before running esbuild
|
|
59255
|
+
const patternKeys = Object.keys(userDefine);
|
|
59256
|
+
if (replaceProcessEnv && Object.keys(processEnv).length) {
|
|
59257
|
+
patternKeys.push('process.env');
|
|
59258
|
+
}
|
|
59259
|
+
if (Object.keys(importMetaKeys).length) {
|
|
59260
|
+
patternKeys.push('import.meta.env', 'import.meta.hot');
|
|
59261
|
+
}
|
|
59262
|
+
const pattern = patternKeys.length
|
|
59263
|
+
? new RegExp(patternKeys.map(escapeRegex).join('|'))
|
|
59260
59264
|
: null;
|
|
59261
59265
|
return [define, pattern];
|
|
59262
59266
|
}
|
|
@@ -59766,18 +59770,7 @@ function importAnalysisPlugin(config) {
|
|
|
59766
59770
|
// These requests will also be registered in transformRequest to be awaited
|
|
59767
59771
|
// by the deps optimizer
|
|
59768
59772
|
const url = removeImportQuery(hmrUrl);
|
|
59769
|
-
server.
|
|
59770
|
-
if (e?.code === ERR_OUTDATED_OPTIMIZED_DEP ||
|
|
59771
|
-
e?.code === ERR_CLOSED_SERVER) {
|
|
59772
|
-
// these are expected errors
|
|
59773
|
-
return;
|
|
59774
|
-
}
|
|
59775
|
-
// Unexpected error, log the issue but avoid an unhandled exception
|
|
59776
|
-
config.logger.error(`Pre-transform error: ${e.message}`, {
|
|
59777
|
-
error: e,
|
|
59778
|
-
timestamp: true,
|
|
59779
|
-
});
|
|
59780
|
-
});
|
|
59773
|
+
server.warmupRequest(url, { ssr });
|
|
59781
59774
|
}
|
|
59782
59775
|
}
|
|
59783
59776
|
else if (!importer.startsWith(withTrailingSlash(clientDir))) {
|
|
@@ -61309,14 +61302,7 @@ function createPluginHookUtils(plugins) {
|
|
|
61309
61302
|
}
|
|
61310
61303
|
function getSortedPluginHooks(hookName) {
|
|
61311
61304
|
const plugins = getSortedPlugins(hookName);
|
|
61312
|
-
return plugins
|
|
61313
|
-
.map((p) => {
|
|
61314
|
-
const hook = p[hookName];
|
|
61315
|
-
return typeof hook === 'object' && 'handler' in hook
|
|
61316
|
-
? hook.handler
|
|
61317
|
-
: hook;
|
|
61318
|
-
})
|
|
61319
|
-
.filter(Boolean);
|
|
61305
|
+
return plugins.map((p) => getHookHandler(p[hookName])).filter(Boolean);
|
|
61320
61306
|
}
|
|
61321
61307
|
return {
|
|
61322
61308
|
getSortedPlugins,
|
|
@@ -61345,6 +61331,9 @@ function getSortedPluginsByHook(hookName, plugins) {
|
|
|
61345
61331
|
}
|
|
61346
61332
|
return [...pre, ...normal, ...post];
|
|
61347
61333
|
}
|
|
61334
|
+
function getHookHandler(hook) {
|
|
61335
|
+
return (typeof hook === 'object' ? hook.handler : hook);
|
|
61336
|
+
}
|
|
61348
61337
|
|
|
61349
61338
|
/**
|
|
61350
61339
|
* This file is refactored into TypeScript based on
|
|
@@ -61424,9 +61413,7 @@ async function createPluginContainer(config, moduleGraph, watcher) {
|
|
|
61424
61413
|
const hook = plugin[hookName];
|
|
61425
61414
|
if (!hook)
|
|
61426
61415
|
continue;
|
|
61427
|
-
|
|
61428
|
-
// @ts-ignore hook is not a primitive
|
|
61429
|
-
const handler = 'handler' in hook ? hook.handler : hook;
|
|
61416
|
+
const handler = getHookHandler(hook);
|
|
61430
61417
|
if (hook.sequential) {
|
|
61431
61418
|
await Promise.all(parallelPromises);
|
|
61432
61419
|
parallelPromises.length = 0;
|
|
@@ -61784,9 +61771,7 @@ async function createPluginContainer(config, moduleGraph, watcher) {
|
|
|
61784
61771
|
continue;
|
|
61785
61772
|
ctx._activePlugin = plugin;
|
|
61786
61773
|
const pluginResolveStart = debugPluginResolve ? performance.now() : 0;
|
|
61787
|
-
const handler =
|
|
61788
|
-
? plugin.resolveId.handler
|
|
61789
|
-
: plugin.resolveId;
|
|
61774
|
+
const handler = getHookHandler(plugin.resolveId);
|
|
61790
61775
|
const result = await handleHookPromise(handler.call(ctx, rawId, importer, {
|
|
61791
61776
|
attributes: options?.attributes ?? {},
|
|
61792
61777
|
custom: options?.custom,
|
|
@@ -61833,7 +61818,7 @@ async function createPluginContainer(config, moduleGraph, watcher) {
|
|
|
61833
61818
|
if (!plugin.load)
|
|
61834
61819
|
continue;
|
|
61835
61820
|
ctx._activePlugin = plugin;
|
|
61836
|
-
const handler =
|
|
61821
|
+
const handler = getHookHandler(plugin.load);
|
|
61837
61822
|
const result = await handleHookPromise(handler.call(ctx, id, { ssr }));
|
|
61838
61823
|
if (result != null) {
|
|
61839
61824
|
if (isObject$1(result)) {
|
|
@@ -61859,9 +61844,7 @@ async function createPluginContainer(config, moduleGraph, watcher) {
|
|
|
61859
61844
|
ctx._activeCode = code;
|
|
61860
61845
|
const start = debugPluginTransform ? performance.now() : 0;
|
|
61861
61846
|
let result;
|
|
61862
|
-
const handler =
|
|
61863
|
-
? plugin.transform.handler
|
|
61864
|
-
: plugin.transform;
|
|
61847
|
+
const handler = getHookHandler(plugin.transform);
|
|
61865
61848
|
try {
|
|
61866
61849
|
result = await handleHookPromise(handler.call(ctx, code, id, { ssr }));
|
|
61867
61850
|
}
|
|
@@ -61893,6 +61876,10 @@ async function createPluginContainer(config, moduleGraph, watcher) {
|
|
|
61893
61876
|
map: ctx._getCombinedSourcemap(),
|
|
61894
61877
|
};
|
|
61895
61878
|
},
|
|
61879
|
+
async watchChange(id, change) {
|
|
61880
|
+
const ctx = new Context();
|
|
61881
|
+
await hookParallel('watchChange', () => ctx, () => [id, change]);
|
|
61882
|
+
},
|
|
61896
61883
|
async close() {
|
|
61897
61884
|
if (closed)
|
|
61898
61885
|
return;
|
|
@@ -61902,6 +61889,9 @@ async function createPluginContainer(config, moduleGraph, watcher) {
|
|
|
61902
61889
|
await hookParallel('buildEnd', () => ctx, () => []);
|
|
61903
61890
|
await hookParallel('closeBundle', () => ctx, () => []);
|
|
61904
61891
|
},
|
|
61892
|
+
[ASYNC_DISPOSE]() {
|
|
61893
|
+
return this.close();
|
|
61894
|
+
},
|
|
61905
61895
|
};
|
|
61906
61896
|
return container;
|
|
61907
61897
|
}
|
|
@@ -62615,6 +62605,9 @@ async function createDepsOptimizer(config, server) {
|
|
|
62615
62605
|
resetRegisteredIds,
|
|
62616
62606
|
ensureFirstRun,
|
|
62617
62607
|
close,
|
|
62608
|
+
[ASYNC_DISPOSE]() {
|
|
62609
|
+
return this.close();
|
|
62610
|
+
},
|
|
62618
62611
|
options: getDepOptimizationConfig(config, ssr),
|
|
62619
62612
|
};
|
|
62620
62613
|
depsOptimizerMap.set(config, depsOptimizer);
|
|
@@ -63149,6 +63142,7 @@ async function createDevSsrDepsOptimizer(config) {
|
|
|
63149
63142
|
resetRegisteredIds: () => { },
|
|
63150
63143
|
ensureFirstRun: () => { },
|
|
63151
63144
|
close: async () => { },
|
|
63145
|
+
[ASYNC_DISPOSE]: async () => { },
|
|
63152
63146
|
options: config.ssr.optimizeDeps,
|
|
63153
63147
|
};
|
|
63154
63148
|
devSsrDepsOptimizerMap.set(config, depsOptimizer);
|
|
@@ -63525,12 +63519,10 @@ async function prepareEsbuildOptimizerRun(resolvedConfig, depsInfo, ssr, process
|
|
|
63525
63519
|
if (optimizerContext.cancelled)
|
|
63526
63520
|
return { context: undefined, idToExports };
|
|
63527
63521
|
// esbuild automatically replaces process.env.NODE_ENV for platform 'browser'
|
|
63528
|
-
//
|
|
63529
|
-
// time we replace it by __vite_process_env_NODE_ENV. This placeholder will be
|
|
63530
|
-
// later replaced by the define plugin
|
|
63522
|
+
// But in lib mode, we need to keep process.env.NODE_ENV untouched
|
|
63531
63523
|
const define = {
|
|
63532
|
-
'process.env.NODE_ENV': isBuild
|
|
63533
|
-
? '
|
|
63524
|
+
'process.env.NODE_ENV': isBuild && config.build.lib
|
|
63525
|
+
? 'process.env.NODE_ENV'
|
|
63534
63526
|
: JSON.stringify(process.env.NODE_ENV || config.mode),
|
|
63535
63527
|
};
|
|
63536
63528
|
const platform = ssr && config.ssr?.target !== 'webworker' ? 'node' : 'browser';
|
|
@@ -65128,7 +65120,7 @@ function injectSsrFlagToHooks(plugin) {
|
|
|
65128
65120
|
function wrapSsrResolveId(hook) {
|
|
65129
65121
|
if (!hook)
|
|
65130
65122
|
return;
|
|
65131
|
-
const fn =
|
|
65123
|
+
const fn = getHookHandler(hook);
|
|
65132
65124
|
const handler = function (id, importer, options) {
|
|
65133
65125
|
return fn.call(this, id, importer, injectSsrFlag(options));
|
|
65134
65126
|
};
|
|
@@ -65145,7 +65137,7 @@ function wrapSsrResolveId(hook) {
|
|
|
65145
65137
|
function wrapSsrLoad(hook) {
|
|
65146
65138
|
if (!hook)
|
|
65147
65139
|
return;
|
|
65148
|
-
const fn =
|
|
65140
|
+
const fn = getHookHandler(hook);
|
|
65149
65141
|
const handler = function (id, ...args) {
|
|
65150
65142
|
// @ts-expect-error: Receiving options param to be future-proof if Rollup adds it
|
|
65151
65143
|
return fn.call(this, id, injectSsrFlag(args[0]));
|
|
@@ -65163,7 +65155,7 @@ function wrapSsrLoad(hook) {
|
|
|
65163
65155
|
function wrapSsrTransform(hook) {
|
|
65164
65156
|
if (!hook)
|
|
65165
65157
|
return;
|
|
65166
|
-
const fn =
|
|
65158
|
+
const fn = getHookHandler(hook);
|
|
65167
65159
|
const handler = function (code, importer, ...args) {
|
|
65168
65160
|
// @ts-expect-error: Receiving options param to be future-proof if Rollup adds it
|
|
65169
65161
|
return fn.call(this, code, importer, injectSsrFlag(args[0]));
|
|
@@ -65486,7 +65478,10 @@ async function preview(inlineConfig = {}) {
|
|
|
65486
65478
|
app.use(proxyMiddleware(httpServer, proxy, config));
|
|
65487
65479
|
}
|
|
65488
65480
|
app.use(compression());
|
|
65489
|
-
|
|
65481
|
+
// base
|
|
65482
|
+
if (config.base !== '/') {
|
|
65483
|
+
app.use(baseMiddleware(config.rawBase, false));
|
|
65484
|
+
}
|
|
65490
65485
|
// static assets
|
|
65491
65486
|
const headers = config.preview.headers;
|
|
65492
65487
|
const viteAssetMiddleware = (...args) => sirv(distDir, {
|
|
@@ -65505,23 +65500,22 @@ async function preview(inlineConfig = {}) {
|
|
|
65505
65500
|
return shouldServeFile(filePath, distDir);
|
|
65506
65501
|
},
|
|
65507
65502
|
})(...args);
|
|
65508
|
-
app.use(
|
|
65503
|
+
app.use(viteAssetMiddleware);
|
|
65509
65504
|
// html fallback
|
|
65510
65505
|
if (config.appType === 'spa' || config.appType === 'mpa') {
|
|
65511
|
-
app.use(
|
|
65506
|
+
app.use(htmlFallbackMiddleware(distDir, config.appType === 'spa'));
|
|
65512
65507
|
}
|
|
65513
65508
|
// apply post server hooks from plugins
|
|
65514
65509
|
postHooks.forEach((fn) => fn && fn());
|
|
65515
65510
|
if (config.appType === 'spa' || config.appType === 'mpa') {
|
|
65516
65511
|
// transform index.html
|
|
65517
|
-
app.use(
|
|
65512
|
+
app.use(indexHtmlMiddleware(distDir, server));
|
|
65518
65513
|
// handle 404s
|
|
65519
|
-
app.use(
|
|
65514
|
+
app.use(notFoundMiddleware());
|
|
65520
65515
|
}
|
|
65521
65516
|
const hostname = await resolveHostname(options.host);
|
|
65522
65517
|
const port = options.port ?? DEFAULT_PREVIEW_PORT;
|
|
65523
|
-
|
|
65524
|
-
const serverPort = await httpServerStart(httpServer, {
|
|
65518
|
+
await httpServerStart(httpServer, {
|
|
65525
65519
|
port,
|
|
65526
65520
|
strictPort: options.strictPort,
|
|
65527
65521
|
host: hostname.host,
|
|
@@ -65529,10 +65523,11 @@ async function preview(inlineConfig = {}) {
|
|
|
65529
65523
|
});
|
|
65530
65524
|
server.resolvedUrls = await resolveServerUrls(httpServer, config.preview, config);
|
|
65531
65525
|
if (options.open) {
|
|
65532
|
-
const
|
|
65533
|
-
|
|
65534
|
-
?
|
|
65535
|
-
|
|
65526
|
+
const url = server.resolvedUrls?.local[0] ?? server.resolvedUrls?.network[0];
|
|
65527
|
+
if (url) {
|
|
65528
|
+
const path = typeof options.open === 'string' ? new URL(options.open, url).href : url;
|
|
65529
|
+
openBrowser(path, true, logger);
|
|
65530
|
+
}
|
|
65536
65531
|
}
|
|
65537
65532
|
return server;
|
|
65538
65533
|
}
|
|
@@ -65566,7 +65561,7 @@ const promisifiedRealpath = promisify$4(fs$l.realpath);
|
|
|
65566
65561
|
function defineConfig(config) {
|
|
65567
65562
|
return config;
|
|
65568
65563
|
}
|
|
65569
|
-
async function resolveConfig(inlineConfig, command, defaultMode = 'development', defaultNodeEnv = 'development') {
|
|
65564
|
+
async function resolveConfig(inlineConfig, command, defaultMode = 'development', defaultNodeEnv = 'development', isPreview = false) {
|
|
65570
65565
|
let config = inlineConfig;
|
|
65571
65566
|
let configFileDependencies = [];
|
|
65572
65567
|
let mode = inlineConfig.mode || defaultMode;
|
|
@@ -65580,7 +65575,8 @@ async function resolveConfig(inlineConfig, command, defaultMode = 'development',
|
|
|
65580
65575
|
const configEnv = {
|
|
65581
65576
|
mode,
|
|
65582
65577
|
command,
|
|
65583
|
-
|
|
65578
|
+
isSsrBuild: !!config.build?.ssr,
|
|
65579
|
+
isPreview,
|
|
65584
65580
|
};
|
|
65585
65581
|
let { configFile } = config;
|
|
65586
65582
|
if (configFile !== false) {
|
|
@@ -65630,10 +65626,6 @@ async function resolveConfig(inlineConfig, command, defaultMode = 'development',
|
|
|
65630
65626
|
allowClearScreen: config.clearScreen,
|
|
65631
65627
|
customLogger: config.customLogger,
|
|
65632
65628
|
});
|
|
65633
|
-
let foundDiscouragedVariableName;
|
|
65634
|
-
if ((foundDiscouragedVariableName = Object.keys(config.define ?? {}).find((k) => ['process', 'global'].includes(k)))) {
|
|
65635
|
-
logger.warn(colors$1.yellow(`Replacing ${colors$1.bold(foundDiscouragedVariableName)} using the define option is discouraged. See https://vitejs.dev/config/shared-options.html#define for more details.`));
|
|
65636
|
-
}
|
|
65637
65629
|
// resolve root
|
|
65638
65630
|
const resolvedRoot = normalizePath$3(config.root ? path$o.resolve(config.root) : process.cwd());
|
|
65639
65631
|
if (resolvedRoot.includes('#')) {
|
|
@@ -66162,7 +66154,7 @@ async function runConfigHook(config, plugins, configEnv) {
|
|
|
66162
66154
|
let conf = config;
|
|
66163
66155
|
for (const p of getSortedPluginsByHook('config', plugins)) {
|
|
66164
66156
|
const hook = p.config;
|
|
66165
|
-
const handler = hook
|
|
66157
|
+
const handler = getHookHandler(hook);
|
|
66166
66158
|
if (handler) {
|
|
66167
66159
|
const res = await handler(conf, configEnv);
|
|
66168
66160
|
if (res) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { z as commonjsGlobal, y as getDefaultExportFromCjs } from './dep-
|
|
1
|
+
import { z as commonjsGlobal, y as getDefaultExportFromCjs } from './dep-WN9UKUor.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 { x as colors, k as createLogger, r as resolveConfig } from './chunks/dep-
|
|
5
|
+
import { x as colors, k as createLogger, r as resolveConfig } from './chunks/dep-WN9UKUor.js';
|
|
6
6
|
import { VERSION } from './constants.js';
|
|
7
7
|
import 'node:fs/promises';
|
|
8
8
|
import 'node:url';
|
|
@@ -759,7 +759,7 @@ cli
|
|
|
759
759
|
filterDuplicateOptions(options);
|
|
760
760
|
// output structure is preserved even after bundling so require()
|
|
761
761
|
// is ok here
|
|
762
|
-
const { createServer } = await import('./chunks/dep-
|
|
762
|
+
const { createServer } = await import('./chunks/dep-WN9UKUor.js').then(function (n) { return n.A; });
|
|
763
763
|
try {
|
|
764
764
|
const server = await createServer({
|
|
765
765
|
root,
|
|
@@ -839,7 +839,7 @@ cli
|
|
|
839
839
|
.option('-w, --watch', `[boolean] rebuilds when modules have changed on disk`)
|
|
840
840
|
.action(async (root, options) => {
|
|
841
841
|
filterDuplicateOptions(options);
|
|
842
|
-
const { build } = await import('./chunks/dep-
|
|
842
|
+
const { build } = await import('./chunks/dep-WN9UKUor.js').then(function (n) { return n.C; });
|
|
843
843
|
const buildOptions = cleanOptions(options);
|
|
844
844
|
try {
|
|
845
845
|
await build({
|
|
@@ -867,7 +867,7 @@ cli
|
|
|
867
867
|
.option('--force', `[boolean] force the optimizer to ignore the cache and re-bundle`)
|
|
868
868
|
.action(async (root, options) => {
|
|
869
869
|
filterDuplicateOptions(options);
|
|
870
|
-
const { optimizeDeps } = await import('./chunks/dep-
|
|
870
|
+
const { optimizeDeps } = await import('./chunks/dep-WN9UKUor.js').then(function (n) { return n.B; });
|
|
871
871
|
try {
|
|
872
872
|
const config = await resolveConfig({
|
|
873
873
|
root,
|
|
@@ -893,7 +893,7 @@ cli
|
|
|
893
893
|
.option('--outDir <dir>', `[string] output directory (default: dist)`)
|
|
894
894
|
.action(async (root, options) => {
|
|
895
895
|
filterDuplicateOptions(options);
|
|
896
|
-
const { preview } = await import('./chunks/dep-
|
|
896
|
+
const { preview } = await import('./chunks/dep-WN9UKUor.js').then(function (n) { return n.D; });
|
|
897
897
|
try {
|
|
898
898
|
const server = await preview({
|
|
899
899
|
root,
|
package/dist/node/constants.js
CHANGED
|
@@ -122,5 +122,6 @@ const wildcardHosts = new Set([
|
|
|
122
122
|
]);
|
|
123
123
|
const DEFAULT_DEV_PORT = 5173;
|
|
124
124
|
const DEFAULT_PREVIEW_PORT = 4173;
|
|
125
|
+
const ASYNC_DISPOSE = Symbol.asyncDispose || Symbol.for('Symbol.asyncDispose');
|
|
125
126
|
|
|
126
|
-
export { CLIENT_DIR, CLIENT_ENTRY, CLIENT_PUBLIC_PATH, CSS_LANGS_RE, DEFAULT_ASSETS_RE, DEFAULT_CONFIG_FILES, DEFAULT_DEV_PORT, DEFAULT_EXTENSIONS, DEFAULT_MAIN_FIELDS, DEFAULT_PREVIEW_PORT, DEP_VERSION_RE, ENV_ENTRY, ENV_PUBLIC_PATH, ESBUILD_MODULES_TARGET, FS_PREFIX, JS_TYPES_RE, KNOWN_ASSET_TYPES, NULL_BYTE_PLACEHOLDER, OPTIMIZABLE_ENTRY_RE, SPECIAL_QUERY_RE, VALID_ID_PREFIX, VERSION, VITE_PACKAGE_DIR, loopbackHosts, wildcardHosts };
|
|
127
|
+
export { ASYNC_DISPOSE, CLIENT_DIR, CLIENT_ENTRY, CLIENT_PUBLIC_PATH, CSS_LANGS_RE, DEFAULT_ASSETS_RE, DEFAULT_CONFIG_FILES, DEFAULT_DEV_PORT, DEFAULT_EXTENSIONS, DEFAULT_MAIN_FIELDS, DEFAULT_PREVIEW_PORT, DEP_VERSION_RE, ENV_ENTRY, ENV_PUBLIC_PATH, ESBUILD_MODULES_TARGET, FS_PREFIX, JS_TYPES_RE, KNOWN_ASSET_TYPES, NULL_BYTE_PLACEHOLDER, OPTIMIZABLE_ENTRY_RE, SPECIAL_QUERY_RE, VALID_ID_PREFIX, VERSION, VITE_PACKAGE_DIR, loopbackHosts, wildcardHosts };
|
package/dist/node/index.d.ts
CHANGED
|
@@ -3,8 +3,10 @@ import { PluginHooks, RollupError, SourceMap, ModuleInfo, PartialResolvedId, Inp
|
|
|
3
3
|
import * as rollup from 'rollup';
|
|
4
4
|
export { rollup as Rollup };
|
|
5
5
|
export { VERSION as rollupVersion } from 'rollup';
|
|
6
|
+
export { parseAst, parseAstAsync } from 'rollup/parseAst';
|
|
6
7
|
import * as http from 'node:http';
|
|
7
8
|
import { OutgoingHttpHeaders, ClientRequestArgs, IncomingMessage, ClientRequest, Agent, Server, ServerResponse } from 'node:http';
|
|
9
|
+
import { Http2SecureServer } from 'node:http2';
|
|
8
10
|
import * as fs from 'node:fs';
|
|
9
11
|
import * as events from 'node:events';
|
|
10
12
|
import { EventEmitter } from 'node:events';
|
|
@@ -715,7 +717,7 @@ interface PreviewServer {
|
|
|
715
717
|
/**
|
|
716
718
|
* native Node http server instance
|
|
717
719
|
*/
|
|
718
|
-
httpServer:
|
|
720
|
+
httpServer: HttpServer;
|
|
719
721
|
/**
|
|
720
722
|
* The resolved urls Vite prints on the CLI.
|
|
721
723
|
* null before server is listening.
|
|
@@ -836,7 +838,7 @@ declare class ModuleGraph {
|
|
|
836
838
|
* https:
|
|
837
839
|
*/
|
|
838
840
|
|
|
839
|
-
interface PluginContainer {
|
|
841
|
+
interface PluginContainer extends AsyncDisposable {
|
|
840
842
|
options: InputOptions;
|
|
841
843
|
getModuleInfo(id: string): ModuleInfo | null;
|
|
842
844
|
buildStart(options: InputOptions): Promise<void>;
|
|
@@ -859,6 +861,9 @@ interface PluginContainer {
|
|
|
859
861
|
load(id: string, options?: {
|
|
860
862
|
ssr?: boolean;
|
|
861
863
|
}): Promise<LoadResult | null>;
|
|
864
|
+
watchChange(id: string, change: {
|
|
865
|
+
event: 'create' | 'update' | 'delete';
|
|
866
|
+
}): Promise<void>;
|
|
862
867
|
close(): Promise<void>;
|
|
863
868
|
}
|
|
864
869
|
|
|
@@ -1394,7 +1399,7 @@ declare namespace WebSocket {
|
|
|
1394
1399
|
}
|
|
1395
1400
|
|
|
1396
1401
|
type WebSocketCustomListener<T> = (data: T, client: WebSocketClient) => void;
|
|
1397
|
-
interface WebSocketServer {
|
|
1402
|
+
interface WebSocketServer extends AsyncDisposable {
|
|
1398
1403
|
/**
|
|
1399
1404
|
* Listen on port and host
|
|
1400
1405
|
*/
|
|
@@ -1548,7 +1553,8 @@ interface FileSystemServeOptions {
|
|
|
1548
1553
|
deny?: string[];
|
|
1549
1554
|
}
|
|
1550
1555
|
type ServerHook = (this: void, server: ViteDevServer) => (() => void) | void | Promise<(() => void) | void>;
|
|
1551
|
-
|
|
1556
|
+
type HttpServer = http.Server | Http2SecureServer;
|
|
1557
|
+
interface ViteDevServer extends AsyncDisposable {
|
|
1552
1558
|
/**
|
|
1553
1559
|
* The resolved vite config object
|
|
1554
1560
|
*/
|
|
@@ -1566,7 +1572,7 @@ interface ViteDevServer {
|
|
|
1566
1572
|
* native Node http server instance
|
|
1567
1573
|
* will be null in middleware mode
|
|
1568
1574
|
*/
|
|
1569
|
-
httpServer:
|
|
1575
|
+
httpServer: HttpServer | null;
|
|
1570
1576
|
/**
|
|
1571
1577
|
* chokidar watcher instance
|
|
1572
1578
|
* https:
|
|
@@ -1595,6 +1601,12 @@ interface ViteDevServer {
|
|
|
1595
1601
|
* without going through the http request pipeline.
|
|
1596
1602
|
*/
|
|
1597
1603
|
transformRequest(url: string, options?: TransformOptions): Promise<TransformResult | null>;
|
|
1604
|
+
/**
|
|
1605
|
+
* Same as `transformRequest` but only warm up the URLs so the next request
|
|
1606
|
+
* will already be cached. The function will never throw as it handles and
|
|
1607
|
+
* reports errors internally.
|
|
1608
|
+
*/
|
|
1609
|
+
warmupRequest(url: string, options?: TransformOptions): Promise<void>;
|
|
1598
1610
|
/**
|
|
1599
1611
|
* Apply vite built-in HTML transforms and any plugin HTML transforms.
|
|
1600
1612
|
*/
|
|
@@ -2413,7 +2425,7 @@ type ExportsData = {
|
|
|
2413
2425
|
exports: readonly string[];
|
|
2414
2426
|
jsxLoader?: boolean;
|
|
2415
2427
|
};
|
|
2416
|
-
interface DepsOptimizer {
|
|
2428
|
+
interface DepsOptimizer extends AsyncDisposable {
|
|
2417
2429
|
metadata: DepOptimizationMetadata;
|
|
2418
2430
|
scanProcessing?: Promise<void>;
|
|
2419
2431
|
registerMissingImport: (id: string, resolved: string) => OptimizedDepInfo;
|
|
@@ -2914,6 +2926,9 @@ interface Plugin<A = any> extends rollup.Plugin<A> {
|
|
|
2914
2926
|
}) => Promise<rollup.TransformResult> | rollup.TransformResult>;
|
|
2915
2927
|
}
|
|
2916
2928
|
type HookHandler<T> = T extends ObjectHook<infer H> ? H : T;
|
|
2929
|
+
type PluginWithRequiredHook<K extends keyof Plugin> = Plugin & {
|
|
2930
|
+
[P in K]: NonNullable<Plugin[P]>;
|
|
2931
|
+
};
|
|
2917
2932
|
|
|
2918
2933
|
interface JsonOptions {
|
|
2919
2934
|
/**
|
|
@@ -2932,10 +2947,8 @@ interface JsonOptions {
|
|
|
2932
2947
|
interface ConfigEnv {
|
|
2933
2948
|
command: 'build' | 'serve';
|
|
2934
2949
|
mode: string;
|
|
2935
|
-
|
|
2936
|
-
|
|
2937
|
-
*/
|
|
2938
|
-
ssrBuild?: boolean;
|
|
2950
|
+
isSsrBuild?: boolean;
|
|
2951
|
+
isPreview?: boolean;
|
|
2939
2952
|
}
|
|
2940
2953
|
/**
|
|
2941
2954
|
* spa: include SPA fallback middleware and configure sirv with `single: true` in preview
|
|
@@ -3097,7 +3110,7 @@ interface UserConfig {
|
|
|
3097
3110
|
*/
|
|
3098
3111
|
format?: 'es' | 'iife';
|
|
3099
3112
|
/**
|
|
3100
|
-
* Vite plugins that apply to worker bundle. The plugins
|
|
3113
|
+
* Vite plugins that apply to worker bundle. The plugins returned by this function
|
|
3101
3114
|
* should be new instances every time it is called, because they are used for each
|
|
3102
3115
|
* rollup worker bundling process.
|
|
3103
3116
|
*/
|
|
@@ -3200,11 +3213,11 @@ type ResolvedConfig = Readonly<Omit<UserConfig, 'plugins' | 'css' | 'assetsInclu
|
|
|
3200
3213
|
experimental: ExperimentalOptions;
|
|
3201
3214
|
} & PluginHookUtils>;
|
|
3202
3215
|
interface PluginHookUtils {
|
|
3203
|
-
getSortedPlugins: (hookName:
|
|
3216
|
+
getSortedPlugins: <K extends keyof Plugin>(hookName: K) => PluginWithRequiredHook<K>[];
|
|
3204
3217
|
getSortedPluginHooks: <K extends keyof Plugin>(hookName: K) => NonNullable<HookHandler<Plugin[K]>>[];
|
|
3205
3218
|
}
|
|
3206
3219
|
type ResolveFn = (id: string, importer?: string, aliasOnly?: boolean, ssr?: boolean) => Promise<string | undefined>;
|
|
3207
|
-
declare function resolveConfig(inlineConfig: InlineConfig, command: 'build' | 'serve', defaultMode?: string, defaultNodeEnv?: string): Promise<ResolvedConfig>;
|
|
3220
|
+
declare function resolveConfig(inlineConfig: InlineConfig, command: 'build' | 'serve', defaultMode?: string, defaultNodeEnv?: string, isPreview?: boolean): Promise<ResolvedConfig>;
|
|
3208
3221
|
declare function sortUserPlugins(plugins: (Plugin | Plugin[])[] | undefined): [Plugin[], Plugin[], Plugin[]];
|
|
3209
3222
|
declare function loadConfigFromFile(configEnv: ConfigEnv, configFile?: string, configRoot?: string, logLevel?: LogLevel): Promise<{
|
|
3210
3223
|
path: string;
|
package/dist/node/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
export { parseAst, parseAstAsync } from 'rollup/parseAst';
|
|
2
|
+
import { i as isInNodeModules } from './chunks/dep-WN9UKUor.js';
|
|
3
|
+
export { b as build, e as buildErrorMessage, h as createFilter, k as createLogger, c as createServer, d as defineConfig, f as formatPostcssSourceMap, u as isFileServingAllowed, l as loadConfigFromFile, v as loadEnv, g as mergeAlias, m as mergeConfig, n as normalizePath, o as optimizeDeps, a as preprocessCSS, p as preview, r as resolveConfig, w as resolveEnvPrefix, q as searchForWorkspaceRoot, j as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-WN9UKUor.js';
|
|
3
4
|
export { VERSION as version } from './constants.js';
|
|
4
5
|
export { version as esbuildVersion } from 'esbuild';
|
|
5
6
|
export { VERSION as rollupVersion } from 'rollup';
|
|
@@ -33,7 +34,6 @@ import 'module';
|
|
|
33
34
|
import 'node:assert';
|
|
34
35
|
import 'node:process';
|
|
35
36
|
import 'node:v8';
|
|
36
|
-
import 'rollup/parseAst';
|
|
37
37
|
import 'querystring';
|
|
38
38
|
import 'node:readline';
|
|
39
39
|
import 'node:events';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite",
|
|
3
|
-
"version": "5.0.0-beta.
|
|
3
|
+
"version": "5.0.0-beta.16",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Evan You",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"dependencies": {
|
|
64
64
|
"esbuild": "^0.19.3",
|
|
65
65
|
"postcss": "^8.4.31",
|
|
66
|
-
"rollup": "^4.
|
|
66
|
+
"rollup": "^4.2.0"
|
|
67
67
|
},
|
|
68
68
|
"optionalDependencies": {
|
|
69
69
|
"fsevents": "~2.3.3"
|