Initial commit

This commit is contained in:
Alejandro Martinez
2026-02-12 02:04:10 +01:00
commit f09af719cf
13433 changed files with 2193445 additions and 0 deletions

24
node_modules/astro/dist/core/config/config.d.ts generated vendored Normal file
View File

@@ -0,0 +1,24 @@
import fs from 'node:fs';
import type { AstroConfig, AstroInlineConfig, AstroUserConfig } from '../../types/public/config.js';
export declare function resolveRoot(cwd?: string | URL): string;
interface ResolveConfigPathOptions {
root: string;
configFile?: string | false;
fs: typeof fs;
}
/**
* Resolve the file URL of the user's `astro.config.js|cjs|mjs|ts` file
*/
export declare function resolveConfigPath(options: ResolveConfigPathOptions): Promise<string | undefined>;
interface ResolveConfigResult {
userConfig: AstroUserConfig;
astroConfig: AstroConfig;
}
/**
* Resolves the Astro config with a given inline config.
*
* @param inlineConfig An inline config that takes highest priority when merging and resolving the final config.
* @param command The running command that uses this config. Usually 'dev' or 'build'.
*/
export declare function resolveConfig(inlineConfig: AstroInlineConfig, command: string, fsMod?: typeof fs): Promise<ResolveConfigResult>;
export {};

107
node_modules/astro/dist/core/config/config.js generated vendored Normal file
View File

@@ -0,0 +1,107 @@
import fs from "node:fs";
import path from "node:path";
import { fileURLToPath } from "node:url";
import colors from "piccolore";
import { ZodError } from "zod";
import { eventConfigError, telemetry } from "../../events/index.js";
import { trackAstroConfigZodError } from "../errors/errors.js";
import { AstroError, AstroErrorData } from "../errors/index.js";
import { formatConfigErrorMessage } from "../messages.js";
import { mergeConfig } from "./merge.js";
import { validateConfig } from "./validate.js";
import { loadConfigWithVite } from "./vite-load.js";
function resolveRoot(cwd) {
if (cwd instanceof URL) {
cwd = fileURLToPath(cwd);
}
return cwd ? path.resolve(cwd) : process.cwd();
}
const configPaths = Object.freeze([
"astro.config.mjs",
"astro.config.js",
"astro.config.ts",
"astro.config.mts",
"astro.config.cjs",
"astro.config.cts"
]);
async function search(fsMod, root) {
const paths = configPaths.map((p) => path.join(root, p));
for (const file of paths) {
if (fsMod.existsSync(file)) {
return file;
}
}
}
async function resolveConfigPath(options) {
let userConfigPath;
if (options.configFile) {
userConfigPath = path.join(options.root, options.configFile);
if (!options.fs.existsSync(userConfigPath)) {
throw new AstroError({
...AstroErrorData.ConfigNotFound,
message: AstroErrorData.ConfigNotFound.message(options.configFile)
});
}
} else {
userConfigPath = await search(options.fs, options.root);
}
return userConfigPath;
}
async function loadConfig(root, configFile, fsMod = fs) {
if (configFile === false) return {};
const configPath = await resolveConfigPath({
root,
configFile,
fs: fsMod
});
if (!configPath) return {};
try {
return await loadConfigWithVite({
root,
configPath,
fs: fsMod
});
} catch (e) {
const configPathText = configFile ? colors.bold(configFile) : "your Astro config";
console.error(`${colors.bold(colors.red("[astro]"))} Unable to load ${configPathText}
`);
throw e;
}
}
function splitInlineConfig(inlineConfig) {
const { configFile, mode, logLevel, ...inlineUserConfig } = inlineConfig;
return {
inlineUserConfig,
inlineOnlyConfig: {
configFile,
mode,
logLevel
}
};
}
async function resolveConfig(inlineConfig, command, fsMod = fs) {
const root = resolveRoot(inlineConfig.root);
const { inlineUserConfig, inlineOnlyConfig } = splitInlineConfig(inlineConfig);
if (inlineConfig.root) {
inlineUserConfig.root = root;
}
const userConfig = await loadConfig(root, inlineOnlyConfig.configFile, fsMod);
const mergedConfig = mergeConfig(userConfig, inlineUserConfig);
let astroConfig;
try {
astroConfig = await validateConfig(mergedConfig, root, command);
} catch (e) {
if (e instanceof ZodError) {
trackAstroConfigZodError(e);
console.error(formatConfigErrorMessage(e) + "\n");
telemetry.record(eventConfigError({ cmd: command, err: e, isFatal: true }));
}
throw e;
}
return { userConfig: mergedConfig, astroConfig };
}
export {
resolveConfig,
resolveConfigPath,
resolveRoot
};

5
node_modules/astro/dist/core/config/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,5 @@
export { resolveConfig, resolveConfigPath, resolveRoot, } from './config.js';
export { createNodeLogger } from './logging.js';
export { mergeConfig } from './merge.js';
export { createSettings } from './settings.js';
export { loadTSConfig, updateTSConfigForFramework } from './tsconfig.js';

19
node_modules/astro/dist/core/config/index.js generated vendored Normal file
View File

@@ -0,0 +1,19 @@
import {
resolveConfig,
resolveConfigPath,
resolveRoot
} from "./config.js";
import { createNodeLogger } from "./logging.js";
import { mergeConfig } from "./merge.js";
import { createSettings } from "./settings.js";
import { loadTSConfig, updateTSConfigForFramework } from "./tsconfig.js";
export {
createNodeLogger,
createSettings,
loadTSConfig,
mergeConfig,
resolveConfig,
resolveConfigPath,
resolveRoot,
updateTSConfigForFramework
};

3
node_modules/astro/dist/core/config/logging.d.ts generated vendored Normal file
View File

@@ -0,0 +1,3 @@
import type { AstroInlineConfig } from '../../types/public/config.js';
import { Logger } from '../logger/core.js';
export declare function createNodeLogger(inlineConfig: AstroInlineConfig): Logger;

12
node_modules/astro/dist/core/config/logging.js generated vendored Normal file
View File

@@ -0,0 +1,12 @@
import { Logger } from "../logger/core.js";
import { nodeLogDestination } from "../logger/node.js";
function createNodeLogger(inlineConfig) {
if (inlineConfig.logger) return inlineConfig.logger;
return new Logger({
dest: nodeLogDestination,
level: inlineConfig.logLevel ?? "info"
});
}
export {
createNodeLogger
};

