writeAssetImports() — astro Function Reference
Architecture documentation for the writeAssetImports() function in mutable-data-store.ts from the astro codebase.
Entity Profile
Dependency Diagram
graph TD ec29fa5b_8500_e9fa_d0e6_bf5cc1eaaae7["writeAssetImports()"] ecb98618_124a_e276_dd98_561beaedc6ea["MutableDataStore"] ec29fa5b_8500_e9fa_d0e6_bf5cc1eaaae7 -->|defined in| ecb98618_124a_e276_dd98_561beaedc6ea 869c30f5_afd6_31bc_2889_1e8921cb5502["clearTimeout()"] 869c30f5_afd6_31bc_2889_1e8921cb5502 -->|calls| ec29fa5b_8500_e9fa_d0e6_bf5cc1eaaae7 style ec29fa5b_8500_e9fa_d0e6_bf5cc1eaaae7 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/astro/src/content/mutable-data-store.ts lines 89–123
async writeAssetImports(filePath: PathLike) {
this.#assetsFile = filePath;
if (this.#assetImports.size === 0) {
try {
await this.#writeFileAtomic(filePath, 'export default new Map();');
} catch (err) {
throw new AstroError(AstroErrorData.UnknownFilesystemError, { cause: err });
}
}
if (!this.#assetsDirty && existsSync(filePath)) {
return;
}
// Import the assets, with a symbol name that is unique to the import id. The import
// for each asset is an object with path, format and dimensions.
// We then export them all, mapped by the import id, so we can find them again in the build.
const imports: Array<string> = [];
const exports: Array<string> = [];
this.#assetImports.forEach((id) => {
const symbol = importIdToSymbolName(id);
imports.push(`import ${symbol} from ${JSON.stringify(id)};`);
exports.push(`[${JSON.stringify(id)}, ${symbol}]`);
});
const code = /* js */ `
${imports.join('\n')}
export default new Map([${exports.join(', ')}]);
`;
try {
await this.#writeFileAtomic(filePath, code);
} catch (err) {
throw new AstroError(AstroErrorData.UnknownFilesystemError, { cause: err });
}
this.#assetsDirty = false;
}
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does writeAssetImports() do?
writeAssetImports() is a function in the astro codebase, defined in packages/astro/src/content/mutable-data-store.ts.
Where is writeAssetImports() defined?
writeAssetImports() is defined in packages/astro/src/content/mutable-data-store.ts at line 89.
What calls writeAssetImports()?
writeAssetImports() is called by 1 function(s): clearTimeout.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free