diff options
Diffstat (limited to 'src/codegen/index.ts')
-rw-r--r-- | src/codegen/index.ts | 11 |
1 files changed, 2 insertions, 9 deletions
diff --git a/src/codegen/index.ts b/src/codegen/index.ts index 9b3104f0a..662d63858 100644 --- a/src/codegen/index.ts +++ b/src/codegen/index.ts @@ -1,6 +1,6 @@ import type { CompileOptions } from '../@types/compiler'; import type { Ast, TemplateNode } from '../compiler/interfaces'; -import type { JsxItem, TransformResult } from '../@types/astro.js'; +import type { JsxItem, TransformResult } from '../@types/astro'; import eslexer from 'es-module-lexer'; import esbuild from 'esbuild'; @@ -61,7 +61,6 @@ function getAttributes(attrs: Attribute[]): Record<string, string> { result[attr.name] = JSON.stringify(getTextFromAttribute(val)); continue; default: - console.log(val); throw new Error('UNKNOWN V'); } } @@ -75,7 +74,6 @@ function getTextFromAttribute(attr: any): string { if (attr.data !== undefined) { return attr.data; } - console.log(attr); throw new Error('UNKNOWN attr'); } @@ -169,12 +167,11 @@ function compileScriptSafe(raw: string, loader: 'jsx' | 'tsx'): string { export async function codegen(ast: Ast, { compileOptions }: CodeGenOptions): Promise<TransformResult> { await eslexer.init; - const script = compileScriptSafe(ast.instance ? ast.instance.content : '', 'tsx'); // Compile scripts as TypeScript, always + const script = compileScriptSafe(ast.instance ? ast.instance.content : '', 'tsx'); // Todo: Validate that `h` and `Fragment` aren't defined in the script - const [scriptImports] = eslexer.parse(script, 'optional-sourcename'); const components = Object.fromEntries( scriptImports.map((imp) => { @@ -193,7 +190,6 @@ export async function codegen(ast: Ast, { compileOptions }: CodeGenOptions): Pro walk(ast.html, { enter(node: TemplateNode) { - // console.log("enter", node.type); switch (node.type) { case 'MustacheTag': let code = compileScriptSafe(node.expression, 'jsx'); @@ -238,7 +234,6 @@ export async function codegen(ast: Ast, { compileOptions }: CodeGenOptions): Pro case 'Element': const name: string = node.name; if (!name) { - console.log(node); throw new Error('AHHHH'); } const attributes = getAttributes(node.attributes); @@ -298,12 +293,10 @@ export async function codegen(ast: Ast, { compileOptions }: CodeGenOptions): Pro return; } default: - console.log(node); throw new Error('Unexpected node type: ' + node.type); } }, leave(node, parent, prop, index) { - // console.log("leave", node.type); switch (node.type) { case 'Text': case 'MustacheTag': |