3
node_modules/astro/dist/core/config/merge.d.ts generated vendored Normal file
View File

@@ -0,0 +1,3 @@
import type { DeepPartial } from '../../type-utils.js';
import type { AstroConfig, AstroInlineConfig } from '../../types/public/index.js';
export declare function mergeConfig<C extends AstroConfig | AstroInlineConfig>(defaults: C, overrides: DeepPartial<C>): C;

53
node_modules/astro/dist/core/config/merge.js generated vendored Normal file
View File

@@ -0,0 +1,53 @@
import { mergeConfig as mergeViteConfig } from "vite";
import { arraify, isObject, isURL } from "../util.js";
function mergeConfigRecursively(defaults, overrides, rootPath) {
const merged = { ...defaults };
for (const key in overrides) {
const value = overrides[key];
if (value == null) {
continue;
}
const existing = merged[key];
if (existing == null) {
merged[key] = value;
continue;
}
if (key === "vite" && rootPath === "") {
merged[key] = mergeViteConfig(existing, value);
continue;
}
if (key === "server" && rootPath === "") {
if (typeof existing === "function" || typeof value === "function") {
merged[key] = (...args) => {
const existingConfig = typeof existing === "function" ? existing(...args) : existing;
const valueConfig = typeof value === "function" ? value(...args) : value;
return mergeConfigRecursively(existingConfig, valueConfig, key);
};
continue;
}
}
if (key === "allowedHosts" && rootPath === "server" && typeof existing === "boolean") {
continue;
}
if (Array.isArray(existing) || Array.isArray(value)) {
merged[key] = [...arraify(existing ?? []), ...arraify(value ?? [])];
continue;
}
if (isURL(existing) && isURL(value)) {
merged[key] = value;
continue;
}
if (isObject(existing) && isObject(value)) {
merged[key] = mergeConfigRecursively(existing, value, rootPath ? `${rootPath}.${key}` : key);
continue;
}
merged[key] = value;
}
return merged;
}
function mergeConfig(defaults, overrides) {
return mergeConfigRecursively(defaults, overrides, "");
}
export {
mergeConfig
};

1394
node_modules/astro/dist/core/config/schemas/base.d.ts generated vendored Normal file

File diff suppressed because it is too large Load Diff

319
node_modules/astro/dist/core/config/schemas/base.js generated vendored Normal file
View File

