Registry / testing / compile-ejs-loader

compile-ejs-loader

JSON →
library0.0.3jsnpmunverified

A webpack loader that precompiles EJS templates into JavaScript functions at build time, removing the need for client-side EJS runtime dependencies. Current stable version 0.0.3, last updated 2018 (maintenance mode). For webpack 5+. Unlike ejs-loader, this loader focuses on compiling templates without shipping the full EJS engine to the browser. Supports HTML minification and beautification via options. Very low maintenance cadence; no updates since 2018.

npm install compile-ejs-loader
INSTALL
IMPORT
SIG · COMPILE-EJS-LOADER
C
compile-ejs-loader
testingjavascriptv0.0.3
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

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

compile-ejs-loader
✓ import template from 'compile-ejs-loader!./file.ejs';
✗ const template = require('compile-ejs-loader!./file.ejs');
Only CommonJS require works in webpack config. In webpack 5, ESM imports are not supported for inline loader syntax; use `require`. This loader returns a compiled template function.
compile-ejs-loader (webpack config rule)
✓ module.exports = { module: { rules: [ { test: /\.ejs$/, loader: 'compile-ejs-loader' } ] } }
✗ module.exports = { module: { rules: [ { test: /\.ejs$/, use: 'compile-ejs-loader' } ] } }
Both `loader` and `use` work for single loaders. If using options, wrap with `{ loader: 'compile-ejs-loader', options: {} }`.
options
✓ options: { htmlmin: true, htmlminOptions: { removeComments: true } }
✗ options: { htmlmin: true, removeComments: true }
htmlmin option enables minification; additional minifier options must be placed under `htmlminOptions` key.

Shows webpack configuration using compile-ejs-loader with htmlmin, beautify options and inline require usage.

// webpack.config.js const path = require('path'); module.exports = { entry: './src/index.js', output: { path: path.resolve(__dirname, 'dist'), filename: 'bundle.js' }, module: { rules: [ { test: /\.ejs$/, loader: 'compile-ejs-loader', options: { compileDebug: false, beautify: true, htmlmin: true, htmlminOptions: { removeComments: true, collapseWhitespace: true } } } ] } }; // src/index.js const template = require('compile-ejs-loader!./template.ejs'); const html = template({ name: 'World' }); console.log(html);
Debug
Known issues
deprecatedPackage not updated since 2018; may have compatibility issues with newer webpack or EJS versions.
fix
Consider using ejs-compiled-loader or ejs-loader for active maintenance.
affects: >=0.0.3
gotchaChild template includes are resolved relative to the webpack execution directory, not the template file.
fix
Use absolute paths or adjust webpack context option for reliable includes.
affects: *
gotchaLoader options are passed directly to EJS; some EJS options like 'filename' may cause issues if not set correctly.
fix
Ensure 'filename' is not used in loader options; the loader handles it internally.
affects: *
Errors
Common errors & fixes
Module parse failed: Unexpected token (1:0) in file.ejs
Webpack is treating the .ejs file as raw text instead of using the loader.
fix
Add a rule for .ejs files: { test: /\.ejs$/, loader: 'compile-ejs-loader' }
Cannot find module 'compile-ejs-loader'
Loader not installed or not in node_modules.
fix
Run: npm install compile-ejs-loader --save-dev
You may need an appropriate loader to handle this file type.
Webpack missing rule for .ejs files.
fix
Add compile-ejs-loader rule in webpack config as shown in quickstart.
Template include 'templates/child' is not working; file not found.
Includes are resolved from webpack execution directory, not relative to template.
fix
Use a path relative to the project root or set webpack context to your source directory.
Upgrade
Version history
0.0.3latest on npm
Audit
Dependencies
webpackrequiredPeer dependency: requires webpack ^5.18.0 to function as a loader.
Agent activity
14 hits · last 30 days
node
12
OpenAI (training)
1
Resources
compile-ejs-loader — npm install compile-ejs-loader · libregistry