0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2024-12-16 21:46:22 -05:00

Update compile.ts

This commit is contained in:
Amichai Sinai 2024-09-26 10:59:32 +03:00 committed by GitHub
parent 1720c5b1d2
commit 07a1294f52
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -34,6 +34,17 @@ export async function compileAstro({
try {
transformResult = await compile(compileProps);
// Check for client: hydration directives in the compiled JSX structure
const hasHydrationDirective = transformResult.code.includes('client:');
if (hasHydrationDirective) {
// Optionally log a warning or error for devs
logger.warn(
null,
`Hydration directive found in ${compileProps.filename}. Astro components should not use client-side rendering.`
);
}
// Compile all TypeScript to JavaScript.
// Also, catches invalid JS/TS in the compiled output before returning.
esbuildResult = await transformWithEsbuild(transformResult.code, compileProps.filename, {