@@ -0,0 +1,319 @@
import { markdownConfigDefaults, syntaxHighlightDefaults } from "@astrojs/markdown-remark";
import { bundledThemes } from "shiki";
import { z } from "zod";
import { fontFamilySchema } from "../../../assets/fonts/config.js";
import { EnvSchema } from "../../../env/schema.js";
import { allowedDirectivesSchema, cspAlgorithmSchema, cspHashSchema } from "../../csp/config.js";
const ASTRO_CONFIG_DEFAULTS = {
root: ".",
srcDir: "./src",
publicDir: "./public",
outDir: "./dist",
cacheDir: "./node_modules/.astro",
base: "/",
trailingSlash: "ignore",
build: {
format: "directory",
client: "./client/",
server: "./server/",
assets: "_astro",
serverEntry: "entry.mjs",
redirects: true,
inlineStylesheets: "auto",
concurrency: 1
},
image: {
endpoint: { entrypoint: void 0, route: "/_image" },
service: { entrypoint: "astro/assets/services/sharp", config: {} },
responsiveStyles: false
},
devToolbar: {
enabled: true
},
compressHTML: true,
server: {
host: false,
port: 4321,
open: false,
allowedHosts: []
},
integrations: [],
markdown: markdownConfigDefaults,
vite: {},
legacy: {
collections: false
},
redirects: {},
security: {
checkOrigin: true,
allowedDomains: []
},
env: {
schema: {},
validateSecrets: false
},
session: void 0,
experimental: {
clientPrerender: false,
contentIntellisense: false,
headingIdCompat: false,
preserveScriptOrder: false,
liveContentCollections: false,
csp: false,
staticImportMetaEnv: false,
chromeDevtoolsWorkspace: false,
failOnPrerenderConflict: false,
svgo: false
}
};
const highlighterTypesSchema = z.union([z.literal("shiki"), z.literal("prism")]).default(syntaxHighlightDefaults.type);
const AstroConfigSchema = z.object({
root: z.string().optional().default(ASTRO_CONFIG_DEFAULTS.root).transform((val) => new URL(val)),
srcDir: z.string().optional().default(ASTRO_CONFIG_DEFAULTS.srcDir).transform((val) => new URL(val)),
publicDir: z.string().optional().default(ASTRO_CONFIG_DEFAULTS.publicDir).transform((val) => new URL(val)),
outDir: z.string().optional().default(ASTRO_CONFIG_DEFAULTS.outDir).transform((val) => new URL(val)),
cacheDir: z.string().optional().default(ASTRO_CONFIG_DEFAULTS.cacheDir).transform((val) => new URL(val)),
site: z.string().url().optional(),
compressHTML: z.boolean().optional().default(ASTRO_CONFIG_DEFAULTS.compressHTML),
base: z.string().optional().default(ASTRO_CONFIG_DEFAULTS.base),
trailingSlash: z.union([z.literal("always"), z.literal("never"), z.literal("ignore")]).optional().default(ASTRO_CONFIG_DEFAULTS.trailingSlash),
output: z.union([z.literal("static"), z.literal("server"), z.literal("hybrid")]).optional().default("static").refine((val) => val !== "hybrid", {
message: 'The `output: "hybrid"` option has been removed. Use `output: "static"` (the default) instead, which now behaves the same way.'
}),
scopedStyleStrategy: z.union([z.literal("where"), z.literal("class"), z.literal("attribute")]).optional().default("attribute"),
adapter: z.object({ name: z.string(), hooks: z.object({}).passthrough().default({}) }).optional(),
integrations: z.preprocess(
// preprocess
(val) => Array.isArray(val) ? val.flat(Infinity).filter(Boolean) : val,
// validate
z.array(z.object({ name: z.string(), hooks: z.object({}).passthrough().default({}) })).default(ASTRO_CONFIG_DEFAULTS.integrations)
),
build: z.object({
format: z.union([z.literal("file"), z.literal("directory"), z.literal("preserve")]).optional().default(ASTRO_CONFIG_DEFAULTS.build.format),
client: z.string().optional().default(ASTRO_CONFIG_DEFAULTS.build.client).transform((val) => new URL(val)),
server: z.string().optional().default(ASTRO_CONFIG_DEFAULTS.build.server).transform((val) => new URL(val)),
assets: z.string().optional().default(ASTRO_CONFIG_DEFAULTS.build.assets),
assetsPrefix: z.string().optional().or(z.object({ fallback: z.string() }).and(z.record(z.string())).optional()),
serverEntry: z.string().optional().default(ASTRO_CONFIG_DEFAULTS.build.serverEntry),
redirects: z.boolean().optional().default(ASTRO_CONFIG_DEFAULTS.build.redirects),
inlineStylesheets: z.enum(["always", "auto", "never"]).optional().default(ASTRO_CONFIG_DEFAULTS.build.inlineStylesheets),
concurrency: z.number().min(1).optional().default(ASTRO_CONFIG_DEFAULTS.build.concurrency)
}).default({}),
server: z.preprocess(
// preprocess
// NOTE: Uses the "error" command here because this is overwritten by the
// individualized schema parser with the correct command.
(val) => typeof val === "function" ? val({ command: "error" }) : val,
// validate
z.object({
open: z.union([z.string(), z.boolean()]).optional().default(ASTRO_CONFIG_DEFAULTS.server.open),
host: z.union([z.string(), z.boolean()]).optional().default(ASTRO_CONFIG_DEFAULTS.server.host),
port: z.number().optional().default(ASTRO_CONFIG_DEFAULTS.server.port),
headers: z.custom().optional(),
allowedHosts: z.union([z.array(z.string()), z.literal(true)]).optional().default(ASTRO_CONFIG_DEFAULTS.server.allowedHosts)
}).default({})
),
redirects: z.record(
z.string(),
z.union([
z.string(),
z.object({
status: z.union([
z.literal(300),
z.literal(301),
z.literal(302),
z.literal(303),
z.literal(304),
z.literal(307),
z.literal(308)
]),
destination: z.string()
})
])
).default(ASTRO_CONFIG_DEFAULTS.redirects),
prefetch: z.union([
z.boolean(),
z.object({
prefetchAll: z.boolean().optional(),
defaultStrategy: z.enum(["tap", "hover", "viewport", "load"]).optional()
})
]).optional(),
image: z.object({
endpoint: z.object({
route: z.literal("/_image").or(z.string()).default(ASTRO_CONFIG_DEFAULTS.image.endpoint.route),
entrypoint: z.string().optional()
}).default(ASTRO_CONFIG_DEFAULTS.image.endpoint),
service: z.object({
entrypoint: z.union([z.literal("astro/assets/services/sharp"), z.string()]).default(ASTRO_CONFIG_DEFAULTS.image.service.entrypoint),
config: z.record(z.any()).default({})
}).default(ASTRO_CONFIG_DEFAULTS.image.service),
domains: z.array(z.string()).default([]),
remotePatterns: z.array(
z.object({
protocol: z.string().optional(),
hostname: z.string().optional(),
port: z.string().optional(),
pathname: z.string().optional()
})
).default([]),
layout: z.enum(["constrained", "fixed", "full-width", "none"]).optional(),
objectFit: z.string().optional(),
objectPosition: z.string().optional(),
breakpoints: z.array(z.number()).optional(),
responsiveStyles: z.boolean().default(ASTRO_CONFIG_DEFAULTS.image.responsiveStyles)
}).default(ASTRO_CONFIG_DEFAULTS.image),
devToolbar: z.object({
enabled: z.boolean().default(ASTRO_CONFIG_DEFAULTS.devToolbar.enabled),
placement: z.enum(["bottom-left", "bottom-center", "bottom-right"]).optional()
}).default(ASTRO_CONFIG_DEFAULTS.devToolbar),
markdown: z.object({
syntaxHighlight: z.union([
z.object({
type: highlighterTypesSchema,
excludeLangs: z.array(z.string()).optional().default(syntaxHighlightDefaults.excludeLangs)
}).default(syntaxHighlightDefaults),
highlighterTypesSchema,
z.literal(false)
]).default(ASTRO_CONFIG_DEFAULTS.markdown.syntaxHighlight),
shikiConfig: z.object({
langs: z.custom().array().transform((langs) => {
for (const lang of langs) {
if (typeof lang === "object") {
if (lang.id) {
lang.name = lang.id;
}
if (lang.grammar) {
Object.assign(lang, lang.grammar);
}
}
}
return langs;
}).default([]),
langAlias: z.record(z.string(), z.string()).optional().default(ASTRO_CONFIG_DEFAULTS.markdown.shikiConfig.langAlias),
theme: z.enum(Object.keys(bundledThemes)).or(z.custom()).default(ASTRO_CONFIG_DEFAULTS.markdown.shikiConfig.theme),
themes: z.record(
z.enum(Object.keys(bundledThemes)).or(z.custom())
).default(ASTRO_CONFIG_DEFAULTS.markdown.shikiConfig.themes),
defaultColor: z.union([z.literal("light"), z.literal("dark"), z.string(), z.literal(false)]).optional(),
wrap: z.boolean().or(z.null()).default(ASTRO_CONFIG_DEFAULTS.markdown.shikiConfig.wrap),
transformers: z.custom().array().default(ASTRO_CONFIG_DEFAULTS.markdown.shikiConfig.transformers)
}).default({}),
remarkPlugins: z.union([
z.string(),
z.tuple([z.string(), z.any()]),
z.custom((data) => typeof data === "function"),
z.tuple([z.custom((data) => typeof data === "function"), z.any()])
]).array().default(ASTRO_CONFIG_DEFAULTS.markdown.remarkPlugins),
rehypePlugins: z.union([
z.string(),
z.tuple([z.string(), z.any()]),
z.custom((data) => typeof data === "function"),
z.tuple([z.custom((data) => typeof data === "function"), z.any()])
]).array().default(ASTRO_CONFIG_DEFAULTS.markdown.rehypePlugins),
remarkRehype: z.custom((data) => data instanceof Object && !Array.isArray(data)).default(ASTRO_CONFIG_DEFAULTS.markdown.remarkRehype),
gfm: z.boolean().default(ASTRO_CONFIG_DEFAULTS.markdown.gfm),
smartypants: z.boolean().default(ASTRO_CONFIG_DEFAULTS.markdown.smartypants)
}).default({}),
vite: z.custom((data) => data instanceof Object && !Array.isArray(data)).default(ASTRO_CONFIG_DEFAULTS.vite),
i18n: z.optional(
z.object({
defaultLocale: z.string(),
locales: z.array(
z.union([
z.string(),
z.object({
path: z.string(),
codes: z.string().array().nonempty()
})
])
),
domains: z.record(
z.string(),
z.string().url(
"The domain value must be a valid URL, and it has to start with 'https' or 'http'."
)
).optional(),
fallback: z.record(z.string(), z.string()).optional(),
routing: z.literal("manual").or(
z.object({
prefixDefaultLocale: z.boolean().optional().default(false),
// TODO: Astro 6.0 change to false
redirectToDefaultLocale: z.boolean().optional().default(true),
fallbackType: z.enum(["redirect", "rewrite"]).optional().default("redirect")
})
).optional().default({})
}).optional()
),
security: z.object({
checkOrigin: z.boolean().default(ASTRO_CONFIG_DEFAULTS.security.checkOrigin),
allowedDomains: z.array(
z.object({
hostname: z.string().optional(),
protocol: z.string().optional(),
port: z.string().optional()
})
).optional().default(ASTRO_CONFIG_DEFAULTS.security.allowedDomains)
}).optional().default(ASTRO_CONFIG_DEFAULTS.security),
env: z.object({
schema: EnvSchema.optional().default(ASTRO_CONFIG_DEFAULTS.env.schema),
validateSecrets: z.boolean().optional().default(ASTRO_CONFIG_DEFAULTS.env.validateSecrets)
}).strict().optional().default(ASTRO_CONFIG_DEFAULTS.env),
session: z.object({
driver: z.string().optional(),
options: z.record(z.any()).optional(),
cookie: z.object({
name: z.string().optional(),
domain: z.string().optional(),
path: z.string().optional(),
maxAge: z.number().optional(),
sameSite: z.union([z.enum(["strict", "lax", "none"]), z.boolean()]).optional(),
secure: z.boolean().optional(),
partitioned: z.boolean().optional()
}).or(z.string()).transform((val) => {
if (typeof val === "string") {
return { name: val };
}
return val;
}).optional(),
ttl: z.number().optional()
}).optional(),
experimental: z.object({
clientPrerender: z.boolean().optional().default(ASTRO_CONFIG_DEFAULTS.experimental.clientPrerender),
contentIntellisense: z.boolean().optional().default(ASTRO_CONFIG_DEFAULTS.experimental.contentIntellisense),
headingIdCompat: z.boolean().optional().default(ASTRO_CONFIG_DEFAULTS.experimental.headingIdCompat),
preserveScriptOrder: z.boolean().optional().default(ASTRO_CONFIG_DEFAULTS.experimental.preserveScriptOrder),
fonts: z.array(fontFamilySchema).optional(),
liveContentCollections: z.boolean().optional().default(ASTRO_CONFIG_DEFAULTS.experimental.liveContentCollections),
csp: z.union([
z.boolean().optional().default(ASTRO_CONFIG_DEFAULTS.experimental.csp),
z.object({
algorithm: cspAlgorithmSchema,
directives: z.array(allowedDirectivesSchema).optional(),
styleDirective: z.object({
resources: z.array(z.string()).optional(),
hashes: z.array(cspHashSchema).optional()
}).optional(),
scriptDirective: z.object({
resources: z.array(z.string()).optional(),
hashes: z.array(cspHashSchema).optional(),
strictDynamic: z.boolean().optional()
}).optional()
})
]).optional().default(ASTRO_CONFIG_DEFAULTS.experimental.csp),
staticImportMetaEnv: z.boolean().optional().default(ASTRO_CONFIG_DEFAULTS.experimental.staticImportMetaEnv),
chromeDevtoolsWorkspace: z.boolean().optional().default(ASTRO_CONFIG_DEFAULTS.experimental.chromeDevtoolsWorkspace),
failOnPrerenderConflict: z.boolean().optional().default(ASTRO_CONFIG_DEFAULTS.experimental.failOnPrerenderConflict),
svgo: z.union([z.boolean(), z.custom((value) => value && typeof value === "object")]).optional().default(ASTRO_CONFIG_DEFAULTS.experimental.svgo)
}).strict(
`Invalid or outdated experimental feature.
Check for incorrect spelling or outdated Astro version.
See https://docs.astro.build/en/reference/experimental-flags/ for a list of all current experiments.`
).default({}),
legacy: z.object({
collections: z.boolean().optional().default(ASTRO_CONFIG_DEFAULTS.legacy.collections)
}).default({})
});
export {
ASTRO_CONFIG_DEFAULTS,
AstroConfigSchema
};

