util.ts — astro Source File
Architecture documentation for util.ts, a typescript file in the astro codebase. 2 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 48088c10_7044_a9b5_a274_a1e22ab9752d["util.ts"] c0c8a87f_ca88_4ea8_585b_2040cded1231["./const.js"] 48088c10_7044_a9b5_a274_a1e22ab9752d --> c0c8a87f_ca88_4ea8_585b_2040cded1231 e4df8f29_fb2f_3d70_a962_fdf6a3670b22["path"] 48088c10_7044_a9b5_a274_a1e22ab9752d --> e4df8f29_fb2f_3d70_a962_fdf6a3670b22 style 48088c10_7044_a9b5_a274_a1e22ab9752d fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import { fileExtension } from '@astrojs/internal-helpers/path';
import { VIRTUAL_PAGE_MODULE_ID } from './const.js';
// This is an arbitrary string that we use to replace the dot of the extension.
const ASTRO_PAGE_EXTENSION_POST_PATTERN = '@_@';
/**
* Prevents Rollup from triggering other plugins in the process by masking the extension (hence the virtual file).
* Inverse function of getComponentFromVirtualModulePageName() below.
* @param virtualModulePrefix The prefix used to create the virtual module
* @param path Page component path
*/
export function getVirtualModulePageName(virtualModulePrefix: string, path: string): string {
const extension = fileExtension(path);
return (
virtualModulePrefix +
(extension.startsWith('.')
? path.slice(0, -extension.length) + extension.replace('.', ASTRO_PAGE_EXTENSION_POST_PATTERN)
: path)
);
}
export function getVirtualModulePageNameForComponent(component: string) {
const virtualModuleName = getVirtualModulePageName(VIRTUAL_PAGE_MODULE_ID, component);
return virtualModuleName;
}
Domain
Subdomains
Dependencies
- ./const.js
- path
Source
Frequently Asked Questions
What does util.ts do?
util.ts is a source file in the astro codebase, written in typescript. It belongs to the CoreAstro domain, RenderingEngine subdomain.
What functions are defined in util.ts?
util.ts defines 2 function(s): getVirtualModulePageName, getVirtualModulePageNameForComponent.
What does util.ts depend on?
util.ts imports 2 module(s): ./const.js, path.
Where is util.ts in the architecture?
util.ts is located at packages/astro/src/vite-plugin-pages/util.ts (domain: CoreAstro, subdomain: RenderingEngine, directory: packages/astro/src/vite-plugin-pages).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free