Registry / devops / esbuild-plugin-pug

esbuild-plugin-pug

JSON →
library0.0.8jsnpmunverified

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.

npm install esbuild-plugin-pug
INSTALL
IMPORT
SIG · ESBUILD-PLUGIN-PUG
E
esbuild-plugin-pug
devopsjavascriptv0.0.8
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default (pugPlugin)
import pugPlugin from 'esbuild-plugin-pug'
The package exports a single function that returns a plugin object. ESM import works in Node.js with esm or bundlers.
default (pugPlugin)
const pugPlugin = require('esbuild-plugin-pug')
CommonJS require works as the package provides a CJS entry.
type Plugin
import type { Plugin } from 'esbuild'
The plugin function returns an object compatible with esbuild's Plugin interface. No explicit type import from this package is needed.

Registers the pug plugin with esbuild and demonstrates importing a .pug file as a function that returns HTML.

import esbuild from 'esbuild'; import pugPlugin from 'esbuild-plugin-pug'; await esbuild.build({ entryPoints: ['src/index.ts'], bundle: true, platform: 'node', outfile: 'dist/bundle.js', plugins: [ pugPlugin() ], }); // Example template usage: // In src/index.ts: // import template from './template.pug'; // console.log(template()); // renders HTML
Debug
Known issues
gotchaThe plugin does not support esbuild's watch mode or incremental builds correctly; file changes in .pug files may not trigger rebuilds.
fix
Use a separate watch mechanism or esbuild's built-in watch with onRebuild callback.
affects: >=0.0.1
gotchaPug options (pretty, filename, etc.) are not exposed. The plugin hardcodes `pretty: true` which may produce unwanted whitespace.
fix
Fork the plugin or precompile templates manually if you need to customize Pug compiler options.
affects: >=0.0.1
gotchaThe plugin returns the compiled template as a function that takes locals object; it does not handle async templates or filters (e.g., markdown).
fix
Precompile async templates separately or use a different plugin that supports esbuild's async plugins.
affects: >=0.0.1
Errors
Common errors & fixes
Error: Cannot find module 'esbuild-plugin-pug'
Missing dev dependency. Install the package locally.
fix
npm install --save-dev esbuild-plugin-pug
TypeError: pugPlugin is not a function
Incorrect import. The package exports a function that must be called to create the plugin.
fix
Change import: use pugPlugin() not pugPlugin
Upgrade
Version history
0.0.8latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
esbuild-plugin-pug — npm install esbuild-plugin-pug · libregistry