Registry / web-framework / auto-ngtemplate-loader

auto-ngtemplate-loader

JSON →
library3.1.2jsnpmunverified

Webpack loader that automatically requires AngularJS 1.x templates when templateUrl is encountered in JavaScript files. Version 3.1.2 drops Node.js 8 support. It works alongside ngtemplate-loader and html-loader to preprocess template paths. Key differentiator: eliminates manual require calls for templates by transforming templateUrl strings into require() statements at build time. Supports custom path resolution and variable naming to avoid conflicts. Recommended to run before transpilation. Maintained but mature, with infrequent releases.

npm install auto-ngtemplate-loader
INSTALL
IMPORT
SIG · AUTO-NGTEMPLATE-LO
A
auto-ngtemplate-loader
web-frameworkjavascriptv3.1.2
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.

auto-ngtemplate-loader
module.exports = { module: { rules: [{ test: /\.js$/, use: ['auto-ngtemplate-loader'] }] } }
import autoNgTemplateLoader from 'auto-ngtemplate-loader';
This is a webpack loader, not a JavaScript module. It should be used in webpack config as a string in the use array.
Options (variableName)
use: [{ loader: 'auto-ngtemplate-loader', options: { variableName: 'myTemplateVar' } }]
use: ['auto-ngtemplate-loader?variableName=myTemplateVar']
Query string syntax works but options object is preferred for readability. variableName defaults to 'autoNgTemplateLoaderTemplate'.
Options (pathResolver)
use: [{ loader: 'auto-ngtemplate-loader', options: { pathResolver: (path) => './' + path } }]
use: [{ loader: 'auto-ngtemplate-loader', options: { pathResolver: 'myFunction' } }]
pathResolver must be a function. In webpack 1, useResolverFromConfig option must be true and define autoNgTemplateLoader in webpack config.

Configures webpack to auto-require AngularJS templates from templateUrl properties, using ngtemplate-loader and html-loader for processing.

// webpack.config.js module.exports = { module: { rules: [ { test: /\.js$/, exclude: /node_modules/, use: ['babel-loader', 'auto-ngtemplate-loader'], }, { test: /\.html$/, use: [ { loader: 'ngtemplate-loader', options: { relativeTo: 'src/' } }, { loader: 'html-loader' }, ], }, ], }, };
Debug
Known issues
breakingNode.js v8 support dropped
fix
Upgrade to Node.js >=10 or use version 2.x if needed.
affects: >=3.0.0
deprecatedWebpack v1 compatibility is deprecated, useResolverFromConfig option may not work with newer webpack versions.
fix
Use webpack v2+ and pass options via loader options object.
affects: >=1.3.0
gotchaLoader must run before transpilation to operate on unchanged source code
fix
Place auto-ngtemplate-loader before transpilers like babel-loader in the use array.
affects: >=1.0.0
gotchatemplateUrl detection may fail on Windows paths in older versions
fix
Upgrade to version >=2.0.1.
affects: <2.0.1
gotchaIf ngtemplate-loader is not configured correctly, template paths may include absolute user-specific paths
fix
Set the relativeTo option on ngtemplate-loader to a common source directory (e.g., 'src/').
affects: >=1.0.0
Errors
Common errors & fixes
Module not found: Error: Can't resolve 'ngtemplate-loader'
ngtemplate-loader is not installed or not added to the webpack rule for .html files.
fix
Install ngtemplate-loader: npm install ngtemplate-loader --save-dev, then add it to the module.rules for .html files.
Error: autoNgTemplateLoaderTemplate is not defined
The variable name used by auto-ngtemplate-loader conflicts with another variable or is not properly injected.
fix
Use the variableName option to set a unique variable name, e.g., { loader: 'auto-ngtemplate-loader', options: { variableName: 'myTemplateVar' } }.
ERROR in ./src/app.js Module build failed (from ./node_modules/auto-ngtemplate-loader/index.js): TypeError: The 'compilation' argument must be an instance of Compilation
Incompatibility with webpack 5; auto-ngtemplate-loader may not support it.
fix
Use webpack 4 or check for updates on the package. Consider using a different loader if unsupported.
Upgrade
Version history
3.1.2latest on npm
Audit
Dependencies
loader-utilsrequiredRequired for webpack loader utilities like urlToRequest
Agent activity
22 hits · last 30 days
node
18
Perplexity
1
OpenAI (training)
1
Resources
auto-ngtemplate-loader — npm install auto-ngtemplate-loader · libregistry