View File

@@ -0,0 +1,3 @@
export { ASTRO_CONFIG_DEFAULTS, AstroConfigSchema, type AstroConfigType, } from './base.js';
export { AstroConfigRefinedSchema } from './refined.js';
export { createRelativeSchema } from './relative.js';

12
node_modules/astro/dist/core/config/schemas/index.js generated vendored Normal file
View File

@@ -0,0 +1,12 @@
import {
ASTRO_CONFIG_DEFAULTS,
AstroConfigSchema
} from "./base.js";
import { AstroConfigRefinedSchema } from "./refined.js";
import { createRelativeSchema } from "./relative.js";
export {
ASTRO_CONFIG_DEFAULTS,
AstroConfigRefinedSchema,
AstroConfigSchema,
createRelativeSchema
};

View File

@@ -0,0 +1,3 @@
import { z } from 'zod';
import type { AstroConfig } from '../../../types/public/config.js';
export declare const AstroConfigRefinedSchema: z.ZodEffects<z.ZodType<AstroConfig, z.ZodTypeDef, AstroConfig>, AstroConfig, AstroConfig>;

146
node_modules/astro/dist/core/config/schemas/refined.js generated vendored Normal file
View File

@@ -0,0 +1,146 @@
import { z } from "zod";
const AstroConfigRefinedSchema = z.custom().superRefine((config, ctx) => {
if (config.build.assetsPrefix && typeof config.build.assetsPrefix !== "string" && !config.build.assetsPrefix.fallback) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
message: "The `fallback` is mandatory when defining the option as an object.",
path: ["build", "assetsPrefix"]
});
}
for (let i = 0; i < config.image.remotePatterns.length; i++) {
const { hostname, pathname } = config.image.remotePatterns[i];
if (hostname && hostname.includes("*") && !(hostname.startsWith("*.") || hostname.startsWith("**."))) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
message: "wildcards can only be placed at the beginning of the hostname",
path: ["image", "remotePatterns", i, "hostname"]
});
}
if (pathname && pathname.includes("*") && !(pathname.endsWith("/*") || pathname.endsWith("/**"))) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
message: "wildcards can only be placed at the end of a pathname",
path: ["image", "remotePatterns", i, "pathname"]
});
}
}
if (config.outDir.toString().startsWith(config.publicDir.toString())) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
message: "The value of `outDir` must not point to a path within the folder set as `publicDir`, this will cause an infinite loop",
path: ["outDir"]
});
}
if (config.i18n) {
const { defaultLocale, locales: _locales, fallback, domains } = config.i18n;
const locales = _locales.map((locale) => {
if (typeof locale === "string") {
return locale;
} else {
return locale.path;
}
});
if (!locales.includes(defaultLocale)) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
message: `The default locale \`${defaultLocale}\` is not present in the \`i18n.locales\` array.`,
path: ["i18n", "locales"]
});
}
if (fallback) {
for (const [fallbackFrom, fallbackTo] of Object.entries(fallback)) {
if (!locales.includes(fallbackFrom)) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
message: `The locale \`${fallbackFrom}\` key in the \`i18n.fallback\` record doesn't exist in the \`i18n.locales\` array.`,
path: ["i18n", "fallbacks"]
});
}
if (fallbackFrom === defaultLocale) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
message: `You can't use the default locale as a key. The default locale can only be used as value.`,
path: ["i18n", "fallbacks"]
});
}
if (!locales.includes(fallbackTo)) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
message: `The locale \`${fallbackTo}\` value in the \`i18n.fallback\` record doesn't exist in the \`i18n.locales\` array.`,
path: ["i18n", "fallbacks"]
});
}
}
}
if (domains) {
const entries = Object.entries(domains);
const hasDomains = domains ? Object.keys(domains).length > 0 : false;
if (entries.length > 0 && !hasDomains) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
message: `When specifying some domains, the property \`i18n.routing.strategy\` must be set to \`"domains"\`.`,
path: ["i18n", "routing", "strategy"]
});
}
if (hasDomains) {
if (!config.site) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
message: "The option `site` isn't set. When using the 'domains' strategy for `i18n`, `site` is required to create absolute URLs for locales that aren't mapped to a domain.",
path: ["site"]
});
}
if (config.output !== "server") {
ctx.addIssue({
code: z.ZodIssueCode.custom,
message: 'Domain support is only available when `output` is `"server"`.',
path: ["output"]
});
}
}
for (const [domainKey, domainValue] of entries) {
if (!locales.includes(domainKey)) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
message: `The locale \`${domainKey}\` key in the \`i18n.domains\` record doesn't exist in the \`i18n.locales\` array.`,
path: ["i18n", "domains"]
});
}
if (!domainValue.startsWith("https") && !domainValue.startsWith("http")) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
message: "The domain value must be a valid URL, and it has to start with 'https' or 'http'.",
path: ["i18n", "domains"]
});
} else {
try {
const domainUrl = new URL(domainValue);
if (domainUrl.pathname !== "/") {
ctx.addIssue({
code: z.ZodIssueCode.custom,
message: `The URL \`${domainValue}\` must contain only the origin. A subsequent pathname isn't allowed here. Remove \`${domainUrl.pathname}\`.`,
path: ["i18n", "domains"]
});
}
} catch {
}
}
}
}
}
if (config.experimental.fonts && config.experimental.fonts.length > 0) {
for (let i = 0; i < config.experimental.fonts.length; i++) {
const { cssVariable } = config.experimental.fonts[i];
if (!cssVariable.startsWith("--") || cssVariable.includes(" ") || cssVariable.includes(":")) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
message: `**cssVariable** property "${cssVariable}" contains invalid characters for CSS variable generation. It must start with -- and be a valid indent: https://developer.mozilla.org/en-US/docs/Web/CSS/ident.`,
path: ["fonts", i, "cssVariable"]
});
}
}
}
});
export {
AstroConfigRefinedSchema
};

