{"id":21999,"library":"rollup-plugin-emit-ejs","title":"rollup-plugin-emit-ejs","description":"Rollup plugin to emit files from EJS templates into the bundle output. Version 3.1.0 (stable, last updated 2021). This plugin uses Rollup's emitFile() method, allowing other plugins to process emitted files (e.g., minify HTML). It provides a basic layout system, automatic JavaScript and stylesheet linking via helper variables (javascripts, stylesheets, content), and supports any file type, not just HTML. Key differentiator: unlike rollup-plugin-bundle-html, it enables post-processing of emitted assets. Requires rollup ^2.10.0 as peer dependency. Ships TypeScript definitions.","status":"active","version":"3.1.0","language":"javascript","source_language":"en","source_url":"https://github.com/juliendargelos/rollup-plugin-emit-ejs","tags":["javascript","typescript"],"install":[{"cmd":"npm install rollup-plugin-emit-ejs","lang":"bash","label":"npm"},{"cmd":"yarn add rollup-plugin-emit-ejs","lang":"bash","label":"yarn"},{"cmd":"pnpm add rollup-plugin-emit-ejs","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency required for plugin functionality (emitFile API).","package":"rollup","optional":false},{"reason":"Runtime dependency for compiling EJS templates.","package":"ejs","optional":false}],"imports":[{"note":"Default export. Plugin is ESM-only; CommonJS require may not work in all setups. Use dynamic import() if CJS needed.","wrong":"const emitEJS = require('rollup-plugin-emit-ejs')","symbol":"emitEJS","correct":"import emitEJS from 'rollup-plugin-emit-ejs'"},{"note":"Options type is exported as a named TypeScript type. Do not use value import for types.","wrong":"import { Options } from 'rollup-plugin-emit-ejs'","symbol":"Options","correct":"import type { Options } from 'rollup-plugin-emit-ejs'"},{"note":"Return type is a Rollup Plugin. If using TypeScript, import Plugin type from 'rollup'.","wrong":null,"symbol":"Plugin","correct":"import type { Plugin } from 'rollup'"}],"quickstart":{"code":"// rollup.config.js\nimport emitEJS from 'rollup-plugin-emit-ejs';\n\nexport default {\n  input: 'src/index.js',\n  output: { dir: 'dist', format: 'es' },\n  plugins: [\n    emitEJS({\n      src: 'src',\n      layout: 'src/layout.html.ejs',\n      data: {\n        title: 'My App',\n        body: 'Content goes here'\n      }\n    })\n  ]\n};","lang":"typescript","description":"Basic usage: emit an HTML file from EJS template with layout and data. Shows plugin config in rollup.config.js."},"warnings":[{"fix":"Do not list layout template in exclude option; it is excluded automatically.","message":"Layout template path is automatically excluded from file emission, but duplicate exclusion may cause unexpected behavior.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Ensure output format supports multiple chunks (e.g., 'es', 'cjs') and that code splitting is enabled.","message":"The helper variables (javascripts, stylesheets) are only populated if Rollup outputs chunks (e.g., code-split). In legacy mode or single-bundle output, they may be empty.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Either use .ejs only and rely on extension option, or use explicit extensions in filename and omit extension option.","message":"The extension option can cause conflicts if specified alongside templates that already have a custom extension (e.g., index.html.ejs).","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Monitor compatibility with upcoming Rollup releases; consider alternatives if Rollup 4+ is needed.","message":"No deprecation notices in current version. Plugin is stable but may not receive updates for newer Rollup versions (>3.0).","severity":"deprecated","affected_versions":">=3.0.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Install ejs: npm install ejs","cause":"Missing runtime dependency 'ejs' in project.","error":"Error: Could not resolve 'ejs'"},{"fix":"Ensure the template file exists and is relative to the src directory (e.g., if src='templates', use layout='templates/layout.html.ejs').","cause":"Template path specified in options does not exist or is outside the src directory.","error":"Error: [plugin:emit-ejs] EJS cannot find module: 'file.ejs'"},{"fix":"Use ESM import: import emitEJS from 'rollup-plugin-emit-ejs' or use dynamic import: const emitEJS = await import('rollup-plugin-emit-ejs').then(m => m.default).","cause":"Wrong import method; using CommonJS require with a default export.","error":"TypeError: emitEJS is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}