Registry / web-framework / rollup-plugin-underscorify

rollup-plugin-underscorify

JSON →
library1.0.0jsnpmunverified

A Rollup plugin (v1.0.0, single release) that converts Underscore templates into ES modules for use in Backbone/Marionette apps. Unlike other template compilers, it forces explicit namespace variable access (no `with` statement) to maintain ES2015 strict mode compatibility. Requires manual injection of Underscore or other libraries into template scope, as Rollup's module bundling can't guarantee global access. Minimal configuration with include/exclude patterns and custom variable name. Stable but essentially feature-complete.

npm install rollup-plugin-underscorify
INSTALL
IMPORT
SIG · ROLLUP-PLUGIN-UNDE
R
rollup-plugin-underscorify
web-frameworkjavascriptv1.0.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18223 runs
build_error
glibc
node 18223 runs
build_error
Code
Verified usage

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

default
import underscorify from 'rollup-plugin-underscorify'
const underscorify = require('rollup-plugin-underscorify')
ESM-only; CJS require will cause undefined error.
underscorify
import underscorify from 'rollup-plugin-underscorify'
import { underscorify } from 'rollup-plugin-underscorify'
Default export, not named.
Plugin config object
underscorify({ include: ['**/*.tpl'], exclude: ['**/ignore.tpl'], variable: 'p' })
underscorify(['**/*.tpl'])
Options must be passed as an object, not an array.

Shows minimal Rollup config using the plugin to compile .tpl files into Underscore template modules.

import underscorify from 'rollup-plugin-underscorify'; export default { input: 'index.js', output: { file: 'bundle.js', format: 'iife' }, plugins: [ underscorify({ include: ['**/*.tpl'], variable: 'p' }) ] };
Debug
Known issues
gotchaNamespace variable (e.g., `p`) MUST be used inside templates to access data; raw property names like `<%= username %>` will be undefined.
fix
Always prefix data properties with the configured variable, e.g., `<%= p.username %>`.
affects: *
gotchaUnderscore (`_`) or any other library used inside templates must be explicitly passed in the data object. Rollup does not guarantee global import availability.
fix
Pass `_` as part of the template data, e.g., `tplData._ = _;`.
affects: *
gotchaThe plugin compiles templates to ES modules; ensure your Rollup config outputs a format (e.g., iife, umd) that supports module imports if used in browsers.
fix
Use a suitable `output.format` like 'iife' or 'umd'.
affects: *
gotcha`with` statement is not used, so template code must reference data through the variable; this avoids strict mode issues but changes template syntax from standard Underscore templates.
fix
Always use variable prefix (e.g., `p.`) in template expressions.
affects: *
Errors
Common errors & fixes
Error: Cannot find module 'rollup-plugin-underscorify'
Package not installed or only installed as devDependency but not available in build environment.
fix
Run `npm install rollup-plugin-underscorify --save-dev` and ensure node_modules path is correct.
SyntaxError: Unexpected token 'export'
Using CJS require with an ESM-only package.
fix
Use `import` syntax in your Rollup config (requires Rollup ESM config support).
TypeError: underscorify is not a function
Using named import `underscorify` instead of default import.
fix
Change import to `import underscorify from 'rollup-plugin-underscorify'`.
Upgrade
Version history
1.0.0latest on npm
Audit
Dependencies
rolluprequiredPeer dependency: Rollup plugin interface
underscorerequiredCompiles templates using Underscore's template function
Agent activity
4 hits · last 30 days
node
4
Resources
rollup-plugin-underscorify — npm install rollup-plugin-underscorify · libregistry