patchTSX() — astro Function Reference
Architecture documentation for the patchTSX() function in astro2tsx.ts from the astro codebase.
Entity Profile
Dependency Diagram
graph TD 910094b7_f418_a70f_7f93_5f8146c51c66["patchTSX()"] b348b824_2985_3524_9b17_fd7579f42c1f["astro2tsx.ts"] 910094b7_f418_a70f_7f93_5f8146c51c66 -->|defined in| b348b824_2985_3524_9b17_fd7579f42c1f 840c0167_4b40_3f42_1c05_3306fbda825b["getVirtualFileTSX()"] 840c0167_4b40_3f42_1c05_3306fbda825b -->|calls| 910094b7_f418_a70f_7f93_5f8146c51c66 style 910094b7_f418_a70f_7f93_5f8146c51c66 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/language-tools/ts-plugin/src/astro2tsx.ts lines 139–151
function patchTSX(code: string, fileName: string) {
const basename = path.basename(fileName, path.extname(fileName));
const isDynamic = basename.startsWith('[') && basename.endsWith(']');
return code.replace(/\b(\S*)__AstroComponent_/g, (fullMatch, m1: string) => {
// If we don't have a match here, it usually means the file has a weird name that couldn't be expressed with valid identifier characters
if (!m1) {
if (basename === '404') return 'FourOhFour';
return fullMatch;
}
return isDynamic ? `_${m1}_` : m1[0].toUpperCase() + m1.slice(1);
});
}
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does patchTSX() do?
patchTSX() is a function in the astro codebase, defined in packages/language-tools/ts-plugin/src/astro2tsx.ts.
Where is patchTSX() defined?
patchTSX() is defined in packages/language-tools/ts-plugin/src/astro2tsx.ts at line 139.
What calls patchTSX()?
patchTSX() is called by 1 function(s): getVirtualFileTSX.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free