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
muslnode 18–226 runs
build_error
glibcnode 18–226 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
tpl
✓ import template from 'tpl!./file.html'
✗ import template from 'tpl-loader!./file.html'
The loader is used via webpack inline syntax. `tpl-loader` can also be used but `tpl!` is the common shorthand.
tplSettings
✓ // webpack.config.js
export const tplSettings = { interpolate: /\{\{\{(.+?)\}\}\}/g }
✗ // Not a direct import; configurations are set via global webpack config, not imported
Configuration is passed through webpack's top-level `tplSettings` property, not imported.
Shows how to configure webpack to load .html files as Lodash templates and use the compiled function.
// webpack.config.js
{
module: {
loaders: [
{ test: /\.html$/, loader: 'tpl-loader' }
]
},
tplSettings: {
interpolate: /\{\{\{(.+?)\}\}\}/g
}
}
// In your module:
import template from './template.html';
const data = { name: 'World' };
const result = template(data); // 'Hello {{World}}'
Errors
Common errors & fixes
Module not found: Error: Cannot resolve module 'tpl-loader'
tpl-loader is not installed or not in node_modules.
fixRun `npm install tpl-loader --save-dev`.
TypeError: _.template is not a function
lodash is not installed or an older version without _.template support.
fixInstall/update lodash: `npm install lodash`.
Audit
Dependencies
lodashrequiredRuntime peer dependency for template compilation function