{"id":25389,"library":"esbuild-plugin-pug","title":"esbuild-plugin-pug","description":"An esbuild plugin that enables importing .pug and .jade templates directly in JavaScript/TypeScript builds. Current version is 0.0.8, with infrequent releases. Unlike generic loaders, it wraps the full Pug compiler, supporting all Pug features (includes, mixins, interpolation) and returns compiled HTML strings. Use with esbuild for server-side rendering or static site generation without a separate build step.","status":"active","version":"0.0.8","language":"javascript","source_language":"en","source_url":"https://github.com/adamjberg/esbuild-plugin-pug","tags":["javascript","esbuild","jade","pug","esbuild-plugin"],"install":[{"cmd":"npm install esbuild-plugin-pug","lang":"bash","label":"npm"},{"cmd":"yarn add esbuild-plugin-pug","lang":"bash","label":"yarn"},{"cmd":"pnpm add esbuild-plugin-pug","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"The package exports a single function that returns a plugin object. ESM import works in Node.js with esm or bundlers.","symbol":"default (pugPlugin)","correct":"import pugPlugin from 'esbuild-plugin-pug'"},{"note":"CommonJS require works as the package provides a CJS entry.","symbol":"default (pugPlugin)","correct":"const pugPlugin = require('esbuild-plugin-pug')"},{"note":"The plugin function returns an object compatible with esbuild's Plugin interface. No explicit type import from this package is needed.","symbol":"type Plugin","correct":"import type { Plugin } from 'esbuild'"}],"quickstart":{"code":"import esbuild from 'esbuild';\nimport pugPlugin from 'esbuild-plugin-pug';\n\nawait esbuild.build({\n  entryPoints: ['src/index.ts'],\n  bundle: true,\n  platform: 'node',\n  outfile: 'dist/bundle.js',\n  plugins: [\n    pugPlugin()\n  ],\n});\n\n// Example template usage:\n// In src/index.ts:\n// import template from './template.pug';\n// console.log(template()); // renders HTML","lang":"typescript","description":"Registers the pug plugin with esbuild and demonstrates importing a .pug file as a function that returns HTML."},"warnings":[{"fix":"Use a separate watch mechanism or esbuild's built-in watch with onRebuild callback.","message":"The plugin does not support esbuild's watch mode or incremental builds correctly; file changes in .pug files may not trigger rebuilds.","severity":"gotcha","affected_versions":">=0.0.1"},{"fix":"Fork the plugin or precompile templates manually if you need to customize Pug compiler options.","message":"Pug options (pretty, filename, etc.) are not exposed. The plugin hardcodes `pretty: true` which may produce unwanted whitespace.","severity":"gotcha","affected_versions":">=0.0.1"},{"fix":"Precompile async templates separately or use a different plugin that supports esbuild's async plugins.","message":"The plugin returns the compiled template as a function that takes locals object; it does not handle async templates or filters (e.g., markdown).","severity":"gotcha","affected_versions":">=0.0.1"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"npm install --save-dev esbuild-plugin-pug","cause":"Missing dev dependency. Install the package locally.","error":"Error: Cannot find module 'esbuild-plugin-pug'"},{"fix":"Change import: use pugPlugin() not pugPlugin","cause":"Incorrect import. The package exports a function that must be called to create the plugin.","error":"TypeError: pugPlugin is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}