{"id":22273,"library":"rollup-plugin-underscorify","title":"rollup-plugin-underscorify","description":"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.","status":"active","version":"1.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/aptivator/rollup-plugin-underscorify","tags":["javascript","rollup","plugin","underscore","templates"],"install":[{"cmd":"npm install rollup-plugin-underscorify","lang":"bash","label":"npm"},{"cmd":"yarn add rollup-plugin-underscorify","lang":"bash","label":"yarn"},{"cmd":"pnpm add rollup-plugin-underscorify","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency: Rollup plugin interface","package":"rollup","optional":false},{"reason":"Compiles templates using Underscore's template function","package":"underscore","optional":false}],"imports":[{"note":"ESM-only; CJS require will cause undefined error.","wrong":"const underscorify = require('rollup-plugin-underscorify')","symbol":"default","correct":"import underscorify from 'rollup-plugin-underscorify'"},{"note":"Default export, not named.","wrong":"import { underscorify } from 'rollup-plugin-underscorify'","symbol":"underscorify","correct":"import underscorify from 'rollup-plugin-underscorify'"},{"note":"Options must be passed as an object, not an array.","wrong":"underscorify(['**/*.tpl'])","symbol":"Plugin config object","correct":"underscorify({ include: ['**/*.tpl'], exclude: ['**/ignore.tpl'], variable: 'p' })"}],"quickstart":{"code":"import underscorify from 'rollup-plugin-underscorify';\n\nexport default {\n  input: 'index.js',\n  output: { file: 'bundle.js', format: 'iife' },\n  plugins: [\n    underscorify({\n      include: ['**/*.tpl'],\n      variable: 'p'\n    })\n  ]\n};","lang":"javascript","description":"Shows minimal Rollup config using the plugin to compile .tpl files into Underscore template modules."},"warnings":[{"fix":"Always prefix data properties with the configured variable, e.g., `<%= p.username %>`.","message":"Namespace variable (e.g., `p`) MUST be used inside templates to access data; raw property names like `<%= username %>` will be undefined.","severity":"gotcha","affected_versions":"*"},{"fix":"Pass `_` as part of the template data, e.g., `tplData._ = _;`.","message":"Underscore (`_`) or any other library used inside templates must be explicitly passed in the data object. Rollup does not guarantee global import availability.","severity":"gotcha","affected_versions":"*"},{"fix":"Use a suitable `output.format` like 'iife' or 'umd'.","message":"The 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.","severity":"gotcha","affected_versions":"*"},{"fix":"Always use variable prefix (e.g., `p.`) in template expressions.","message":"`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.","severity":"gotcha","affected_versions":"*"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Run `npm install rollup-plugin-underscorify --save-dev` and ensure node_modules path is correct.","cause":"Package not installed or only installed as devDependency but not available in build environment.","error":"Error: Cannot find module 'rollup-plugin-underscorify'"},{"fix":"Use `import` syntax in your Rollup config (requires Rollup ESM config support).","cause":"Using CJS require with an ESM-only package.","error":"SyntaxError: Unexpected token 'export'"},{"fix":"Change import to `import underscorify from 'rollup-plugin-underscorify'`.","cause":"Using named import `underscorify` instead of default import.","error":"TypeError: underscorify is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}