get_compiled_code
Retrieve compiled JavaScript and CSS output for Svelte components to debug compilation issues and analyze generated code.
Instructions
Get the compiled JavaScript and CSS output for a Svelte component. Useful for debugging compilation issues.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| filePath | Yes | Absolute path to the .svelte file |
Implementation Reference
- src/tools/svelte.ts:17-28 (registration)Registration of the "get_compiled_code" tool in Svelte tools module.
server.registerTool( "get_compiled_code", { title: "Get Compiled Code", description: "Get the compiled JavaScript and CSS output for a Svelte component. Useful for debugging compilation issues.", inputSchema: z.object({ filePath: z .string() .describe("Absolute path to the .svelte file"), }), }, - src/tools/svelte.ts:29-65 (handler)Handler implementation for "get_compiled_code", which makes an LSP request to '$/getCompiledCode'.
async ({ filePath }): Promise<ToolResult> => { try { const prep = await prepareDocumentRequest(lsp, filePath); if ("error" in prep) return textResult(prep.error); const result = await lsp.request("$/getCompiledCode", prep.uri); if (!result) { return textResult( `No compiled code available for ${basename(filePath)}.` ); } const parts: string[] = []; if (result.js) { parts.push("=== Compiled JavaScript ==="); parts.push(result.js); } if (result.css) { parts.push(""); parts.push("=== Compiled CSS ==="); parts.push(result.css); } if (parts.length === 0) { return textResult( `Compiled code for ${basename(filePath)} is empty.` ); } return textResult(parts.join("\n")); } catch (ex) { return textResult(formatError(ex)); } } - src/tools/svelte.ts:23-27 (schema)Input schema definition for the "get_compiled_code" tool using Zod.
inputSchema: z.object({ filePath: z .string() .describe("Absolute path to the .svelte file"), }),