Registry / web-framework / ejs-compiled-loader

ejs-compiled-loader

JSON →
library3.1.0jsnpmunverified

Webpack loader that compiles EJS templates (without frontend dependencies) into reusable JavaScript functions. Current stable version is 3.1.0. Release cadence is irregular; major version bumps (e.g., 3.0.0) added webpack 4 support. Key differentiators: it strips out runtime dependencies, compiles templates to functions, supports HTML minification, and is intended for server-side or build-time template compilation—not for browser-ready templates with the full EJS runtime.

npm install ejs-compiled-loader
INSTALL
IMPORT
SIG · EJS-COMPILED-LOADE
E
ejs-compiled-loader
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 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

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

ejs-compiled-loader
import template from 'ejs-compiled-loader!./file.ejs';
const template = require('ejs-compiled-loader!./file.ejs');
Webpack loader usage is identical in CommonJS and ESM; the loader returns the template function, not the raw source.
rules config (webpack)
module.exports = { module: { rules: [ { test: /\.ejs$/, use: 'ejs-compiled-loader' } ] } };
module.exports = { module: { loaders: [ { test: /\.ejs$/, loader: 'ejs-compiled-loader' } ] } };
webpack 4+ uses module.rules, not module.loaders. The loader property was deprecated in webpack 2.
require() in Node (without webpack)
const { compile } = require('ejs'); const template = compile(source);
const template = require('ejs-compiled-loader!./file.ejs'); // Only works in webpack context
ejs-compiled-loader is a webpack loader; it cannot be used directly in Node without webpack.

Shows basic webpack configuration and how to import an .ejs template, then render it with data.

// webpack.config.js module.exports = { module: { rules: [ { test: /\.ejs$/, use: 'ejs-compiled-loader' } ] } }; // app.js import template from './file.ejs'; const html = template({ name: 'World' }); console.log(html); // => '<p>Hello World</p>'
Debug
Known issues
breakingejs-compiled-loader v3 drops support for webpack <4. If you are on webpack 3 or earlier, use v2.
fix
Upgrade to webpack 4+ or pin ejs-compiled-loader@2.3.0.
affects: >=3.0.0
deprecatedThe module.loaders syntax is deprecated since webpack 2. Using it with ejs-compiled-loader will cause warnings.
fix
Use module.rules with the use property instead of loaders.
affects: *
gotchaEJS options like 'delimiter' or 'openDelimiter' are not directly supported in ejs-compiled-loader v3; you must pass them via query parameters or the options object.
fix
Example: use: 'ejs-compiled-loader?delimiter=?' or specify in options: use: { loader: 'ejs-compiled-loader', options: { delimiter: '?' } }
affects: >=3.0.0
gotchaThe loader returns a function, not a string. Attempting to assign the output directly to innerHTML will fail if not invoked.
fix
Ensure you call the template function with data: const html = template(data);
affects: *
Errors
Common errors & fixes
Module not found: Error: Can't resolve 'ejs' in '/path'
ejs is a peer dependency and must be installed separately.
fix
Run: npm install ejs
You may need an appropriate loader to handle this file type.
Webpack cannot parse .ejs files without the ejs-compiled-loader configured.
fix
Add a rule for .ejs files in your webpack configuration using ejs-compiled-loader.
template is not a function
You did not invoke the function returned by the loader.
fix
Call the imported template with data: const html = template(data);
Upgrade
Version history
3.1.0latest on npm
Audit
Dependencies
ejsrequiredEJS library used to compile templates (peer dependency in v3).
html-minifieroptionalOptional dependency for minifying HTML output (only needed if htmlmin is enabled).
Agent activity
5 hits · last 30 days
node
4
OpenAI (training)
1
Resources
ejs-compiled-loader — npm install ejs-compiled-loader · libregistry