{"id":41587,"library":"nginject-loader","title":"ngInject Loader","description":"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.","status":"maintenance","version":"2.1.0","language":"javascript","source_language":"en","source_url":"https://github.com/bholloway/nginject-loader","tags":["javascript","webpack","loader","annotate","ng-annotate","ngInject","angular","minify","preminifiy"],"install":[{"cmd":"npm install nginject-loader","lang":"bash","label":"npm"},{"cmd":"yarn add nginject-loader","lang":"bash","label":"yarn"},{"cmd":"pnpm add nginject-loader","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"ngInject-loader is designed to be used as a pre-processor to ng-annotate-loader for the purpose of migrating annotations.","package":"ng-annotate-loader","optional":false}],"imports":[{"note":"This package is a webpack loader and is not intended for direct import. It is used via webpack configuration or inline loader syntax.","wrong":"const nginject = require('nginject-loader'); // Not a Node module to import, it's a webpack loader","symbol":"nginject-loader","correct":"import 'nginject-loader'; // Or use in webpack config as a loader string"},{"note":"The loader order matters: place nginject after transpilers (e.g., babel) and before ng-annotate.","wrong":"loaders: ['nginject', 'ng-annotate'] // Wrong order: nginject should come after transpilers, before ng-annotate","symbol":"nginject","correct":"loaders: ['ng-annotate', 'nginject?deprecate'] // In webpack config"},{"note":"The deprecate option is strongly encouraged to help migration from @ngInject to \"ngInject\" syntax.","wrong":"loaders: ['ng-annotate', 'nginject'] // Missing deprecate option, no warnings emitted","symbol":"deprecate option","correct":"loaders: ['ng-annotate', 'nginject?deprecate'] // With query parameter"}],"quickstart":{"code":"// webpack.config.js\nmodule.exports = {\n  module: {\n    rules: [\n      {\n        test: /\\.js$/,\n        use: [\n          'ng-annotate-loader',\n          { loader: 'nginject-loader', options: { deprecate: true } }\n        ]\n      }\n    ]\n  }\n};\n// Inline usage: require('!ng-annotate-loader!nginject-loader?deprecate!./file.js')","lang":"javascript","description":"Shows how to configure webpack to use nginject-loader as a pre-processor to ng-annotate-loader, with the deprecate option enabled."},"warnings":[{"fix":"Ensure you use ng-annotate-loader alongside nginject-loader for complete annotation. Remove any direct usage of version 1.x API.","message":"Version 2.x changed the loader's purpose from full pre-minification to syntax migration only.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Migrate your code to use \"ngInject\" directive prologue and eventually remove this loader to improve compile time.","message":"The @ngInject annotation syntax is deprecated in favor of the \"ngInject\" directive prologue.","severity":"deprecated","affected_versions":">=0.0.0"},{"fix":"In webpack config, place nginject-loader after transpilers and before ng-annotate in the loaders array.","message":"Loader order matters: nginject-loader must come after transpilers (like babel) and before ng-annotate-loader.","severity":"gotcha","affected_versions":">=2.0.0"},{"fix":"Add ?deprecate or { deprecate: true } to enable warnings during migration.","message":"The deprecate option is not enabled by default; without it, no warnings are emitted for @ngInject usage.","severity":"gotcha","affected_versions":">=2.0.0"}],"env_vars":null,"search_vec":"'1':67 '2':53 '2.1.0':27 'alongsid':47 'angular':83 'angularj':21 'annot':39,50,73,78,81 'applic':22 'cadenc':31 'contrast':64 'current':23 'detect':35 'differenti':33 'direct':17 'enabl':42 'focus':59 'function':74 'gradual':43 'javascript':75 'key':32 'legaci':8 'loader':2,4,51,57,77 'low':29 'migrat':6,44,63 'minifi':12,84 'modern':15 'ng':49,72,80 'ng-annot':71,79 'ng-annotate-load':48 'nginject':1,9,16,38,82 'overlap':70 'pre':11 'pre-minifi':10 'preminifiy':85 'prologu':18 'releas':30 'reliabl':34 'rewrit':37 'sole':60 'stabl':24 'streamlin':55 'syntax':13,19,62 'transpil':41 'version':25,52,66 'webpack':3,76 'work':46 'x':54,68","created_at":"2026-06-04T18:53:08.085100+00:00","updated_at":"2026-06-04T18:53:08.085100+00:00","problems":[{"fix":"Use the loader via webpack module rules or inline loader syntax, e.g., require('!nginject-loader!./file.js').","cause":"Directly importing nginject-loader with require('nginject-loader') instead of using it as a loader in webpack config.","error":"Module parse failed: The module seems to be a webpack loader, not a regular module."},{"fix":"Update the source code to use \"ngInject\" directive prologue instead of @ngInject.","cause":"The deprecate option is enabled and an @ngInject annotation was detected.","error":"Error: Deprecation warning: @ngInject found in ... Consider migrating to \"ngInject\" syntax."}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/bholloway/nginject-loader","github":"https://github.com/bholloway/nginject-loader","docs":null,"changelog":null,"pypi":null,"npm":"nginject-loader","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops","testing"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-04","next_check":"2026-09-02","install_tag":null}}