{"id":25742,"library":"idyll-compiler","title":"Idyll Compiler","description":"Lexer and parser for the Idyll markup language, converting Idyll source into an abstract syntax tree (AST). Current version is 5.0.0-alpha.2, with active development. It allows embedding Idyll documents in web pages when combined with idyll-document. Key differentiators: provides a full AST for custom processing, supports async compilation, and is part of the Idyll ecosystem. It is ESM-only and requires Node.js 12+.","status":"active","version":"5.0.0-alpha.2","language":"javascript","source_language":"en","source_url":"https://github.com/idyll-lang/idyll","tags":["javascript","idyll","compiler"],"install":[{"cmd":"npm install idyll-compiler","lang":"bash","label":"npm"},{"cmd":"yarn add idyll-compiler","lang":"bash","label":"yarn"},{"cmd":"pnpm add idyll-compiler","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"ESM-only; CommonJS require will fail. Use the named export.","wrong":"const compile = require('idyll-compiler')","symbol":"compile","correct":"import { compile } from 'idyll-compiler'"},{"note":"Available if you need to preprocess Idyll source before full compilation.","symbol":"preprocess","correct":"import { preprocess } from 'idyll-compiler'"},{"note":"The module has a default export that is the compile function. Prefer named import for clarity.","wrong":"import { default } from 'idyll-compiler'","symbol":"default export","correct":"import idyllCompiler from 'idyll-compiler'"}],"quickstart":{"code":"import { compile } from 'idyll-compiler';\n\nconst input = `[var name:\"World\"]\\nHello [span]${name}[/span]!`;\n\ncompile(input, { async: false }).then(ast => {\n  console.log(JSON.stringify(ast, null, 2));\n}).catch(err => {\n  console.error(err);\n});","lang":"typescript","description":"Compiles a simple Idyll string with variable and inline element into an AST, then logs it."},"warnings":[{"fix":"Use import syntax and ensure your project supports ESM (\"type\": \"module\" in package.json).","message":"v5 changed from CJS to ESM only.","severity":"breaking","affected_versions":">=5.0.0-alpha"},{"fix":"Use .then/catch or async/await instead of callback.","message":"compile callback style removed in v5; use Promise-based API.","severity":"deprecated","affected_versions":">=5.0.0-alpha"},{"fix":"Set { async: false } to avoid Webpack issues with dynamic imports.","message":"For browser usage, compile runs synchronously if options.async is false.","severity":"gotcha","affected_versions":"*"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Validate your Idyll syntax. Use an Idyll linter or check brackets.","cause":"Idyll syntax error in input string (e.g., mismatched tags).","error":"SyntaxError: Unexpected token"},{"fix":"Use `import { compile } from 'idyll-compiler'`.","cause":"Importing the package incorrectly (CJS vs ESM).","error":"compiler is not a function"},{"fix":"Run `npm install idyll-compiler` and ensure it's in dependencies.","cause":"Package not installed or incorrect version.","error":"Cannot find module 'idyll-compiler'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}