vite 6.0.0-beta.8 → 6.0.0-beta.9
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/client.d.ts +10 -0
- package/dist/client/client.mjs +323 -92
- package/dist/node/chunks/{dep-qU9-vqRp.js → dep-BLfo3Ie2.js} +267 -106
- package/dist/node/chunks/{dep-Ddvoc4zx.js → dep-CG5ueZZV.js} +424 -295
- package/dist/node/chunks/{dep-DUn1iy3F.js → dep-DIgjieZc.js} +1 -1
- package/dist/node/cli.js +5 -5
- package/dist/node/index.d.ts +1503 -1492
- package/dist/node/index.js +3 -34
- package/dist/node/module-runner.d.ts +89 -98
- package/dist/node/module-runner.js +214 -67
- package/package.json +8 -8
- package/types/hmrPayload.d.ts +5 -0
@@ -7,7 +7,7 @@ import { promisify, format, inspect } from 'node:util';
|
|
7
7
|
import { performance } from 'node:perf_hooks';
|
8
8
|
import require$$0$3, { createRequire, builtinModules } from 'node:module';
|
9
9
|
import esbuild, { transform, formatMessages, build as build$3 } from 'esbuild';
|
10
|
-
import { CLIENT_ENTRY, OPTIMIZABLE_ENTRY_RE, wildcardHosts, loopbackHosts, FS_PREFIX, CLIENT_PUBLIC_PATH, ENV_PUBLIC_PATH, DEFAULT_ASSETS_INLINE_LIMIT, ENV_ENTRY, SPECIAL_QUERY_RE, DEP_VERSION_RE, DEV_PROD_CONDITION, JS_TYPES_RE, KNOWN_ASSET_TYPES, CSS_LANGS_RE, METADATA_FILENAME, ESBUILD_MODULES_TARGET, ERR_OPTIMIZE_DEPS_PROCESSING_ERROR, ERR_OUTDATED_OPTIMIZED_DEP, ERR_FILE_NOT_FOUND_IN_OPTIMIZED_DEP_DIR, VITE_PACKAGE_DIR, CLIENT_DIR, DEFAULT_DEV_PORT, VERSION, ROLLUP_HOOKS, DEFAULT_PREVIEW_PORT, DEFAULT_ASSETS_RE, DEFAULT_CONFIG_FILES, DEFAULT_CONDITIONS, DEFAULT_EXTENSIONS,
|
10
|
+
import { CLIENT_ENTRY, OPTIMIZABLE_ENTRY_RE, wildcardHosts, loopbackHosts, FS_PREFIX, CLIENT_PUBLIC_PATH, ENV_PUBLIC_PATH, DEFAULT_ASSETS_INLINE_LIMIT, ENV_ENTRY, SPECIAL_QUERY_RE, DEP_VERSION_RE, DEV_PROD_CONDITION, JS_TYPES_RE, KNOWN_ASSET_TYPES, CSS_LANGS_RE, METADATA_FILENAME, ESBUILD_MODULES_TARGET, ERR_OPTIMIZE_DEPS_PROCESSING_ERROR, ERR_OUTDATED_OPTIMIZED_DEP, ERR_FILE_NOT_FOUND_IN_OPTIMIZED_DEP_DIR, VITE_PACKAGE_DIR, CLIENT_DIR, DEFAULT_DEV_PORT, VERSION, ROLLUP_HOOKS, DEFAULT_PREVIEW_PORT, DEFAULT_ASSETS_RE, DEFAULT_CONFIG_FILES, DEFAULT_MAIN_FIELDS, DEFAULT_CONDITIONS, DEFAULT_EXTENSIONS, DEFAULT_EXTERNAL_CONDITIONS } from '../constants.js';
|
11
11
|
import * as sysPath from 'path';
|
12
12
|
import sysPath__default, { posix, win32, isAbsolute, resolve as resolve$2, relative as relative$1, basename as basename$1, extname, dirname as dirname$1, join, sep } from 'path';
|
13
13
|
import require$$0$1, { existsSync, readFileSync, statSync, lstatSync, unwatchFile, watchFile, watch as watch$1, stat as stat$1, readdirSync } from 'fs';
|
@@ -2308,6 +2308,15 @@ function withTrailingSlash(path) {
|
|
2308
2308
|
}
|
2309
2309
|
return path;
|
2310
2310
|
}
|
2311
|
+
function promiseWithResolvers() {
|
2312
|
+
let resolve;
|
2313
|
+
let reject;
|
2314
|
+
const promise = new Promise((_resolve, _reject) => {
|
2315
|
+
resolve = _resolve;
|
2316
|
+
reject = _reject;
|
2317
|
+
});
|
2318
|
+
return { promise, resolve, reject };
|
2319
|
+
}
|
2311
2320
|
|
2312
2321
|
// @ts-check
|
2313
2322
|
/** @typedef { import('estree').BaseNode} BaseNode */
|
@@ -10614,15 +10623,6 @@ function getPackageManagerCommand(type = "install") {
|
|
10614
10623
|
function isDevServer(server) {
|
10615
10624
|
return "pluginContainer" in server;
|
10616
10625
|
}
|
10617
|
-
function promiseWithResolvers() {
|
10618
|
-
let resolve;
|
10619
|
-
let reject;
|
10620
|
-
const promise = new Promise((_resolve, _reject) => {
|
10621
|
-
resolve = _resolve;
|
10622
|
-
reject = _reject;
|
10623
|
-
});
|
10624
|
-
return { promise, resolve, reject };
|
10625
|
-
}
|
10626
10626
|
function createSerialPromiseQueue() {
|
10627
10627
|
let previousTask;
|
10628
10628
|
return {
|
@@ -13323,6 +13323,9 @@ function checkPublicFile(url, config) {
|
|
13323
13323
|
|
13324
13324
|
const assetUrlRE = /__VITE_ASSET__([\w$]+)__(?:\$_(.*?)__)?/g;
|
13325
13325
|
const jsSourceMapRE = /\.[cm]?js\.map$/;
|
13326
|
+
const noInlineRE = /[?&]no-inline\b/;
|
13327
|
+
const inlineRE$2 = /[?&]inline\b/;
|
13328
|
+
const svgExtRE = /\.svg(?:$|\?)/;
|
13326
13329
|
const assetCache = /* @__PURE__ */ new WeakMap();
|
13327
13330
|
const cssEntriesMap = /* @__PURE__ */ new WeakMap();
|
13328
13331
|
function registerCustomMime() {
|
@@ -13411,10 +13414,11 @@ function assetPlugin(config) {
|
|
13411
13414
|
}
|
13412
13415
|
id = removeUrlQuery(id);
|
13413
13416
|
let url = await fileToUrl$1(this, id);
|
13414
|
-
|
13415
|
-
|
13416
|
-
|
13417
|
-
|
13417
|
+
if (!url.startsWith("data:") && this.environment.mode === "dev") {
|
13418
|
+
const mod = this.environment.moduleGraph.getModuleById(id);
|
13419
|
+
if (mod && mod.lastHMRTimestamp > 0) {
|
13420
|
+
url = injectQuery(url, `t=${mod.lastHMRTimestamp}`);
|
13421
|
+
}
|
13418
13422
|
}
|
13419
13423
|
return {
|
13420
13424
|
code: `export default ${JSON.stringify(encodeURIPath(url))}`,
|
@@ -13455,14 +13459,28 @@ function assetPlugin(config) {
|
|
13455
13459
|
async function fileToUrl$1(pluginContext, id) {
|
13456
13460
|
const { environment } = pluginContext;
|
13457
13461
|
if (environment.config.command === "serve") {
|
13458
|
-
return fileToDevUrl(
|
13462
|
+
return fileToDevUrl(environment, id);
|
13459
13463
|
} else {
|
13460
13464
|
return fileToBuiltUrl(pluginContext, id);
|
13461
13465
|
}
|
13462
13466
|
}
|
13463
|
-
function fileToDevUrl(
|
13467
|
+
async function fileToDevUrl(environment, id, skipBase = false) {
|
13468
|
+
const config = environment.getTopLevelConfig();
|
13469
|
+
const publicFile = checkPublicFile(id, config);
|
13470
|
+
if (inlineRE$2.test(id)) {
|
13471
|
+
const file = publicFile || cleanUrl(id);
|
13472
|
+
const content = await fsp.readFile(file);
|
13473
|
+
return assetToDataURL(environment, file, content);
|
13474
|
+
}
|
13475
|
+
if (svgExtRE.test(id)) {
|
13476
|
+
const file = publicFile || cleanUrl(id);
|
13477
|
+
const content = await fsp.readFile(file);
|
13478
|
+
if (shouldInline(environment, file, id, content, void 0, void 0)) {
|
13479
|
+
return assetToDataURL(environment, file, content);
|
13480
|
+
}
|
13481
|
+
}
|
13464
13482
|
let rtn;
|
13465
|
-
if (
|
13483
|
+
if (publicFile) {
|
13466
13484
|
rtn = id;
|
13467
13485
|
} else if (id.startsWith(withTrailingSlash(config.root))) {
|
13468
13486
|
rtn = "/" + path.posix.relative(config.root, id);
|
@@ -13503,8 +13521,15 @@ function isGitLfsPlaceholder(content) {
|
|
13503
13521
|
async function fileToBuiltUrl(pluginContext, id, skipPublicCheck = false, forceInline) {
|
13504
13522
|
const environment = pluginContext.environment;
|
13505
13523
|
const topLevelConfig = environment.getTopLevelConfig();
|
13506
|
-
if (!skipPublicCheck
|
13507
|
-
|
13524
|
+
if (!skipPublicCheck) {
|
13525
|
+
const publicFile = checkPublicFile(id, topLevelConfig);
|
13526
|
+
if (publicFile) {
|
13527
|
+
if (inlineRE$2.test(id)) {
|
13528
|
+
id = publicFile;
|
13529
|
+
} else {
|
13530
|
+
return publicFileToBuiltUrl(id, topLevelConfig);
|
13531
|
+
}
|
13532
|
+
}
|
13508
13533
|
}
|
13509
13534
|
const cache = assetCache.get(environment);
|
13510
13535
|
const cached = cache.get(id);
|
@@ -13514,18 +13539,8 @@ async function fileToBuiltUrl(pluginContext, id, skipPublicCheck = false, forceI
|
|
13514
13539
|
const { file, postfix } = splitFileAndPostfix(id);
|
13515
13540
|
const content = await fsp.readFile(file);
|
13516
13541
|
let url;
|
13517
|
-
if (shouldInline(
|
13518
|
-
|
13519
|
-
environment.logger.warn(
|
13520
|
-
colors.yellow(`Inlined file ${id} was not downloaded via Git LFS`)
|
13521
|
-
);
|
13522
|
-
}
|
13523
|
-
if (file.endsWith(".svg")) {
|
13524
|
-
url = svgToDataURL(content);
|
13525
|
-
} else {
|
13526
|
-
const mimeType = lookup(file) ?? "application/octet-stream";
|
13527
|
-
url = `data:${mimeType};base64,${content.toString("base64")}`;
|
13528
|
-
}
|
13542
|
+
if (shouldInline(environment, file, id, content, pluginContext, forceInline)) {
|
13543
|
+
url = assetToDataURL(environment, file, content);
|
13529
13544
|
} else {
|
13530
13545
|
const originalFileName = normalizePath$1(
|
13531
13546
|
path.relative(environment.config.root, file)
|
@@ -13556,13 +13571,18 @@ async function urlToBuiltUrl(pluginContext, url, importer, forceInline) {
|
|
13556
13571
|
forceInline
|
13557
13572
|
);
|
13558
13573
|
}
|
13559
|
-
|
13560
|
-
|
13561
|
-
|
13562
|
-
if (
|
13563
|
-
|
13574
|
+
function shouldInline(environment, file, id, content, buildPluginContext, forceInline) {
|
13575
|
+
if (noInlineRE.test(id)) return false;
|
13576
|
+
if (inlineRE$2.test(id)) return true;
|
13577
|
+
if (buildPluginContext) {
|
13578
|
+
if (environment.config.build.lib) return true;
|
13579
|
+
if (buildPluginContext.getModuleInfo(id)?.isEntry) return false;
|
13580
|
+
}
|
13564
13581
|
if (forceInline !== void 0) return forceInline;
|
13582
|
+
if (file.endsWith(".html")) return false;
|
13583
|
+
if (file.endsWith(".svg") && id.includes("#")) return false;
|
13565
13584
|
let limit;
|
13585
|
+
const { assetsInlineLimit } = environment.config.build;
|
13566
13586
|
if (typeof assetsInlineLimit === "function") {
|
13567
13587
|
const userShouldInline = assetsInlineLimit(file, content);
|
13568
13588
|
if (userShouldInline != null) return userShouldInline;
|
@@ -13570,10 +13590,21 @@ const shouldInline = (pluginContext, file, id, content, forceInline) => {
|
|
13570
13590
|
} else {
|
13571
13591
|
limit = Number(assetsInlineLimit);
|
13572
13592
|
}
|
13573
|
-
if (file.endsWith(".html")) return false;
|
13574
|
-
if (file.endsWith(".svg") && id.includes("#")) return false;
|
13575
13593
|
return content.length < limit && !isGitLfsPlaceholder(content);
|
13576
|
-
}
|
13594
|
+
}
|
13595
|
+
function assetToDataURL(environment, file, content) {
|
13596
|
+
if (environment.config.build.lib && isGitLfsPlaceholder(content)) {
|
13597
|
+
environment.logger.warn(
|
13598
|
+
colors.yellow(`Inlined file ${file} was not downloaded via Git LFS`)
|
13599
|
+
);
|
13600
|
+
}
|
13601
|
+
if (file.endsWith(".svg")) {
|
13602
|
+
return svgToDataURL(content);
|
13603
|
+
} else {
|
13604
|
+
const mimeType = lookup(file) ?? "application/octet-stream";
|
13605
|
+
return `data:${mimeType};base64,${content.toString("base64")}`;
|
13606
|
+
}
|
13607
|
+
}
|
13577
13608
|
const nestedQuotesRE = /"[^"']*'[^"]*"|'[^'"]*"[^']*'/;
|
13578
13609
|
function svgToDataURL(content) {
|
13579
13610
|
const stringContent = content.toString();
|
@@ -15942,7 +15973,7 @@ const startsWithWordCharRE = /^\w/;
|
|
15942
15973
|
const debug$a = createDebugger("vite:resolve-details", {
|
15943
15974
|
onlyWhenFocused: true
|
15944
15975
|
});
|
15945
|
-
function resolvePlugin(resolveOptions
|
15976
|
+
function resolvePlugin(resolveOptions) {
|
15946
15977
|
const { root, isProduction, asSrc, preferRelative = false } = resolveOptions;
|
15947
15978
|
const rootInRoot = tryStatSync(path.join(root, root))?.isDirectory() ?? false;
|
15948
15979
|
return {
|
@@ -15952,23 +15983,15 @@ function resolvePlugin(resolveOptions, environmentsOptions) {
|
|
15952
15983
|
id.startsWith("/virtual:")) {
|
15953
15984
|
return;
|
15954
15985
|
}
|
15955
|
-
const ssr = resolveOpts?.ssr === true;
|
15956
15986
|
const depsOptimizer = resolveOptions.optimizeDeps && this.environment.mode === "dev" ? this.environment.depsOptimizer : void 0;
|
15957
15987
|
if (id.startsWith(browserExternalId)) {
|
15958
15988
|
return id;
|
15959
15989
|
}
|
15960
15990
|
const isRequire = resolveOpts?.custom?.["node-resolve"]?.isRequire ?? false;
|
15961
|
-
const
|
15962
|
-
const currentEnvironmentOptions = this.environment.config || environmentsOptions?.[environmentName];
|
15963
|
-
const environmentResolveOptions = currentEnvironmentOptions?.resolve;
|
15964
|
-
if (!environmentResolveOptions) {
|
15965
|
-
throw new Error(
|
15966
|
-
`Missing ResolveOptions for ${environmentName} environment`
|
15967
|
-
);
|
15968
|
-
}
|
15991
|
+
const currentEnvironmentOptions = this.environment.config;
|
15969
15992
|
const options = {
|
15970
15993
|
isRequire,
|
15971
|
-
...
|
15994
|
+
...currentEnvironmentOptions.resolve,
|
15972
15995
|
...resolveOptions,
|
15973
15996
|
// plugin options + resolve options overrides
|
15974
15997
|
scan: resolveOpts?.scan ?? resolveOptions.scan
|
@@ -15996,13 +16019,13 @@ function resolvePlugin(resolveOptions, environmentsOptions) {
|
|
15996
16019
|
if (asSrc && id.startsWith(FS_PREFIX)) {
|
15997
16020
|
res = fsPathFromId(id);
|
15998
16021
|
debug$a?.(`[@fs] ${colors.cyan(id)} -> ${colors.dim(res)}`);
|
15999
|
-
return ensureVersionQuery(res, id, options,
|
16022
|
+
return ensureVersionQuery(res, id, options, depsOptimizer);
|
16000
16023
|
}
|
16001
16024
|
if (asSrc && id[0] === "/" && (rootInRoot || !id.startsWith(withTrailingSlash(root)))) {
|
16002
16025
|
const fsPath = path.resolve(root, id.slice(1));
|
16003
16026
|
if (res = tryFsResolve(fsPath, options)) {
|
16004
16027
|
debug$a?.(`[url] ${colors.cyan(id)} -> ${colors.dim(res)}`);
|
16005
|
-
return ensureVersionQuery(res, id, options,
|
16028
|
+
return ensureVersionQuery(res, id, options, depsOptimizer);
|
16006
16029
|
}
|
16007
16030
|
}
|
16008
16031
|
if (id[0] === "." || (preferRelative || importer?.endsWith(".html")) && startsWithWordCharRE.test(id)) {
|
@@ -16025,7 +16048,7 @@ function resolvePlugin(resolveOptions, environmentsOptions) {
|
|
16025
16048
|
return res;
|
16026
16049
|
}
|
16027
16050
|
if (res = tryFsResolve(fsPath, options)) {
|
16028
|
-
res = ensureVersionQuery(res, id, options,
|
16051
|
+
res = ensureVersionQuery(res, id, options, depsOptimizer);
|
16029
16052
|
debug$a?.(`[relative] ${colors.cyan(id)} -> ${colors.dim(res)}`);
|
16030
16053
|
if (!options.idOnly && !options.scan && options.isBuild) {
|
16031
16054
|
const resPkg = findNearestPackageData(
|
@@ -16050,12 +16073,12 @@ function resolvePlugin(resolveOptions, environmentsOptions) {
|
|
16050
16073
|
const fsPath = path.resolve(basedir, id);
|
16051
16074
|
if (res = tryFsResolve(fsPath, options)) {
|
16052
16075
|
debug$a?.(`[drive-relative] ${colors.cyan(id)} -> ${colors.dim(res)}`);
|
16053
|
-
return ensureVersionQuery(res, id, options,
|
16076
|
+
return ensureVersionQuery(res, id, options, depsOptimizer);
|
16054
16077
|
}
|
16055
16078
|
}
|
16056
16079
|
if (isNonDriveRelativeAbsolutePath(id) && (res = tryFsResolve(id, options))) {
|
16057
16080
|
debug$a?.(`[fs] ${colors.cyan(id)} -> ${colors.dim(res)}`);
|
16058
|
-
return ensureVersionQuery(res, id, options,
|
16081
|
+
return ensureVersionQuery(res, id, options, depsOptimizer);
|
16059
16082
|
}
|
16060
16083
|
if (isExternalUrl(id)) {
|
16061
16084
|
return options.idOnly ? id : { id, external: true };
|
@@ -16105,7 +16128,7 @@ function resolvePlugin(resolveOptions, environmentsOptions) {
|
|
16105
16128
|
importer
|
16106
16129
|
)}"`;
|
16107
16130
|
}
|
16108
|
-
message += `. Consider disabling environments.${
|
16131
|
+
message += `. Consider disabling environments.${this.environment.name}.noExternal or remove the built-in dependency.`;
|
16109
16132
|
this.error(message);
|
16110
16133
|
}
|
16111
16134
|
return options.idOnly ? id : { id, external: true, moduleSideEffects: false };
|
@@ -16170,8 +16193,8 @@ function resolveSubpathImports(id, importer, options) {
|
|
16170
16193
|
}
|
16171
16194
|
return importsPath + postfix;
|
16172
16195
|
}
|
16173
|
-
function ensureVersionQuery(resolved, id, options,
|
16174
|
-
if (!
|
16196
|
+
function ensureVersionQuery(resolved, id, options, depsOptimizer) {
|
16197
|
+
if (!options.isBuild && !options.scan && depsOptimizer && !(resolved === normalizedClientEntry$1 || resolved === normalizedEnvEntry$1)) {
|
16175
16198
|
const isNodeModule = isInNodeModules$1(id) || isInNodeModules$1(resolved);
|
16176
16199
|
if (isNodeModule && !DEP_VERSION_RE.test(resolved)) {
|
16177
16200
|
const versionHash = depsOptimizer.metadata.browserHash;
|
@@ -25798,6 +25821,90 @@ function ssrFixStacktrace(e, moduleGraph) {
|
|
25798
25821
|
rewroteStacktraces.add(e);
|
25799
25822
|
}
|
25800
25823
|
|
25824
|
+
function createHMROptions(environment, options) {
|
25825
|
+
if (environment.config.server.hmr === false || options.hmr === false) {
|
25826
|
+
return false;
|
25827
|
+
}
|
25828
|
+
if (!("api" in environment.hot)) return false;
|
25829
|
+
return {
|
25830
|
+
logger: options.hmr?.logger
|
25831
|
+
};
|
25832
|
+
}
|
25833
|
+
const prepareStackTrace = {
|
25834
|
+
retrieveFile(id) {
|
25835
|
+
if (existsSync$1(id)) {
|
25836
|
+
return readFileSync$1(id, "utf-8");
|
25837
|
+
}
|
25838
|
+
}
|
25839
|
+
};
|
25840
|
+
function resolveSourceMapOptions(options) {
|
25841
|
+
if (options.sourcemapInterceptor != null) {
|
25842
|
+
if (options.sourcemapInterceptor === "prepareStackTrace") {
|
25843
|
+
return prepareStackTrace;
|
25844
|
+
}
|
25845
|
+
if (typeof options.sourcemapInterceptor === "object") {
|
25846
|
+
return { ...prepareStackTrace, ...options.sourcemapInterceptor };
|
25847
|
+
}
|
25848
|
+
return options.sourcemapInterceptor;
|
25849
|
+
}
|
25850
|
+
if (typeof process !== "undefined" && "setSourceMapsEnabled" in process) {
|
25851
|
+
return "node";
|
25852
|
+
}
|
25853
|
+
return prepareStackTrace;
|
25854
|
+
}
|
25855
|
+
const createServerModuleRunnerTransport = (options) => {
|
25856
|
+
const hmrClient = {
|
25857
|
+
send: (payload) => {
|
25858
|
+
if (payload.type !== "custom") {
|
25859
|
+
throw new Error(
|
25860
|
+
"Cannot send non-custom events from the client to the server."
|
25861
|
+
);
|
25862
|
+
}
|
25863
|
+
options.channel.send(payload);
|
25864
|
+
}
|
25865
|
+
};
|
25866
|
+
let handler;
|
25867
|
+
return {
|
25868
|
+
connect({ onMessage }) {
|
25869
|
+
options.channel.api.outsideEmitter.on("send", onMessage);
|
25870
|
+
onMessage({ type: "connected" });
|
25871
|
+
handler = onMessage;
|
25872
|
+
},
|
25873
|
+
disconnect() {
|
25874
|
+
if (handler) {
|
25875
|
+
options.channel.api.outsideEmitter.off("send", handler);
|
25876
|
+
}
|
25877
|
+
},
|
25878
|
+
send(payload) {
|
25879
|
+
if (payload.type !== "custom") {
|
25880
|
+
throw new Error(
|
25881
|
+
"Cannot send non-custom events from the server to the client."
|
25882
|
+
);
|
25883
|
+
}
|
25884
|
+
options.channel.api.innerEmitter.emit(
|
25885
|
+
payload.event,
|
25886
|
+
payload.data,
|
25887
|
+
hmrClient
|
25888
|
+
);
|
25889
|
+
}
|
25890
|
+
};
|
25891
|
+
};
|
25892
|
+
function createServerModuleRunner(environment, options = {}) {
|
25893
|
+
const hmr = createHMROptions(environment, options);
|
25894
|
+
return new ModuleRunner(
|
25895
|
+
{
|
25896
|
+
...options,
|
25897
|
+
root: environment.config.root,
|
25898
|
+
transport: createServerModuleRunnerTransport({
|
25899
|
+
channel: environment.hot
|
25900
|
+
}),
|
25901
|
+
hmr,
|
25902
|
+
sourcemapInterceptor: resolveSourceMapOptions(options)
|
25903
|
+
},
|
25904
|
+
options.evaluator || new ESModulesEvaluator()
|
25905
|
+
);
|
25906
|
+
}
|
25907
|
+
|
25801
25908
|
async function ssrLoadModule(url, server, fixStacktrace) {
|
25802
25909
|
const environment = server.environments.ssr;
|
25803
25910
|
server._ssrCompatModuleRunner ||= new SSRCompatModuleRunner(environment);
|
@@ -25838,9 +25945,9 @@ class SSRCompatModuleRunner extends ModuleRunner {
|
|
25838
25945
|
super(
|
25839
25946
|
{
|
25840
25947
|
root: environment.config.root,
|
25841
|
-
transport: {
|
25842
|
-
|
25843
|
-
},
|
25948
|
+
transport: createServerModuleRunnerTransport({
|
25949
|
+
channel: environment.hot
|
25950
|
+
}),
|
25844
25951
|
sourcemapInterceptor: false,
|
25845
25952
|
hmr: false
|
25846
25953
|
},
|
@@ -32906,6 +33013,14 @@ function createWebSocketServer(server, config, httpsOptions) {
|
|
32906
33013
|
},
|
32907
33014
|
on: noop$2,
|
32908
33015
|
off: noop$2,
|
33016
|
+
setInvokeHandler: noop$2,
|
33017
|
+
handleInvoke: async () => ({
|
33018
|
+
e: {
|
33019
|
+
name: "TransportError",
|
33020
|
+
message: "handleInvoke not implemented",
|
33021
|
+
stack: new Error().stack
|
33022
|
+
}
|
33023
|
+
}),
|
32909
33024
|
listen: noop$2,
|
32910
33025
|
send: noop$2
|
32911
33026
|
};
|
@@ -32997,7 +33112,9 @@ ${e.stack || e.message}`),
|
|
32997
33112
|
const listeners = customListeners.get(parsed.event);
|
32998
33113
|
if (!listeners?.size) return;
|
32999
33114
|
const client = getSocketClient(socket);
|
33000
|
-
listeners.forEach(
|
33115
|
+
listeners.forEach(
|
33116
|
+
(listener) => listener(parsed.data, client, parsed.invoke)
|
33117
|
+
);
|
33001
33118
|
});
|
33002
33119
|
socket.on("error", (err) => {
|
33003
33120
|
config.logger.error(`${colors.red(`ws error:`)}
|
@@ -33029,17 +33146,7 @@ ${e.stack || e.message}`),
|
|
33029
33146
|
function getSocketClient(socket) {
|
33030
33147
|
if (!clientsMap.has(socket)) {
|
33031
33148
|
clientsMap.set(socket, {
|
33032
|
-
send: (
|
33033
|
-
let payload;
|
33034
|
-
if (typeof args[0] === "string") {
|
33035
|
-
payload = {
|
33036
|
-
type: "custom",
|
33037
|
-
event: args[0],
|
33038
|
-
data: args[1]
|
33039
|
-
};
|
33040
|
-
} else {
|
33041
|
-
payload = args[0];
|
33042
|
-
}
|
33149
|
+
send: (payload) => {
|
33043
33150
|
socket.send(JSON.stringify(payload));
|
33044
33151
|
},
|
33045
33152
|
socket
|
@@ -33048,78 +33155,84 @@ ${e.stack || e.message}`),
|
|
33048
33155
|
return clientsMap.get(socket);
|
33049
33156
|
}
|
33050
33157
|
let bufferedError = null;
|
33051
|
-
|
33052
|
-
|
33053
|
-
|
33054
|
-
|
33055
|
-
|
33056
|
-
|
33057
|
-
|
33058
|
-
|
33158
|
+
const normalizedHotChannel = normalizeHotChannel(
|
33159
|
+
{
|
33160
|
+
send(payload) {
|
33161
|
+
if (payload.type === "error" && !wss.clients.size) {
|
33162
|
+
bufferedError = payload;
|
33163
|
+
return;
|
33164
|
+
}
|
33165
|
+
const stringified = JSON.stringify(payload);
|
33166
|
+
wss.clients.forEach((client) => {
|
33167
|
+
if (client.readyState === 1) {
|
33168
|
+
client.send(stringified);
|
33169
|
+
}
|
33170
|
+
});
|
33171
|
+
},
|
33172
|
+
on(event, fn) {
|
33059
33173
|
if (!customListeners.has(event)) {
|
33060
33174
|
customListeners.set(event, /* @__PURE__ */ new Set());
|
33061
33175
|
}
|
33062
33176
|
customListeners.get(event).add(fn);
|
33177
|
+
},
|
33178
|
+
off(event, fn) {
|
33179
|
+
customListeners.get(event)?.delete(fn);
|
33180
|
+
},
|
33181
|
+
listen() {
|
33182
|
+
wsHttpServer?.listen(port, host);
|
33183
|
+
},
|
33184
|
+
close() {
|
33185
|
+
if (hmrServerWsListener && wsServer) {
|
33186
|
+
wsServer.off("upgrade", hmrServerWsListener);
|
33187
|
+
}
|
33188
|
+
return new Promise((resolve, reject) => {
|
33189
|
+
wss.clients.forEach((client) => {
|
33190
|
+
client.terminate();
|
33191
|
+
});
|
33192
|
+
wss.close((err) => {
|
33193
|
+
if (err) {
|
33194
|
+
reject(err);
|
33195
|
+
} else {
|
33196
|
+
if (wsHttpServer) {
|
33197
|
+
wsHttpServer.close((err2) => {
|
33198
|
+
if (err2) {
|
33199
|
+
reject(err2);
|
33200
|
+
} else {
|
33201
|
+
resolve();
|
33202
|
+
}
|
33203
|
+
});
|
33204
|
+
} else {
|
33205
|
+
resolve();
|
33206
|
+
}
|
33207
|
+
}
|
33208
|
+
});
|
33209
|
+
});
|
33210
|
+
}
|
33211
|
+
},
|
33212
|
+
config.server.hmr !== false
|
33213
|
+
);
|
33214
|
+
return {
|
33215
|
+
...normalizedHotChannel,
|
33216
|
+
on: (event, fn) => {
|
33217
|
+
if (wsServerEvents.includes(event)) {
|
33218
|
+
wss.on(event, fn);
|
33219
|
+
return;
|
33063
33220
|
}
|
33221
|
+
normalizedHotChannel.on(event, fn);
|
33064
33222
|
},
|
33065
33223
|
off: (event, fn) => {
|
33066
33224
|
if (wsServerEvents.includes(event)) {
|
33067
33225
|
wss.off(event, fn);
|
33068
|
-
|
33069
|
-
customListeners.get(event)?.delete(fn);
|
33226
|
+
return;
|
33070
33227
|
}
|
33228
|
+
normalizedHotChannel.off(event, fn);
|
33229
|
+
},
|
33230
|
+
async close() {
|
33231
|
+
await normalizedHotChannel.close();
|
33071
33232
|
},
|
33233
|
+
[isWebSocketServer]: true,
|
33072
33234
|
get clients() {
|
33073
33235
|
return new Set(Array.from(wss.clients).map(getSocketClient));
|
33074
|
-
},
|
33075
|
-
send(...args) {
|
33076
|
-
let payload;
|
33077
|
-
if (typeof args[0] === "string") {
|
33078
|
-
payload = {
|
33079
|
-
type: "custom",
|
33080
|
-
event: args[0],
|
33081
|
-
data: args[1]
|
33082
|
-
};
|
33083
|
-
} else {
|
33084
|
-
payload = args[0];
|
33085
|
-
}
|
33086
|
-
if (payload.type === "error" && !wss.clients.size) {
|
33087
|
-
bufferedError = payload;
|
33088
|
-
return;
|
33089
|
-
}
|
33090
|
-
const stringified = JSON.stringify(payload);
|
33091
|
-
wss.clients.forEach((client) => {
|
33092
|
-
if (client.readyState === 1) {
|
33093
|
-
client.send(stringified);
|
33094
|
-
}
|
33095
|
-
});
|
33096
|
-
},
|
33097
|
-
close() {
|
33098
|
-
if (hmrServerWsListener && wsServer) {
|
33099
|
-
wsServer.off("upgrade", hmrServerWsListener);
|
33100
|
-
}
|
33101
|
-
return new Promise((resolve, reject) => {
|
33102
|
-
wss.clients.forEach((client) => {
|
33103
|
-
client.terminate();
|
33104
|
-
});
|
33105
|
-
wss.close((err) => {
|
33106
|
-
if (err) {
|
33107
|
-
reject(err);
|
33108
|
-
} else {
|
33109
|
-
if (wsHttpServer) {
|
33110
|
-
wsHttpServer.close((err2) => {
|
33111
|
-
if (err2) {
|
33112
|
-
reject(err2);
|
33113
|
-
} else {
|
33114
|
-
resolve();
|
33115
|
-
}
|
33116
|
-
});
|
33117
|
-
} else {
|
33118
|
-
resolve();
|
33119
|
-
}
|
33120
|
-
}
|
33121
|
-
});
|
33122
|
-
});
|
33123
33236
|
}
|
33124
33237
|
};
|
33125
33238
|
}
|
@@ -39358,6 +39471,130 @@ const normalizedClientDir = normalizePath$1(CLIENT_DIR);
|
|
39358
39471
|
function getShortName(file, root) {
|
39359
39472
|
return file.startsWith(withTrailingSlash(root)) ? path.posix.relative(root, file) : file;
|
39360
39473
|
}
|
39474
|
+
const normalizeHotChannel = (channel, enableHmr) => {
|
39475
|
+
const normalizedListenerMap = /* @__PURE__ */ new WeakMap();
|
39476
|
+
const listenersForEvents = /* @__PURE__ */ new Map();
|
39477
|
+
let invokeHandlers;
|
39478
|
+
let listenerForInvokeHandler;
|
39479
|
+
const handleInvoke = async (payload) => {
|
39480
|
+
if (!invokeHandlers) {
|
39481
|
+
return {
|
39482
|
+
e: {
|
39483
|
+
name: "TransportError",
|
39484
|
+
message: "invokeHandlers is not set",
|
39485
|
+
stack: new Error().stack
|
39486
|
+
}
|
39487
|
+
};
|
39488
|
+
}
|
39489
|
+
const data = payload.data;
|
39490
|
+
const { name, data: args } = data;
|
39491
|
+
try {
|
39492
|
+
const invokeHandler = invokeHandlers[name];
|
39493
|
+
const result = await invokeHandler(...args);
|
39494
|
+
return { r: result };
|
39495
|
+
} catch (error2) {
|
39496
|
+
return {
|
39497
|
+
e: {
|
39498
|
+
name: error2.name,
|
39499
|
+
message: error2.message,
|
39500
|
+
stack: error2.stack
|
39501
|
+
}
|
39502
|
+
};
|
39503
|
+
}
|
39504
|
+
};
|
39505
|
+
return {
|
39506
|
+
...channel,
|
39507
|
+
on: (event, fn) => {
|
39508
|
+
if (event === "connection") {
|
39509
|
+
channel.on?.(event, fn);
|
39510
|
+
return;
|
39511
|
+
}
|
39512
|
+
const listenerWithNormalizedClient = (data, client) => {
|
39513
|
+
const normalizedClient = {
|
39514
|
+
send: (...args) => {
|
39515
|
+
let payload;
|
39516
|
+
if (typeof args[0] === "string") {
|
39517
|
+
payload = {
|
39518
|
+
type: "custom",
|
39519
|
+
event: args[0],
|
39520
|
+
data: args[1]
|
39521
|
+
};
|
39522
|
+
} else {
|
39523
|
+
payload = args[0];
|
39524
|
+
}
|
39525
|
+
client.send(payload);
|
39526
|
+
}
|
39527
|
+
};
|
39528
|
+
fn(data, normalizedClient);
|
39529
|
+
};
|
39530
|
+
normalizedListenerMap.set(fn, listenerWithNormalizedClient);
|
39531
|
+
channel.on?.(event, listenerWithNormalizedClient);
|
39532
|
+
if (!listenersForEvents.has(event)) {
|
39533
|
+
listenersForEvents.set(event, /* @__PURE__ */ new Set());
|
39534
|
+
}
|
39535
|
+
listenersForEvents.get(event).add(listenerWithNormalizedClient);
|
39536
|
+
},
|
39537
|
+
off: (event, fn) => {
|
39538
|
+
if (event === "connection") {
|
39539
|
+
channel.off?.(event, fn);
|
39540
|
+
return;
|
39541
|
+
}
|
39542
|
+
const normalizedListener = normalizedListenerMap.get(fn);
|
39543
|
+
if (normalizedListener) {
|
39544
|
+
channel.off?.(event, normalizedListener);
|
39545
|
+
listenersForEvents.get(event)?.delete(normalizedListener);
|
39546
|
+
}
|
39547
|
+
},
|
39548
|
+
setInvokeHandler(_invokeHandlers) {
|
39549
|
+
invokeHandlers = _invokeHandlers;
|
39550
|
+
if (!_invokeHandlers) {
|
39551
|
+
if (listenerForInvokeHandler) {
|
39552
|
+
channel.off?.("vite:invoke", listenerForInvokeHandler);
|
39553
|
+
}
|
39554
|
+
return;
|
39555
|
+
}
|
39556
|
+
listenerForInvokeHandler = async (payload, client) => {
|
39557
|
+
const responseInvoke = payload.id.replace("send", "response");
|
39558
|
+
client.send({
|
39559
|
+
type: "custom",
|
39560
|
+
event: "vite:invoke",
|
39561
|
+
data: {
|
39562
|
+
name: payload.name,
|
39563
|
+
id: responseInvoke,
|
39564
|
+
data: await handleInvoke({
|
39565
|
+
type: "custom",
|
39566
|
+
event: "vite:invoke",
|
39567
|
+
data: payload
|
39568
|
+
})
|
39569
|
+
}
|
39570
|
+
});
|
39571
|
+
};
|
39572
|
+
channel.on?.("vite:invoke", listenerForInvokeHandler);
|
39573
|
+
},
|
39574
|
+
handleInvoke,
|
39575
|
+
send: (...args) => {
|
39576
|
+
let payload;
|
39577
|
+
if (typeof args[0] === "string") {
|
39578
|
+
payload = {
|
39579
|
+
type: "custom",
|
39580
|
+
event: args[0],
|
39581
|
+
data: args[1]
|
39582
|
+
};
|
39583
|
+
} else {
|
39584
|
+
payload = args[0];
|
39585
|
+
}
|
39586
|
+
if (enableHmr || payload.type === "connected" || payload.type === "ping" || payload.type === "custom" || payload.type === "error") {
|
39587
|
+
channel.send?.(payload);
|
39588
|
+
}
|
39589
|
+
},
|
39590
|
+
listen() {
|
39591
|
+
return channel.listen?.();
|
39592
|
+
},
|
39593
|
+
close() {
|
39594
|
+
return channel.close?.();
|
39595
|
+
}
|
39596
|
+
};
|
39597
|
+
};
|
39361
39598
|
function getSortedPluginsByHotUpdateHook(plugins) {
|
39362
39599
|
const sortedPlugins = [];
|
39363
39600
|
let pre = 0, normal = 0, post = 0;
|
@@ -39901,17 +40138,7 @@ function createServerHotChannel() {
|
|
39901
40138
|
const innerEmitter = new EventEmitter$1();
|
39902
40139
|
const outsideEmitter = new EventEmitter$1();
|
39903
40140
|
return {
|
39904
|
-
send(
|
39905
|
-
let payload;
|
39906
|
-
if (typeof args[0] === "string") {
|
39907
|
-
payload = {
|
39908
|
-
type: "custom",
|
39909
|
-
event: args[0],
|
39910
|
-
data: args[1]
|
39911
|
-
};
|
39912
|
-
} else {
|
39913
|
-
payload = args[0];
|
39914
|
-
}
|
40141
|
+
send(payload) {
|
39915
40142
|
outsideEmitter.emit("send", payload);
|
39916
40143
|
},
|
39917
40144
|
off(event, listener) {
|
@@ -39933,23 +40160,20 @@ function createServerHotChannel() {
|
|
39933
40160
|
}
|
39934
40161
|
};
|
39935
40162
|
}
|
39936
|
-
function createNoopHotChannel() {
|
39937
|
-
function noop() {
|
39938
|
-
}
|
39939
|
-
return {
|
39940
|
-
send: noop,
|
39941
|
-
on: noop,
|
39942
|
-
off: noop,
|
39943
|
-
listen: noop,
|
39944
|
-
close: noop
|
39945
|
-
};
|
39946
|
-
}
|
39947
40163
|
function createDeprecatedHotBroadcaster(ws) {
|
39948
40164
|
const broadcaster = {
|
39949
40165
|
on: ws.on,
|
39950
40166
|
off: ws.off,
|
39951
40167
|
listen: ws.listen,
|
39952
40168
|
send: ws.send,
|
40169
|
+
setInvokeHandler: ws.setInvokeHandler,
|
40170
|
+
handleInvoke: async () => ({
|
40171
|
+
e: {
|
40172
|
+
name: "TransportError",
|
40173
|
+
message: "handleInvoke not implemented",
|
40174
|
+
stack: new Error().stack
|
40175
|
+
}
|
40176
|
+
}),
|
39953
40177
|
get channels() {
|
39954
40178
|
return [ws];
|
39955
40179
|
},
|
@@ -39957,7 +40181,9 @@ function createDeprecatedHotBroadcaster(ws) {
|
|
39957
40181
|
return broadcaster;
|
39958
40182
|
},
|
39959
40183
|
close() {
|
39960
|
-
return Promise.all(
|
40184
|
+
return Promise.all(
|
40185
|
+
broadcaster.channels.map((channel) => channel.close?.())
|
40186
|
+
);
|
39961
40187
|
}
|
39962
40188
|
};
|
39963
40189
|
return broadcaster;
|
@@ -41962,18 +42188,15 @@ async function resolvePlugins(config, prePlugins, normalPlugins, postPlugins) {
|
|
41962
42188
|
}),
|
41963
42189
|
...prePlugins,
|
41964
42190
|
modulePreload !== false && modulePreload.polyfill ? modulePreloadPolyfillPlugin(config) : null,
|
41965
|
-
resolvePlugin(
|
41966
|
-
|
41967
|
-
|
41968
|
-
|
41969
|
-
|
41970
|
-
|
41971
|
-
|
41972
|
-
|
41973
|
-
|
41974
|
-
},
|
41975
|
-
config.environments
|
41976
|
-
),
|
42191
|
+
resolvePlugin({
|
42192
|
+
root: config.root,
|
42193
|
+
isProduction: config.isProduction,
|
42194
|
+
isBuild,
|
42195
|
+
packageCache: config.packageCache,
|
42196
|
+
asSrc: true,
|
42197
|
+
optimizeDeps: true,
|
42198
|
+
externalize: true
|
42199
|
+
}),
|
41977
42200
|
htmlInlineProxyPlugin(config),
|
41978
42201
|
cssPlugin(config),
|
41979
42202
|
config.esbuild !== false ? esbuildPlugin(config) : null,
|
@@ -42221,12 +42444,13 @@ class EnvironmentPluginContainer {
|
|
42221
42444
|
return;
|
42222
42445
|
}
|
42223
42446
|
this._started = true;
|
42447
|
+
const config = this.environment.getTopLevelConfig();
|
42224
42448
|
this._buildStartPromise = this.handleHookPromise(
|
42225
42449
|
this.hookParallel(
|
42226
42450
|
"buildStart",
|
42227
42451
|
(plugin) => this._getPluginContext(plugin),
|
42228
42452
|
() => [this.options],
|
42229
|
-
(plugin) => this.environment.name === "client" ||
|
42453
|
+
(plugin) => this.environment.name === "client" || config.server.perEnvironmentStartEndDuringDev || plugin.perEnvironmentStartEndDuringDev
|
42230
42454
|
)
|
42231
42455
|
);
|
42232
42456
|
await this._buildStartPromise;
|
@@ -42378,11 +42602,12 @@ class EnvironmentPluginContainer {
|
|
42378
42602
|
if (this._closed) return;
|
42379
42603
|
this._closed = true;
|
42380
42604
|
await Promise.allSettled(Array.from(this._processesing));
|
42605
|
+
const config = this.environment.getTopLevelConfig();
|
42381
42606
|
await this.hookParallel(
|
42382
42607
|
"buildEnd",
|
42383
42608
|
(plugin) => this._getPluginContext(plugin),
|
42384
42609
|
() => [],
|
42385
|
-
(plugin) => this.environment.name === "client" ||
|
42610
|
+
(plugin) => this.environment.name === "client" || config.server.perEnvironmentStartEndDuringDev || plugin.perEnvironmentStartEndDuringDev
|
42386
42611
|
);
|
42387
42612
|
await this.hookParallel(
|
42388
42613
|
"closeBundle",
|
@@ -43380,9 +43605,9 @@ function cssAnalysisPlugin(config) {
|
|
43380
43605
|
for (const file of pluginImports) {
|
43381
43606
|
depModules.add(
|
43382
43607
|
isCSSRequest(file) ? moduleGraph.createFileOnlyEntry(file) : await moduleGraph.ensureEntryFromUrl(
|
43383
|
-
fileToDevUrl(
|
43608
|
+
await fileToDevUrl(
|
43609
|
+
this.environment,
|
43384
43610
|
file,
|
43385
|
-
config,
|
43386
43611
|
/* skipBase */
|
43387
43612
|
true
|
43388
43613
|
)
|
@@ -43747,8 +43972,8 @@ function createCachedImport(imp) {
|
|
43747
43972
|
return cached;
|
43748
43973
|
};
|
43749
43974
|
}
|
43750
|
-
const importPostcssImport = createCachedImport(() => import('./dep-
|
43751
|
-
const importPostcssModules = createCachedImport(() => import('./dep-
|
43975
|
+
const importPostcssImport = createCachedImport(() => import('./dep-DIgjieZc.js').then(function (n) { return n.i; }));
|
43976
|
+
const importPostcssModules = createCachedImport(() => import('./dep-BLfo3Ie2.js').then(function (n) { return n.i; }));
|
43752
43977
|
const importPostcss = createCachedImport(() => import('postcss'));
|
43753
43978
|
const preprocessorWorkerControllerCache = /* @__PURE__ */ new WeakMap();
|
43754
43979
|
let alwaysFakeWorkerWorkerControllerCache;
|
@@ -47480,10 +47705,14 @@ class DevEnvironment extends BaseEnvironment {
|
|
47480
47705
|
name,
|
47481
47706
|
(url) => this.pluginContainer.resolveId(url, void 0)
|
47482
47707
|
);
|
47483
|
-
this.hot = context.hot || createNoopHotChannel();
|
47484
47708
|
this._crawlEndFinder = setupOnCrawlEnd();
|
47485
47709
|
this._remoteRunnerOptions = context.remoteRunner ?? {};
|
47486
|
-
context.
|
47710
|
+
this.hot = context.transport ? isWebSocketServer in context.transport ? context.transport : normalizeHotChannel(context.transport, context.hot) : normalizeHotChannel({}, context.hot);
|
47711
|
+
this.hot.setInvokeHandler({
|
47712
|
+
fetchModule: (id, importer, options2) => {
|
47713
|
+
return this.fetchModule(id, importer, options2);
|
47714
|
+
}
|
47715
|
+
});
|
47487
47716
|
this.hot.on("vite:invalidate", async ({ path, message }) => {
|
47488
47717
|
invalidateModule(this, {
|
47489
47718
|
path,
|
@@ -47556,7 +47785,7 @@ class DevEnvironment extends BaseEnvironment {
|
|
47556
47785
|
this.pluginContainer.close(),
|
47557
47786
|
this.depsOptimizer?.close(),
|
47558
47787
|
// WebSocketServer is independent of HotChannel and should not be closed on environment close
|
47559
|
-
isWebSocketServer in this.hot ? Promise.resolve() : this.hot.close(),
|
47788
|
+
isWebSocketServer in this.hot ? Promise.resolve() : this.hot.close?.(),
|
47560
47789
|
(async () => {
|
47561
47790
|
while (this._pendingRequests.size > 0) {
|
47562
47791
|
await Promise.allSettled(
|
@@ -47654,117 +47883,12 @@ function setupOnCrawlEnd() {
|
|
47654
47883
|
};
|
47655
47884
|
}
|
47656
47885
|
|
47657
|
-
class ServerHMRBroadcasterClient {
|
47658
|
-
constructor(hotChannel) {
|
47659
|
-
this.hotChannel = hotChannel;
|
47660
|
-
}
|
47661
|
-
send(...args) {
|
47662
|
-
let payload;
|
47663
|
-
if (typeof args[0] === "string") {
|
47664
|
-
payload = {
|
47665
|
-
type: "custom",
|
47666
|
-
event: args[0],
|
47667
|
-
data: args[1]
|
47668
|
-
};
|
47669
|
-
} else {
|
47670
|
-
payload = args[0];
|
47671
|
-
}
|
47672
|
-
if (payload.type !== "custom") {
|
47673
|
-
throw new Error(
|
47674
|
-
"Cannot send non-custom events from the client to the server."
|
47675
|
-
);
|
47676
|
-
}
|
47677
|
-
this.hotChannel.send(payload);
|
47678
|
-
}
|
47679
|
-
}
|
47680
|
-
class ServerHMRConnector {
|
47681
|
-
constructor(hotChannel) {
|
47682
|
-
this.hotChannel = hotChannel;
|
47683
|
-
this.hmrClient = new ServerHMRBroadcasterClient(hotChannel);
|
47684
|
-
hotChannel.api.outsideEmitter.on("send", (payload) => {
|
47685
|
-
this.handlers.forEach((listener) => listener(payload));
|
47686
|
-
});
|
47687
|
-
this.hotChannel = hotChannel;
|
47688
|
-
}
|
47689
|
-
handlers = [];
|
47690
|
-
hmrClient;
|
47691
|
-
connected = false;
|
47692
|
-
isReady() {
|
47693
|
-
return this.connected;
|
47694
|
-
}
|
47695
|
-
send(payload_) {
|
47696
|
-
const payload = payload_;
|
47697
|
-
this.hotChannel.api.innerEmitter.emit(
|
47698
|
-
payload.event,
|
47699
|
-
payload.data,
|
47700
|
-
this.hmrClient
|
47701
|
-
);
|
47702
|
-
}
|
47703
|
-
onUpdate(handler) {
|
47704
|
-
this.handlers.push(handler);
|
47705
|
-
handler({ type: "connected" });
|
47706
|
-
this.connected = true;
|
47707
|
-
}
|
47708
|
-
}
|
47709
|
-
|
47710
|
-
function createHMROptions(environment, options) {
|
47711
|
-
if (environment.config.server.hmr === false || options.hmr === false) {
|
47712
|
-
return false;
|
47713
|
-
}
|
47714
|
-
if (options.hmr?.connection) {
|
47715
|
-
return {
|
47716
|
-
connection: options.hmr.connection,
|
47717
|
-
logger: options.hmr.logger
|
47718
|
-
};
|
47719
|
-
}
|
47720
|
-
if (!("api" in environment.hot)) return false;
|
47721
|
-
const connection = new ServerHMRConnector(environment.hot);
|
47722
|
-
return {
|
47723
|
-
connection,
|
47724
|
-
logger: options.hmr?.logger
|
47725
|
-
};
|
47726
|
-
}
|
47727
|
-
const prepareStackTrace = {
|
47728
|
-
retrieveFile(id) {
|
47729
|
-
if (existsSync$1(id)) {
|
47730
|
-
return readFileSync$1(id, "utf-8");
|
47731
|
-
}
|
47732
|
-
}
|
47733
|
-
};
|
47734
|
-
function resolveSourceMapOptions(options) {
|
47735
|
-
if (options.sourcemapInterceptor != null) {
|
47736
|
-
if (options.sourcemapInterceptor === "prepareStackTrace") {
|
47737
|
-
return prepareStackTrace;
|
47738
|
-
}
|
47739
|
-
if (typeof options.sourcemapInterceptor === "object") {
|
47740
|
-
return { ...prepareStackTrace, ...options.sourcemapInterceptor };
|
47741
|
-
}
|
47742
|
-
return options.sourcemapInterceptor;
|
47743
|
-
}
|
47744
|
-
if (typeof process !== "undefined" && "setSourceMapsEnabled" in process) {
|
47745
|
-
return "node";
|
47746
|
-
}
|
47747
|
-
return prepareStackTrace;
|
47748
|
-
}
|
47749
|
-
function createServerModuleRunner(environment, options = {}) {
|
47750
|
-
const hmr = createHMROptions(environment, options);
|
47751
|
-
return new ModuleRunner(
|
47752
|
-
{
|
47753
|
-
...options,
|
47754
|
-
root: environment.config.root,
|
47755
|
-
transport: {
|
47756
|
-
fetchModule: (id, importer, options2) => environment.fetchModule(id, importer, options2)
|
47757
|
-
},
|
47758
|
-
hmr,
|
47759
|
-
sourcemapInterceptor: resolveSourceMapOptions(options)
|
47760
|
-
},
|
47761
|
-
options.evaluator || new ESModulesEvaluator()
|
47762
|
-
);
|
47763
|
-
}
|
47764
|
-
|
47765
47886
|
function createRunnableDevEnvironment(name, config, context = {}) {
|
47887
|
+
if (context.transport == null) {
|
47888
|
+
context.transport = createServerHotChannel();
|
47889
|
+
}
|
47766
47890
|
if (context.hot == null) {
|
47767
|
-
context.hot =
|
47891
|
+
context.hot = true;
|
47768
47892
|
}
|
47769
47893
|
return new RunnableDevEnvironment(name, config, context);
|
47770
47894
|
}
|
@@ -48075,16 +48199,12 @@ function defineConfig(config) {
|
|
48075
48199
|
}
|
48076
48200
|
function defaultCreateClientDevEnvironment(name, config, context) {
|
48077
48201
|
return new DevEnvironment(name, config, {
|
48078
|
-
hot:
|
48202
|
+
hot: true,
|
48203
|
+
transport: context.ws
|
48079
48204
|
});
|
48080
48205
|
}
|
48081
|
-
function defaultCreateSsrDevEnvironment(name, config) {
|
48082
|
-
return createRunnableDevEnvironment(name, config);
|
48083
|
-
}
|
48084
48206
|
function defaultCreateDevEnvironment(name, config) {
|
48085
|
-
return
|
48086
|
-
hot: false
|
48087
|
-
});
|
48207
|
+
return createRunnableDevEnvironment(name, config);
|
48088
48208
|
}
|
48089
48209
|
function resolveDevEnvironmentOptions(dev, environmentName, consumer, skipSsrTransform) {
|
48090
48210
|
return {
|
@@ -48092,7 +48212,7 @@ function resolveDevEnvironmentOptions(dev, environmentName, consumer, skipSsrTra
|
|
48092
48212
|
sourcemapIgnoreList: dev?.sourcemapIgnoreList === false ? () => false : dev?.sourcemapIgnoreList || isInNodeModules$1,
|
48093
48213
|
preTransformRequests: dev?.preTransformRequests ?? consumer === "client",
|
48094
48214
|
warmup: dev?.warmup ?? [],
|
48095
|
-
createEnvironment: dev?.createEnvironment ?? (environmentName === "client" ? defaultCreateClientDevEnvironment :
|
48215
|
+
createEnvironment: dev?.createEnvironment ?? (environmentName === "client" ? defaultCreateClientDevEnvironment : defaultCreateDevEnvironment),
|
48096
48216
|
recoverable: dev?.recoverable ?? consumer === "client",
|
48097
48217
|
moduleRunnerTransform: dev?.moduleRunnerTransform ?? (skipSsrTransform !== void 0 && consumer === "server" ? skipSsrTransform : consumer === "server")
|
48098
48218
|
};
|
@@ -48177,10 +48297,12 @@ const clientAlias = [
|
|
48177
48297
|
}
|
48178
48298
|
];
|
48179
48299
|
function resolveEnvironmentResolveOptions(resolve, alias, preserveSymlinks, logger, consumer, isSsrTargetWebworkerEnvironment) {
|
48300
|
+
let mainFields = resolve?.mainFields;
|
48301
|
+
mainFields ??= consumer === "client" || isSsrTargetWebworkerEnvironment ? DEFAULT_MAIN_FIELDS : DEFAULT_MAIN_FIELDS.filter((f) => f !== "browser");
|
48180
48302
|
let conditions = resolve?.conditions;
|
48181
48303
|
conditions ??= consumer === "client" || isSsrTargetWebworkerEnvironment ? DEFAULT_CONDITIONS.filter((c) => c !== "node") : DEFAULT_CONDITIONS.filter((c) => c !== "browser");
|
48182
48304
|
const resolvedResolve = {
|
48183
|
-
mainFields
|
48305
|
+
mainFields,
|
48184
48306
|
conditions,
|
48185
48307
|
externalConditions: resolve?.externalConditions ?? DEFAULT_EXTERNAL_CONDITIONS,
|
48186
48308
|
external: resolve?.external ?? (consumer === "server" && !isSsrTargetWebworkerEnvironment ? builtinModules : []),
|
@@ -48205,6 +48327,13 @@ function resolveEnvironmentResolveOptions(resolve, alias, preserveSymlinks, logg
|
|
48205
48327
|
function resolveResolveOptions(resolve, logger) {
|
48206
48328
|
const alias = normalizeAlias(mergeAlias(clientAlias, resolve?.alias || []));
|
48207
48329
|
const preserveSymlinks = resolve?.preserveSymlinks ?? false;
|
48330
|
+
if (alias.some((a) => a.find === "/")) {
|
48331
|
+
logger.warn(
|
48332
|
+
colors.yellow(
|
48333
|
+
`\`resolve.alias\` contains an alias that maps \`/\`. This is not recommended as it can cause unexpected behavior when resolving paths.`
|
48334
|
+
)
|
48335
|
+
);
|
48336
|
+
}
|
48208
48337
|
return resolveEnvironmentResolveOptions(
|
48209
48338
|
resolve,
|
48210
48339
|
alias,
|
@@ -48944,4 +49073,4 @@ function optimizeDepsDisabledBackwardCompatibility(resolved, optimizeDeps, optim
|
|
48944
49073
|
}
|
48945
49074
|
}
|
48946
49075
|
|
48947
|
-
export { rollupVersion as A, BuildEnvironment as B, send$1 as C, DevEnvironment as D, createLogger as E, searchForWorkspaceRoot as F, isFileServingAllowed as G, isFileLoadingAllowed as H, loadEnv as I, resolveEnvPrefix as J, colors as K, getDefaultExportFromCjs as L, commonjsGlobal as M, index$1 as N, index as O, build$1 as P, preview$1 as Q,
|
49076
|
+
export { rollupVersion as A, BuildEnvironment as B, send$1 as C, DevEnvironment as D, createLogger as E, searchForWorkspaceRoot as F, isFileServingAllowed as G, isFileLoadingAllowed as H, loadEnv as I, resolveEnvPrefix as J, colors as K, getDefaultExportFromCjs as L, commonjsGlobal as M, index$1 as N, index as O, build$1 as P, preview$1 as Q, arraify as a, build as b, createServer as c, defineConfig as d, createBuilder as e, createIdResolver as f, formatPostcssSourceMap as g, preprocessCSS as h, isInNodeModules$1 as i, buildErrorMessage as j, createRunnableDevEnvironment as k, loadConfigFromFile as l, isRunnableDevEnvironment as m, fetchModule as n, optimizeDeps as o, preview as p, createServerModuleRunner as q, resolveConfig as r, sortUserPlugins as s, transformWithEsbuild as t, createServerHotChannel as u, ssrTransform as v, normalizePath$1 as w, mergeConfig as x, mergeAlias as y, createFilter as z };
|