1745
node_modules/astro/dist/core/config/schemas/relative.d.ts generated vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,92 @@
import path from "node:path";
import { fileURLToPath, pathToFileURL } from "node:url";
import { z } from "zod";
import { appendForwardSlash, prependForwardSlash, removeTrailingForwardSlash } from "../../path.js";
import { ASTRO_CONFIG_DEFAULTS, AstroConfigSchema } from "./base.js";
function resolveDirAsUrl(dir, root) {
let resolvedDir = path.resolve(root, dir);
if (!resolvedDir.endsWith(path.sep)) {
resolvedDir += path.sep;
}
return pathToFileURL(resolvedDir);
}
function createRelativeSchema(cmd, fileProtocolRoot) {
let originalBuildClient;
let originalBuildServer;
const AstroConfigRelativeSchema = AstroConfigSchema.extend({
root: z.string().default(ASTRO_CONFIG_DEFAULTS.root).transform((val) => resolveDirAsUrl(val, fileProtocolRoot)),
srcDir: z.string().default(ASTRO_CONFIG_DEFAULTS.srcDir).transform((val) => resolveDirAsUrl(val, fileProtocolRoot)),
compressHTML: z.boolean().optional().default(ASTRO_CONFIG_DEFAULTS.compressHTML),
publicDir: z.string().default(ASTRO_CONFIG_DEFAULTS.publicDir).transform((val) => resolveDirAsUrl(val, fileProtocolRoot)),
outDir: z.string().default(ASTRO_CONFIG_DEFAULTS.outDir).transform((val) => resolveDirAsUrl(val, fileProtocolRoot)),
cacheDir: z.string().default(ASTRO_CONFIG_DEFAULTS.cacheDir).transform((val) => resolveDirAsUrl(val, fileProtocolRoot)),
build: z.object({
format: z.union([z.literal("file"), z.literal("directory"), z.literal("preserve")]).optional().default(ASTRO_CONFIG_DEFAULTS.build.format),
// NOTE: `client` and `server` are transformed relative to the default outDir first,
// later we'll fix this to be relative to the actual `outDir`
client: z.string().optional().default(ASTRO_CONFIG_DEFAULTS.build.client).transform((val) => {
originalBuildClient = val;
return resolveDirAsUrl(
val,
path.resolve(fileProtocolRoot, ASTRO_CONFIG_DEFAULTS.outDir)
);
}),
server: z.string().optional().default(ASTRO_CONFIG_DEFAULTS.build.server).transform((val) => {
originalBuildServer = val;
return resolveDirAsUrl(
val,
path.resolve(fileProtocolRoot, ASTRO_CONFIG_DEFAULTS.outDir)
);
}),
assets: z.string().optional().default(ASTRO_CONFIG_DEFAULTS.build.assets),
assetsPrefix: z.string().optional().or(z.object({ fallback: z.string() }).and(z.record(z.string())).optional()),
serverEntry: z.string().optional().default(ASTRO_CONFIG_DEFAULTS.build.serverEntry),
redirects: z.boolean().optional().default(ASTRO_CONFIG_DEFAULTS.build.redirects),
inlineStylesheets: z.enum(["always", "auto", "never"]).optional().default(ASTRO_CONFIG_DEFAULTS.build.inlineStylesheets),
concurrency: z.number().min(1).optional().default(ASTRO_CONFIG_DEFAULTS.build.concurrency)
}).optional().default({}),
server: z.preprocess(
// preprocess
(val) => {
if (typeof val === "function") {
return val({ command: cmd === "dev" ? "dev" : "preview" });
}
return val;
},
// validate
z.object({
open: z.union([z.string(), z.boolean()]).optional().default(ASTRO_CONFIG_DEFAULTS.server.open),
host: z.union([z.string(), z.boolean()]).optional().default(ASTRO_CONFIG_DEFAULTS.server.host),
port: z.number().optional().default(ASTRO_CONFIG_DEFAULTS.server.port),
headers: z.custom().optional(),
streaming: z.boolean().optional().default(true),
allowedHosts: z.union([z.array(z.string()), z.literal(true)]).optional().default(ASTRO_CONFIG_DEFAULTS.server.allowedHosts)
}).optional().default({})
)
}).transform((config) => {
if (config.outDir.toString() !== resolveDirAsUrl(ASTRO_CONFIG_DEFAULTS.outDir, fileProtocolRoot).toString()) {
const outDirPath = fileURLToPath(config.outDir);
config.build.client = resolveDirAsUrl(originalBuildClient, outDirPath);
config.build.server = resolveDirAsUrl(originalBuildServer, outDirPath);
}
if (config.trailingSlash === "never") {
config.base = prependForwardSlash(removeTrailingForwardSlash(config.base));
config.image.endpoint.route = prependForwardSlash(
removeTrailingForwardSlash(config.image.endpoint.route)
);
} else if (config.trailingSlash === "always") {
config.base = prependForwardSlash(appendForwardSlash(config.base));
config.image.endpoint.route = prependForwardSlash(
appendForwardSlash(config.image.endpoint.route)
);
} else {
config.base = prependForwardSlash(config.base);
config.image.endpoint.route = prependForwardSlash(config.image.endpoint.route);
}
return config;
});
return AstroConfigRelativeSchema;
}
export {
createRelativeSchema
};

