Skip to content

Commit

Permalink
Update compile.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
Amichaiz authored Sep 26, 2024
1 parent 1720c5b commit 07a1294
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions packages/astro/src/vite-plugin-astro/compile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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, {
Expand Down

0 comments on commit 07a1294

Please sign in to comment.