Registry / devops / cache-pug-templates

cache-pug-templates

JSON →
library2.0.3jsnpmunverified

Utility for caching Pug templates in web frameworks like Express, Koa, and Connect. v2.0.3 is the latest stable release (last updated 2020). It batches template compilation to avoid overhead on first request. Alternatives like pug's built-in caching or webpack-based approaches offer more integration, but this package provides explicit control over batch caching for Lad/Koa/Express/Connect apps.

npm install cache-pug-templates
INSTALL
IMPORT
SIG · CACHE-PUG-TEMPLATE
C
cache-pug-templates
devopsjavascriptv2.0.3
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.

CachePugTemplates
✓ const CachePugTemplates = require('cache-pug-templates')
✗ import CachePugTemplates from 'cache-pug-templates'
CJS only; no ESM export.
default
✓ const CachePugTemplates = require('cache-pug-templates')
✗ const { CachePugTemplates } = require('cache-pug-templates')
Module exports a single class via module.exports = CachePugTemplates

Shows basic usage: create a cache instance with views path and start caching.

const path = require('path'); const CachePugTemplates = require('cache-pug-templates'); const views = path.join(__dirname, 'views'); const cache = new CachePugTemplates({ views }); cache.start(); // pre-caches all .pug files in views
Debug
Known issues
breakingv2.0.0 changed options: removed `directory`, must use `views`.
fix
Use `views` instead of `directory` in options.
affects: <2.0.0
gotchaCaches ALL .pug files in views directory on start; can be slow for large directories.
fix
Use `concurrency` and `interval` options to limit rate or use `callback` to manually select files.
affects: >=2.0.0
gotchaPackage is CJS only; cannot be imported with ESM import syntax.
fix
Use require() instead of import.
affects: >=2.0.0
Errors
Common errors & fixes
Error: Cannot find module 'cache-pug-templates'
Package not installed.
fix
npm install cache-pug-templates pug
TypeError: CachePugTemplates is not a constructor
Wrong import syntax (destructured require or ESM import).
fix
Use const CachePugTemplates = require('cache-pug-templates')
Error: The `views` option must be provided.
Missing or invalid `views` option in constructor.
fix
Pass a valid directory path or array of paths in `views` option.
Upgrade
Version history
2.0.3latest on npm
Audit
Dependencies
pugrequiredpeer dependency – used to compile and cache templates
Agent activity
7 hits · last 30 days
node
6
Resources
cache-pug-templates — npm install cache-pug-templates · libregistry