4
node_modules/astro/dist/core/config/settings.d.ts generated vendored Normal file
View File

@@ -0,0 +1,4 @@
import type { AstroSettings } from '../../types/astro.js';
import type { AstroConfig } from '../../types/public/config.js';
export declare function createBaseSettings(config: AstroConfig): AstroSettings;
export declare function createSettings(config: AstroConfig, cwd?: string): Promise<AstroSettings>;

160
node_modules/astro/dist/core/config/settings.js generated vendored Normal file
View File

@@ -0,0 +1,160 @@
import path from "node:path";
import { fileURLToPath, pathToFileURL } from "node:url";
import yaml from "js-yaml";
import toml from "smol-toml";
import { getContentPaths } from "../../content/index.js";
import createPreferences from "../../preferences/index.js";
import { markdownContentEntryType } from "../../vite-plugin-markdown/content-entry-type.js";
import { getDefaultClientDirectives } from "../client-directive/index.js";
import { SUPPORTED_MARKDOWN_FILE_EXTENSIONS } from "./../constants.js";
import { AstroError, AstroErrorData } from "../errors/index.js";
import {
formatTOMLError,
formatYAMLException,
isTOMLError,
isYAMLException
} from "../errors/utils.js";
import { AstroTimer } from "./timer.js";
import { loadTSConfig } from "./tsconfig.js";
function createBaseSettings(config) {
const { contentDir } = getContentPaths(config);
const dotAstroDir = new URL(".astro/", config.root);
const preferences = createPreferences(config, dotAstroDir);
return {
config,
preferences,
tsConfig: void 0,
tsConfigPath: void 0,
adapter: void 0,
injectedRoutes: [],
resolvedInjectedRoutes: [],
serverIslandMap: /* @__PURE__ */ new Map(),
serverIslandNameMap: /* @__PURE__ */ new Map(),
pageExtensions: [".astro", ".html", ...SUPPORTED_MARKDOWN_FILE_EXTENSIONS],
contentEntryTypes: [markdownContentEntryType],
dataEntryTypes: [
{
extensions: [".json"],
getEntryInfo({ contents, fileUrl }) {
if (contents === void 0 || contents === "") return { data: {} };
const pathRelToContentDir = path.relative(
fileURLToPath(contentDir),
fileURLToPath(fileUrl)
);
let data;
try {
data = JSON.parse(contents);
} catch (e) {
throw new AstroError({
...AstroErrorData.DataCollectionEntryParseError,
message: AstroErrorData.DataCollectionEntryParseError.message(
pathRelToContentDir,
e instanceof Error ? e.message : "contains invalid JSON."
),
location: { file: fileUrl.pathname },
stack: e instanceof Error ? e.stack : void 0
});
}
if (data == null || typeof data !== "object") {
throw new AstroError({
...AstroErrorData.DataCollectionEntryParseError,
message: AstroErrorData.DataCollectionEntryParseError.message(
pathRelToContentDir,
"data is not an object."
),
location: { file: fileUrl.pathname }
});
}
return { data };
}
},
{
extensions: [".yaml", ".yml"],
getEntryInfo({ contents, fileUrl }) {
try {
const data = yaml.load(contents, { filename: fileURLToPath(fileUrl) });
const rawData = contents;
return { data, rawData };
} catch (e) {
const pathRelToContentDir = path.relative(
fileURLToPath(contentDir),
fileURLToPath(fileUrl)
);
const formattedError = isYAMLException(e) ? formatYAMLException(e) : new Error("contains invalid YAML.");
throw new AstroError({
...AstroErrorData.DataCollectionEntryParseError,
message: AstroErrorData.DataCollectionEntryParseError.message(
pathRelToContentDir,
formattedError.message
),
stack: formattedError.stack,
location: "loc" in formattedError ? { file: fileUrl.pathname, ...formattedError.loc } : { file: fileUrl.pathname }
});
}
}
},
{
extensions: [".toml"],
getEntryInfo({ contents, fileUrl }) {
try {
const data = toml.parse(contents);
const rawData = contents;
return { data, rawData };
} catch (e) {
const pathRelToContentDir = path.relative(
fileURLToPath(contentDir),
fileURLToPath(fileUrl)
);
const formattedError = isTOMLError(e) ? formatTOMLError(e) : new Error("contains invalid TOML.");
throw new AstroError({
...AstroErrorData.DataCollectionEntryParseError,
message: AstroErrorData.DataCollectionEntryParseError.message(
pathRelToContentDir,
formattedError.message
),
stack: formattedError.stack,
location: "loc" in formattedError ? { file: fileUrl.pathname, ...formattedError.loc } : { file: fileUrl.pathname }
});
}
}
}
],
renderers: [],
scripts: [],
clientDirectives: getDefaultClientDirectives(),
middlewares: { pre: [], post: [] },
watchFiles: [],
devToolbarApps: [],
timer: new AstroTimer(),
dotAstroDir,
latestAstroVersion: void 0,
// Will be set later if applicable when the dev server starts
injectedTypes: [],
buildOutput: void 0,
injectedCsp: {
fontResources: /* @__PURE__ */ new Set(),
styleHashes: []
}
};
}
async function createSettings(config, cwd) {
const tsconfig = await loadTSConfig(cwd);
const settings = createBaseSettings(config);
let watchFiles = [];
if (cwd) {
watchFiles.push(fileURLToPath(new URL("./package.json", pathToFileURL(cwd))));
}
if (typeof tsconfig !== "string") {
watchFiles.push(
...[tsconfig.tsconfigFile, ...(tsconfig.extended ?? []).map((e) => e.tsconfigFile)]
);
settings.tsConfig = tsconfig.tsconfig;
settings.tsConfigPath = tsconfig.tsconfigFile;
}
settings.watchFiles = watchFiles;
return settings;
}
export {
createBaseSettings,
createSettings
};

