Gathering detailed insights and metrics for auto-ngtemplate-loader
Gathering detailed insights and metrics for auto-ngtemplate-loader
Gathering detailed insights and metrics for auto-ngtemplate-loader
Gathering detailed insights and metrics for auto-ngtemplate-loader
Auto require AngularJS 1.x templates in Webpack style
npm install auto-ngtemplate-loader
Typescript
Module System
Min. Node Version
Node Version
NPM Version
auto-ngtemplate-loader v3.1.2
Updated on Aug 08, 2022
auto-ngtemplate-loader v3.1.1
Updated on Sep 07, 2021
auto-ngtemplate-loader v3.0.0
Updated on Jul 23, 2020
auto-ngtemplate-loader v2.1.0
Updated on Mar 01, 2020
auto-ngtemplate-loader v2.0.2
Updated on Jul 25, 2019
auto-ngtemplate-loader v2.0.1
Updated on Jun 10, 2019
JavaScript (99.59%)
Shell (0.41%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
12 Stars
380 Commits
6 Forks
2 Watchers
9 Branches
2 Contributors
Updated on Oct 02, 2024
Latest Version
3.1.2
Package Id
auto-ngtemplate-loader@3.1.2
Unpacked Size
18.60 kB
Size
6.41 kB
File Count
7
NPM Version
8.15.0
Node Version
18.7.0
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
Auto require AngularJS 1.x templates in Webpack style
Install the package by running npm install auto-ngtemplate-loader
. Once installed, you can add it to your Webpack config.
1module.exports = { 2 module: { 3 rules: [ 4 { 5 test: /\.js$/, 6 exclude: /node_modules/, 7 use: ['babel-loader', 'other-loaders', 'auto-ngtemplate-loader'], 8 }, 9 ], 10 }, 11};
Note - It is recommended that this loader be run before any transpilation happens so it can operate on unchanged source code.
The next step is to add ngtemplate-loader
and a loader that you want to handle your template code with. The most common one is html-loader
. This will run every time Webpack encounters require('something.html')
.
1module.exports = { 2 module: { 3 rules: [ 4 { 5 test: /\.html$/, 6 exclude: /node_modules/, 7 use: [ 8 { 9 loader: 'ngtemplate-loader', 10 options: { 11 relativeTo: 'src/', 12 }, 13 }, 14 { 15 loader: 'html-loader', 16 }, 17 ], 18 }, 19 ], 20 }, 21};
It is a good idea to add the relativeTo
option for ngtemplate-loader
so that the templates aren't put into the Angular template cache with absolute paths which contain platform specific or user specific information. This will affect the portability of the bundled code.
This module supports configuration through either the options
object method or the query string method. The valid options are listed in the table below.
Name | Type | Default Value | Details |
---|---|---|---|
variableName | string | autoNgTemplateLoaderTemplate | The variable name that gets injected into the compiled code. This is included so that variable collisions can be prevented. |
pathResolver | (path: string) => string | urlToRequest | This function can be used to customize the require path in cases where templates don't use relative paths. This function is called with the path of the template and must return a string which is a valid path. |
Since Webpack v1 only supports query strings for loaders and doesn't allow passing a function as an option, this loader has a useResolverFromConfig
boolean option that can be passed in through the query string. The loader will look for the resolver in the Webpack configuration object under the key autoNgTemplateLoader
. The only acceptable member of autoNgTemplateLoader
is pathResolver
which should be a function that returns a string for all cases. An example is below.
1module.exports = { 2 autoNgTemplateLoader: { 3 pathResolver: (p) => p.replace(/src/, '..').substring(1), 4 }, 5 module: { 6 loaders: [ 7 { 8 test: /\.js$/, 9 exclude: /node_modules/, 10 loader: 11 'babel-loader!auto-ngtemplate-loader?variableName=testVar&useResolverFromConfig=true', 12 }, 13 ], 14 }, 15};
Note: The loader will throw an error if useResolverFromConfig
is used in Webpack v2 or newer. The recommended way to pass the function is through the options in that case. This is because the Loader API v2 has deprecated a property that is used for the v1 workaround. The loader will check the version and report an error.
Please follow the guidelines in the contribution guide for development.
Once the repository is cloned, run npm install
to get all the dependencies. The examples in this package also depend on ngtemplate-loader
and html-loader
.
There are a few example projects included. One that has one directive, another that has more, one that uses templates from a different folder, and one that uses absolute paths. You can run npm run one-directive
, npm run many-directives
, npm run multiple-directives
, npm run separated-templates
, or npm run absolute-paths
to see the loader in action. Once successful, examining the build/bundle.js
file under the respective examples folder will show the results.
The tests for this package are written in with ava. They can be run by running npm test
.
This project uses ESLint. All the requisite files can be linted using npm run linter
. The rules for this project are located in eslintrc.json
. This will also report prettier errors.
main
branch by running git pull --rebase
. Resolve all the conflicts as necessary.npm outdated
and npm update
. This will update the package versions that can be updated automatically.package.json
and change all the ^
into ~
and regenerate the package-lock.json
by running rm -rf node_modules package-lock.json && npm install
CHANGELOG.md
file and detail the changes that are shipping with this release.package.json
and package-lock.json
.main
.main
to stable
.stable
.stable
locally and run npm run publish-dryrun
to validate the files that are being shipped. Make sure that it is the most minimal set.npm publish
to publish the package.This project also includes an .nvmrc
. This is to tell nvm
what version of Node.js to use for this project. It is set to v16 which is the current release. However, we run tests on node LTS versions 10, 12, and 14 as well.
loader-utils
Issue and PR templates derived from smhxx/atom-ts-transpiler.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
SAST tool detected but not run on all commits
Details
Reason
security policy file detected
Details
Reason
Found 0/5 approved changesets -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
13 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More