Registry / web-framework / rollup-plugin-emit-ejs

rollup-plugin-emit-ejs

JSON →
library3.1.0jsnpmunverified

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.

npm install rollup-plugin-emit-ejs
INSTALL
IMPORT
SIG · ROLLUP-PLUGIN-EMIT
R
rollup-plugin-emit-ejs
web-frameworkjavascriptv3.1.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.

emitEJS
import emitEJS from 'rollup-plugin-emit-ejs'
const emitEJS = require('rollup-plugin-emit-ejs')
Default export. Plugin is ESM-only; CommonJS require may not work in all setups. Use dynamic import() if CJS needed.
Options
import type { Options } from 'rollup-plugin-emit-ejs'
import { Options } from 'rollup-plugin-emit-ejs'
Options type is exported as a named TypeScript type. Do not use value import for types.
Plugin
import type { Plugin } from 'rollup'
Return type is a Rollup Plugin. If using TypeScript, import Plugin type from 'rollup'.

Basic usage: emit an HTML file from EJS template with layout and data. Shows plugin config in rollup.config.js.

// rollup.config.js import emitEJS from 'rollup-plugin-emit-ejs'; export default { input: 'src/index.js', output: { dir: 'dist', format: 'es' }, plugins: [ emitEJS({ src: 'src', layout: 'src/layout.html.ejs', data: { title: 'My App', body: 'Content goes here' } }) ] };
Debug
Known issues
gotchaLayout template path is automatically excluded from file emission, but duplicate exclusion may cause unexpected behavior.
fix
Do not list layout template in exclude option; it is excluded automatically.
affects: >=1.0.0
gotchaThe 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.
fix
Ensure output format supports multiple chunks (e.g., 'es', 'cjs') and that code splitting is enabled.
affects: >=1.0.0
gotchaThe extension option can cause conflicts if specified alongside templates that already have a custom extension (e.g., index.html.ejs).
fix
Either use .ejs only and rely on extension option, or use explicit extensions in filename and omit extension option.
affects: >=1.0.0
deprecatedNo deprecation notices in current version. Plugin is stable but may not receive updates for newer Rollup versions (>3.0).
fix
Monitor compatibility with upcoming Rollup releases; consider alternatives if Rollup 4+ is needed.
affects: >=3.0.0
Errors
Common errors & fixes
Error: Could not resolve 'ejs'
Missing runtime dependency 'ejs' in project.
fix
Install ejs: npm install ejs
Error: [plugin:emit-ejs] EJS cannot find module: 'file.ejs'
Template path specified in options does not exist or is outside the src directory.
fix
Ensure the template file exists and is relative to the src directory (e.g., if src='templates', use layout='templates/layout.html.ejs').
TypeError: emitEJS is not a function
Wrong import method; using CommonJS require with a default export.
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).
Upgrade
Version history
3.1.0latest on npm
Audit
Dependencies
rolluprequiredPeer dependency required for plugin functionality (emitFile API).
ejsrequiredRuntime dependency for compiling EJS templates.
Agent activity
4 hits · last 30 days
node
4
Resources
rollup-plugin-emit-ejs — npm install rollup-plugin-emit-ejs · libregistry