22
node_modules/astro/dist/core/config/timer.d.ts generated vendored Normal file
View File

@@ -0,0 +1,22 @@
/**
* Timer to track certain operations' performance. Used by Astro's scripts only.
* Set `process.env.ASTRO_TIMER_PATH` truthy to enable.
*/
export declare class AstroTimer {
private enabled;
private ongoingTimers;
private stats;
constructor();
/**
* Start a timer for a scope with a given name.
*/
start(name: string): void;
/**
* End a timer for a scope with a given name.
*/
end(name: string): void;
/**
* Write stats to `process.env.ASTRO_TIMER_PATH`
*/
writeStats(): void;
}

46
node_modules/astro/dist/core/config/timer.js generated vendored Normal file
View File

@@ -0,0 +1,46 @@
import fs from "node:fs";
class AstroTimer {
enabled;
ongoingTimers = /* @__PURE__ */ new Map();
stats = {};
constructor() {
this.enabled = !!process.env.ASTRO_TIMER_PATH;
}
/**
* Start a timer for a scope with a given name.
*/
start(name) {
if (!this.enabled) return;
globalThis.gc?.();
this.ongoingTimers.set(name, {
startTime: performance.now(),
startHeap: process.memoryUsage().heapUsed
});
}
/**
* End a timer for a scope with a given name.
*/
end(name) {
if (!this.enabled) return;
const stat = this.ongoingTimers.get(name);
if (!stat) return;
globalThis.gc?.();
const endHeap = process.memoryUsage().heapUsed;
this.stats[name] = {
elapsedTime: performance.now() - stat.startTime,
heapUsedChange: endHeap - stat.startHeap,
heapUsedTotal: endHeap
};
this.ongoingTimers.delete(name);
}
/**
* Write stats to `process.env.ASTRO_TIMER_PATH`
*/
writeStats() {
if (!this.enabled) return;
fs.writeFileSync(process.env.ASTRO_TIMER_PATH, JSON.stringify(this.stats, null, 2));
}
}
export {
AstroTimer
};

28
node_modules/astro/dist/core/config/tsconfig.d.ts generated vendored Normal file
View File

@@ -0,0 +1,28 @@
import { type TSConfckParseResult } from 'tsconfck';
import type { CompilerOptions, TypeAcquisition } from 'typescript';
export declare const defaultTSConfig: TSConfig;
export type frameworkWithTSSettings = 'vue' | 'react' | 'preact' | 'solid-js';
export declare const presets: Map<frameworkWithTSSettings, TSConfig>;
type TSConfigResult<T = object> = Promise<(TSConfckParseResult & T) | 'invalid-config' | 'missing-config' | 'unknown-error'>;
/**
* Load a tsconfig.json or jsconfig.json is the former is not found
* @param root The root directory to search in, defaults to `process.cwd()`.
* @param findUp Whether to search for the config file in parent directories, by default only the root directory is searched.
*/
export declare function loadTSConfig(root: string | undefined, findUp?: boolean): Promise<TSConfigResult<{
rawConfig: TSConfig;
}>>;
export declare function updateTSConfigForFramework(target: TSConfig, framework: frameworkWithTSSettings): TSConfig;
type StripEnums<T extends Record<string, any>> = {
[K in keyof T]: T[K] extends boolean ? T[K] : T[K] extends string ? T[K] : T[K] extends object ? T[K] : T[K] extends Array<any> ? T[K] : T[K] extends undefined ? undefined : any;
};
export interface TSConfig {
compilerOptions?: StripEnums<CompilerOptions>;
compileOnSave?: boolean;
extends?: string;
files?: string[];
include?: string[];
exclude?: string[];
typeAcquisition?: TypeAcquisition;
}
export {};

