Registry / devops / nginject-loader

nginject-loader

JSON →
library2.1.0jsnpmunverified

Webpack loader to migrate from legacy @ngInject pre-minifier syntax to modern "ngInject" directive prologue syntax for AngularJS applications. Current stable version is 2.1.0 with low release cadence. Key differentiator: reliably detects and rewrites @ngInject annotations after transpilation, enabling gradual migration while working alongside ng-annotate-loader. Version 2.x streamlined the loader to focus solely on syntax migration, contrasting with version 1.x which overlapped ng-annotate functionality.

npm install nginject-loader
INSTALL
IMPORT
SIG · NGINJECT-LOADER
N
nginject-loader
devopsjavascriptv2.1.0
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.

nginject-loader
✓ import 'nginject-loader'; // Or use in webpack config as a loader string
✗ const nginject = require('nginject-loader'); // Not a Node module to import, it's a webpack loader
This package is a webpack loader and is not intended for direct import. It is used via webpack configuration or inline loader syntax.
nginject
✓ loaders: ['ng-annotate', 'nginject?deprecate'] // In webpack config
✗ loaders: ['nginject', 'ng-annotate'] // Wrong order: nginject should come after transpilers, before ng-annotate
The loader order matters: place nginject after transpilers (e.g., babel) and before ng-annotate.
deprecate option
✓ loaders: ['ng-annotate', 'nginject?deprecate'] // With query parameter
✗ loaders: ['ng-annotate', 'nginject'] // Missing deprecate option, no warnings emitted
The deprecate option is strongly encouraged to help migration from @ngInject to "ngInject" syntax.

Shows how to configure webpack to use nginject-loader as a pre-processor to ng-annotate-loader, with the deprecate option enabled.

// webpack.config.js module.exports = { module: { rules: [ { test: /\.js$/, use: [ 'ng-annotate-loader', { loader: 'nginject-loader', options: { deprecate: true } } ] } ] } }; // Inline usage: require('!ng-annotate-loader!nginject-loader?deprecate!./file.js')
Debug
Known issues
breakingVersion 2.x changed the loader's purpose from full pre-minification to syntax migration only.
fix
Ensure you use ng-annotate-loader alongside nginject-loader for complete annotation. Remove any direct usage of version 1.x API.
affects: >=2.0.0
deprecatedThe @ngInject annotation syntax is deprecated in favor of the "ngInject" directive prologue.
fix
Migrate your code to use "ngInject" directive prologue and eventually remove this loader to improve compile time.
affects: >=0.0.0
gotchaLoader order matters: nginject-loader must come after transpilers (like babel) and before ng-annotate-loader.
fix
In webpack config, place nginject-loader after transpilers and before ng-annotate in the loaders array.
affects: >=2.0.0
gotchaThe deprecate option is not enabled by default; without it, no warnings are emitted for @ngInject usage.
fix
Add ?deprecate or { deprecate: true } to enable warnings during migration.
affects: >=2.0.0
Errors
Common errors & fixes
Module parse failed: The module seems to be a webpack loader, not a regular module.
Directly importing nginject-loader with require('nginject-loader') instead of using it as a loader in webpack config.
fix
Use the loader via webpack module rules or inline loader syntax, e.g., require('!nginject-loader!./file.js').
Error: Deprecation warning: @ngInject found in ... Consider migrating to "ngInject" syntax.
The deprecate option is enabled and an @ngInject annotation was detected.
fix
Update the source code to use "ngInject" directive prologue instead of @ngInject.
Upgrade
Version history
2.1.0latest on npm
Audit
Dependencies
ng-annotate-loaderrequiredngInject-loader is designed to be used as a pre-processor to ng-annotate-loader for the purpose of migrating annotations.
Agent activity
11 hits · last 30 days
node
10
Resources
nginject-loader — npm install nginject-loader · libregistry