load-file.ts — astro Source File
Architecture documentation for load-file.ts, a typescript file in the astro codebase. 13 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR c880535e_510d_6ed5_4280_3abb271db261["load-file.ts"] eda9bb18_dc7e_2d22_8ac4_4f2697d51221["./consts.js"] c880535e_510d_6ed5_4280_3abb271db261 --> eda9bb18_dc7e_2d22_8ac4_4f2697d51221 57319c2a_db71_c5b3_0171_5f4c55721d69["./errors.js"] c880535e_510d_6ed5_4280_3abb271db261 --> 57319c2a_db71_c5b3_0171_5f4c55721d69 befc0c6e_040a_fbf0_7cea_2d0ac6cf2570["./integration/error-map.js"] c880535e_510d_6ed5_4280_3abb271db261 --> befc0c6e_040a_fbf0_7cea_2d0ac6cf2570 b81d717b_ec28_afd6_a1fc_5f065ee1b5a2["./integration/vite-plugin-db.js"] c880535e_510d_6ed5_4280_3abb271db261 --> b81d717b_ec28_afd6_a1fc_5f065ee1b5a2 d97d1d38_d12d_091d_d5c6_25c44398932a["./core/schemas.js"] c880535e_510d_6ed5_4280_3abb271db261 --> d97d1d38_d12d_091d_d5c6_25c44398932a 97fa73a6_cf67_73a5_b60d_d52bfb00c7d8["./core/types.js"] c880535e_510d_6ed5_4280_3abb271db261 --> 97fa73a6_cf67_73a5_b60d_d52bfb00c7d8 6ae6435e_1314_7d59_4826_25e9a2ada03f["./utils.js"] c880535e_510d_6ed5_4280_3abb271db261 --> 6ae6435e_1314_7d59_4826_25e9a2ada03f e16a223b_37f3_6b25_1ee1_2b7bcb9d9415["node:fs"] c880535e_510d_6ed5_4280_3abb271db261 --> e16a223b_37f3_6b25_1ee1_2b7bcb9d9415 5d6d1861_a18d_b246_cd94_08889ab7e74c["promises"] c880535e_510d_6ed5_4280_3abb271db261 --> 5d6d1861_a18d_b246_cd94_08889ab7e74c 3955a637_4c78_0528_fe7c_92190a232cb0["node:module"] c880535e_510d_6ed5_4280_3abb271db261 --> 3955a637_4c78_0528_fe7c_92190a232cb0 d9a92db9_c95e_9165_13ac_24b3d859d946["node:url"] c880535e_510d_6ed5_4280_3abb271db261 --> d9a92db9_c95e_9165_13ac_24b3d859d946 f16d8c76_2866_6150_bd14_0347b59abfe9["astro"] c880535e_510d_6ed5_4280_3abb271db261 --> f16d8c76_2866_6150_bd14_0347b59abfe9 972c6fe0_4a8d_d55e_c1b0_a57c5bf4ed60["esbuild"] c880535e_510d_6ed5_4280_3abb271db261 --> 972c6fe0_4a8d_d55e_c1b0_a57c5bf4ed60 style c880535e_510d_6ed5_4280_3abb271db261 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import { existsSync } from 'node:fs';
import { unlink, writeFile } from 'node:fs/promises';
import { createRequire } from 'node:module';
import { fileURLToPath, pathToFileURL } from 'node:url';
import type { AstroConfig } from 'astro';
import { build as esbuild } from 'esbuild';
import { CONFIG_FILE_NAMES, VIRTUAL_MODULE_ID } from './consts.js';
import { INTEGRATION_TABLE_CONFLICT_ERROR } from './errors.js';
import { errorMap } from './integration/error-map.js';
import { getConfigVirtualModContents } from './integration/vite-plugin-db.js';
import { dbConfigSchema } from './schemas.js';
import './types.js';
import { getAstroEnv, getDbDirectoryUrl } from './utils.js';
/**
* Load a user’s `astro:db` configuration file and additional configuration files provided by integrations.
*/
export async function resolveDbConfig({
root,
integrations,
}: Pick<AstroConfig, 'root' | 'integrations'>) {
const { mod, dependencies } = await loadUserConfigFile(root);
const userDbConfig = dbConfigSchema.parse(mod?.default ?? {}, { error: errorMap });
/** Resolved `astro:db` config including tables provided by integrations. */
const dbConfig = { tables: userDbConfig.tables ?? {} };
// Collect additional config and seed files from integrations.
const integrationDbConfigPaths: Array<{ name: string; configEntrypoint: string | URL }> = [];
const integrationSeedPaths: Array<string | URL> = [];
for (const integration of integrations) {
const { name, hooks } = integration;
if (hooks['astro:db:setup']) {
hooks['astro:db:setup']({
extendDb({ configEntrypoint, seedEntrypoint }) {
if (configEntrypoint) {
integrationDbConfigPaths.push({ name, configEntrypoint });
}
if (seedEntrypoint) {
integrationSeedPaths.push(seedEntrypoint);
}
},
});
}
}
for (const { name, configEntrypoint } of integrationDbConfigPaths) {
// TODO: config file dependencies are not tracked for integrations for now.
const loadedConfig = await loadIntegrationConfigFile(root, configEntrypoint);
const integrationDbConfig = dbConfigSchema.parse(loadedConfig.mod?.default ?? {}, {
error: errorMap,
});
for (const key in integrationDbConfig.tables) {
if (key in dbConfig.tables) {
const isUserConflict = key in (userDbConfig.tables ?? {});
throw new Error(INTEGRATION_TABLE_CONFLICT_ERROR(name, key, isUserConflict));
} else {
dbConfig.tables[key] = integrationDbConfig.tables[key];
}
}
}
// ... (145 more lines)
Domain
Subdomains
Functions
Dependencies
- ./consts.js
- ./core/schemas.js
- ./core/types.js
- ./errors.js
- ./integration/error-map.js
- ./integration/vite-plugin-db.js
- ./utils.js
- astro
- esbuild
- node:fs
- node:module
- node:url
- promises
Source
Frequently Asked Questions
What does load-file.ts do?
load-file.ts is a source file in the astro codebase, written in typescript. It belongs to the CoreAstro domain, RoutingSystem subdomain.
What functions are defined in load-file.ts?
load-file.ts defines 7 function(s): bundleFile, getResolvedFileUrl, importBundledFile, loadAndBundleDbConfigFile, loadIntegrationConfigFile, loadUserConfigFile, resolveDbConfig.
What does load-file.ts depend on?
load-file.ts imports 13 module(s): ./consts.js, ./core/schemas.js, ./core/types.js, ./errors.js, ./integration/error-map.js, ./integration/vite-plugin-db.js, ./utils.js, astro, and 5 more.
Where is load-file.ts in the architecture?
load-file.ts is located at packages/db/src/core/load-file.ts (domain: CoreAstro, subdomain: RoutingSystem, directory: packages/db/src/core).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free