@gluonjs/compiler / packages/compiler/src / GluonCompilerDiagnostic
Interface: GluonCompilerDiagnostic
Properties
code
readonlycode:"GLUON_TEMPLATE_STYLE_ELEMENT"|"GLUON_ELEMENT_TAG_INVALID"|"GLUON_ELEMENT_SETUP_CLEANUP_MISSING"|"GLUON_ELEMENT_SETUP_LIFECYCLE_DEFERRED"
location
readonlylocation:SourceLocation
message
readonlymessage:string
Example
Report a compiler-owned template violation with its stable code, human message, and exact source position:
import {
transformGluonModule,
transpileGluonDecorators,
type GluonCompilerDiagnostic,
type GluonDecoratorMode,
type GluonSourceMap,
type GluonTemplateLocation,
type GluonTemplatePart,
type GluonTemplateTag,
type GluonTransformOptions,
type GluonTransformResult,
type GluonTranspileResult,
type SourceLocation,
} from '@gluonjs/compiler';
const source = `
import { html } from '@gluonjs/core';
export const Product = (name: string) => html\`<h1>\${name}</h1>\`;
`;
const options = { development: true } satisfies GluonTransformOptions;
const result: GluonTransformResult = transformGluonModule(source, '/src/product.ts', options);
const map: GluonSourceMap = result.map;
const template: GluonTemplateLocation | undefined = result.templates[0];
const tag: GluonTemplateTag | undefined = template?.tag;
const part: GluonTemplatePart | undefined = template?.parts[0];
const start: SourceLocation | undefined = part?.start;
const diagnostic: GluonCompilerDiagnostic | undefined = result.diagnostics[0];
const mode: GluonDecoratorMode = 'standard';
const transpiled: GluonTranspileResult = transpileGluonDecorators(result.code, '/src/product.ts', mode);
console.log(result.code, transpiled.code, map.sources, tag, start, diagnostic?.message, result.hmr);