{"id":26123,"library":"pug-tail","title":"pug-tail","description":"A zero-runtime transpiler that expands custom component DSLs with slot syntax directly on the Pug AST. Version 0.1.0-alpha.6 targets Node >=18, ships TypeScript type definitions, and is in early alpha stage. Unlike runtime slot systems (e.g., Vue slots), pug-tail performs static expansion at build time, producing plain Pug output with no client-side overhead. It offers a Vue-like slot syntax (named, scoped, fallback) but compiles away entirely. The project has irregular release cadence and is not yet stable. Key differentiators: no runtime cost, AST-level transformation, and integration with existing Pug toolchains.","status":"active","version":"0.1.0-alpha.6","language":"javascript","source_language":"en","source_url":"https://github.com/megurock/pug-tail","tags":["javascript","pug","pugjs","template","component","slot","slots","transpiler","ast","typescript"],"install":[{"cmd":"npm install pug-tail","lang":"bash","label":"npm"},{"cmd":"yarn add pug-tail","lang":"bash","label":"yarn"},{"cmd":"pnpm add pug-tail","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Tokenizes Pug source input","package":"pug-lexer","optional":false},{"reason":"Parses tokens into Pug AST","package":"pug-parser","optional":false}],"imports":[{"note":"Default export does not exist; the function is a named export.","wrong":"import extend from 'pug-tail'","symbol":"extend","correct":"import { extend } from 'pug-tail'"},{"note":"No namespace import needed; named import is idiomatic.","wrong":"import * as pugTail from 'pug-tail'; pugTail.compile()","symbol":"compile","correct":"import { compile } from 'pug-tail'"},{"note":"CommonJS requires destructured assignment; default require returns empty object.","wrong":"const extend = require('pug-tail')","symbol":"extend","correct":"const { extend } = require('pug-tail')"}],"quickstart":{"code":"import { extend } from 'pug-tail'\\nimport { lex, parse } from 'pug-lexer'\\nimport { parse as pugParse } from 'pug-parser'\\n\\n// Sample Pug template with custom component 'Button' and slot\\nconst source = `\\nButton\\n  slot(name='label')\\n    | Click me\\n`\\n\\nconst tokens = lex(source)\\nconst ast = pugParse(tokens)\\n\\n// Define component template for 'Button' (plain Pug AST)\\n// In real usage, you'd load from files. For demo, build minimal AST:\\nconst buttonTemplate = {\\n  type: 'Tag',\\n  name: 'button',\\n  attrs: { class: 'btn' },\\n  children: []\\n}\\n\\nconst extendedAst = extend(ast, {\\n  components: {\\n    Button: {\\n      template: buttonTemplate,\\n      slots: { label: true }\\n    }\\n  }\\n})\\n\\nconsole.log(JSON.stringify(extendedAst, null, 2))","lang":"typescript","description":"Expands a custom component with a slot in Pug AST, converting slot content into component children."},"warnings":[{"fix":"Pin exact version and test upgrades thoroughly.","message":"API is not stable; alpha versions may introduce breaking changes without deprecation.","severity":"breaking","affected_versions":">=0.1.0-alpha.0"},{"fix":"const copy = JSON.parse(JSON.stringify(ast)); extend(copy, options);","message":"The `extend` function mutates the input AST. Create a deep copy if the original AST is needed later.","severity":"gotcha","affected_versions":">=0.1.0-alpha.0"},{"fix":"Replace compile(ast, options) with extend(ast, options) then manually serialize.","message":"The `compile` function is deprecated in favor of `extend` and separate post-processing.","severity":"deprecated","affected_versions":">=0.1.0-alpha.5"},{"fix":"Ensure every slot in the component definition has a fallback: false or valid AST.","message":"Slot fallback content must be explicitly marked; missing fallback leads to empty output.","severity":"gotcha","affected_versions":">=0.1.0-alpha.0"},{"fix":"Use Node >=18.","message":"Node.js 16 support was dropped after v0.1.0-alpha.3.","severity":"breaking","affected_versions":">=0.1.0-alpha.4"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Ensure options.components is an object with keys matching component names, each having a template AST node.","cause":"The component definition is missing or malformed in the options object.","error":"TypeError: Cannot read properties of undefined (reading 'type')"},{"fix":"Either add a slot named 'default' to the component definition, or rename the slot reference.","cause":"Slot reference uses name 'default' but the component defines slots without that name.","error":"Error: No slot named 'default' in component X"},{"fix":"Use a custom serializer (e.g., from 'pug-walk') instead of JSON.stringify.","cause":"The extended AST contains circular references or non-serializable nodes.","error":"SyntaxError: Unexpected token (in JSON output)"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}