123
node_modules/astro/dist/core/config/tsconfig.js generated vendored Normal file
View File

@@ -0,0 +1,123 @@
import { readFile } from "node:fs/promises";
import { join } from "node:path";
import {
find,
parse,
TSConfckParseError,
toJson
} from "tsconfck";
const defaultTSConfig = { extends: "astro/tsconfigs/base" };
const presets = /* @__PURE__ */ new Map([
[
"vue",
// Settings needed for template intellisense when using Volar
{
compilerOptions: {
jsx: "preserve"
}
}
],
[
"react",
// Default TypeScript settings, but we need to redefine them in case the users changed them previously
{
compilerOptions: {
jsx: "react-jsx",
jsxImportSource: "react"
}
}
],
[
"preact",
// https://preactjs.com/guide/v10/typescript/#typescript-configuration
{
compilerOptions: {
jsx: "react-jsx",
jsxImportSource: "preact"
}
}
],
[
"solid-js",
// https://www.solidjs.com/guides/typescript#configuring-typescript
{
compilerOptions: {
jsx: "preserve",
jsxImportSource: "solid-js"
}
}
]
]);
async function loadTSConfig(root, findUp = false) {
const safeCwd = root ?? process.cwd();
const [jsconfig, tsconfig] = await Promise.all(
["jsconfig.json", "tsconfig.json"].map(
(configName) => (
// `tsconfck` expects its first argument to be a file path, not a directory path, so we'll fake one
find(join(safeCwd, "./dummy.txt"), {
root: findUp ? void 0 : root,
configName
})
)
)
);
if (tsconfig) {
const parsedConfig = await safeParse(tsconfig, { root });
if (typeof parsedConfig === "string") {
return parsedConfig;
}
const rawConfig = await readFile(tsconfig, "utf-8").then(toJson).then((content) => JSON.parse(content));
return { ...parsedConfig, rawConfig };
}
if (jsconfig) {
const parsedConfig = await safeParse(jsconfig, { root });
if (typeof parsedConfig === "string") {
return parsedConfig;
}
const rawConfig = await readFile(jsconfig, "utf-8").then(toJson).then((content) => JSON.parse(content));
return { ...parsedConfig, rawConfig };
}
return "missing-config";
}
async function safeParse(tsconfigPath, options = {}) {
try {
const parseResult = await parse(tsconfigPath, options);
if (parseResult.tsconfig == null) {
return "missing-config";
}
return parseResult;
} catch (e) {
if (e instanceof TSConfckParseError) {
return "invalid-config";
}
return "unknown-error";
}
}
function updateTSConfigForFramework(target, framework) {
if (!presets.has(framework)) {
return target;
}
return deepMergeObjects(target, presets.get(framework));
}
function deepMergeObjects(a, b) {
const merged = { ...a };
for (const key in b) {
const value = b[key];
if (a[key] == null) {
merged[key] = value;
continue;
}
if (typeof a[key] === "object" && typeof value === "object") {
merged[key] = deepMergeObjects(a[key], value);
continue;
}
merged[key] = value;
}
return merged;
}
export {
defaultTSConfig,
loadTSConfig,
presets,
updateTSConfigForFramework
};

9
node_modules/astro/dist/core/config/validate.d.ts generated vendored Normal file
View File

@@ -0,0 +1,9 @@
import type { AstroConfig } from '../../types/public/config.js';
/** Turn raw config values into normalized values */
export declare function validateConfig(userConfig: any, root: string, cmd: string): Promise<AstroConfig>;
/**
* Used twice:
* - To validate the user config
* - To validate the config after all integrations (that may have updated it)
*/
export declare function validateConfigRefined(updatedConfig: AstroConfig): Promise<AstroConfig>;

15
node_modules/astro/dist/core/config/validate.js generated vendored Normal file
View File

@@ -0,0 +1,15 @@
import { errorMap } from "../errors/index.js";
import { AstroConfigRefinedSchema, createRelativeSchema } from "./schemas/index.js";
async function validateConfig(userConfig, root, cmd) {
const AstroConfigRelativeSchema = createRelativeSchema(cmd, root);
return await validateConfigRefined(
await AstroConfigRelativeSchema.parseAsync(userConfig, { errorMap })
);
}
async function validateConfigRefined(updatedConfig) {
return await AstroConfigRefinedSchema.parseAsync(updatedConfig, { errorMap });
}
export {
validateConfig,
validateConfigRefined
};

8
node_modules/astro/dist/core/config/vite-load.d.ts generated vendored Normal file
View File

@@ -0,0 +1,8 @@
import type fsType from 'node:fs';
interface LoadConfigWithViteOptions {
root: string;
configPath: string;
fs: typeof fsType;
}
export declare function loadConfigWithVite({ configPath, fs, root, }: LoadConfigWithViteOptions): Promise<Record<string, any>>;
export {};

46
node_modules/astro/dist/core/config/vite-load.js generated vendored Normal file
View File

@@ -0,0 +1,46 @@
import { pathToFileURL } from "node:url";
import { createServer } from "vite";
import loadFallbackPlugin from "../../vite-plugin-load-fallback/index.js";
import { debug } from "../logger/core.js";
async function createViteServer(root, fs) {
const viteServer = await createServer({
configFile: false,
server: { middlewareMode: true, hmr: false, watch: null, ws: false },
optimizeDeps: { noDiscovery: true },
clearScreen: false,
appType: "custom",
ssr: { external: true },
plugins: [loadFallbackPlugin({ fs, root: pathToFileURL(root) })]
});
return viteServer;
}
async function loadConfigWithVite({
configPath,
fs,
root
}) {
if (/\.[cm]?js$/.test(configPath)) {
try {
const config = await import(pathToFileURL(configPath).toString() + "?t=" + Date.now());
return config.default ?? {};
} catch (e) {
if (e && typeof e === "object" && "code" in e && e.code === "ERR_DLOPEN_DISABLED") {
throw e;
}
debug("Failed to load config with Node", e);
}
}
let server;
try {
server = await createViteServer(root, fs);
const mod = await server.ssrLoadModule(configPath, { fixStacktrace: true });
return mod.default ?? {};
} finally {
if (server) {
await server.close();
}
}
}
export {
loadConfigWithVite
};