{"_id":"inspect-loader","_rev":"8-e6f3f880f58a1939129901d27bb42c48","name":"inspect-loader","dist-tags":{"latest":"2.0.0"},"versions":{"1.0.0":{"name":"inspect-loader","version":"1.0.0","keywords":["webpack","loader","test","testing","debug"],"author":{"name":"developers@peerigon.com"},"license":"Unlicense","_id":"inspect-loader@1.0.0","maintainers":[{"name":"jhnns","email":"mail@johannesewald.de"}],"homepage":"https://github.com/peerigon/inspect-loader#readme","bugs":{"url":"https://github.com/peerigon/inspect-loader/issues"},"dist":{"shasum":"b5b1158237e059540f99edab84195abd4587b440","tarball":"https://registry.npmjs.org/inspect-loader/-/inspect-loader-1.0.0.tgz","integrity":"sha512-9bbKaXsJ+y+Y+k2Y0jL9SMiRt0Sw9NVSiTRD6e1WaWIQWNGR01a6+CMA1oqtbuFd6X5aaLEjfuwqywhYzZNbhg==","signatures":[{"sig":"MEUCIQCxaLOXLHDK2LoB2Xut6O7MGZYIR3y2XEdqaoE/sB/b8gIgUYEfe3avbxnrNosbU2tiOHhf4V7QCDnaY8GLNCX6Qw0=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"lib/loader.js","_from":".","files":["lib","raw.js","README.md","LICENSE"],"_shasum":"b5b1158237e059540f99edab84195abd4587b440","engines":{"node":">=4.0.0"},"gitHead":"1add30493a2420bac2c76bfcaf43e45e39db0ffb","scripts":{"lint":"eslint --ignore-path .gitignore lib test","test":"nyc ava"},"_npmUser":{"name":"jhnns","email":"mail@johannesewald.de"},"repository":{"url":"git+https://github.com/peerigon/inspect-loader.git","type":"git"},"_npmVersion":"4.1.2","description":"Webpack loader designed for loader testing and debugging. Calls a function with the received input.","directories":{},"_nodeVersion":"7.7.1","dependencies":{"loader-utils":"^1.0.3"},"devDependencies":{"ava":"^0.18.2","nyc":"^10.1.2","eslint":"^3.17.1","webpack":"^2.2.1","eslint-plugin-jsdoc":"^2.4.0","eslint-config-peerigon":"^9.0.0"},"_npmOperationalInternal":{"tmp":"tmp/inspect-loader-1.0.0.tgz_1489169828547_0.43085258547216654","host":"packages-12-west.internal.npmjs.com"}},"2.0.0":{"name":"inspect-loader","version":"2.0.0","keywords":["webpack","loader","test","testing","debug"],"author":{"name":"developers@peerigon.com"},"license":"Unlicense","_id":"inspect-loader@2.0.0","maintainers":[{"name":"jhnns","email":"mail@johannesewald.de"},{"name":"peeri","email":"developers@peerigon.com"}],"homepage":"https://github.com/peerigon/inspect-loader#readme","bugs":{"url":"https://github.com/peerigon/inspect-loader/issues"},"dist":{"shasum":"93697b33a88709e783cd27a07c34b05b0ee5a950","tarball":"https://registry.npmjs.org/inspect-loader/-/inspect-loader-2.0.0.tgz","fileCount":5,"integrity":"sha512-FBIDHct6NPRioSi7sWlJIYQhfbZHsfyp9ShFDTTpzUArTqioyBpiUgBzPhHhjeEvMJm5y1S8k1h0SkJM07IIRw==","signatures":[{"sig":"MEUCIC+1G09R9JsB9+daLVeaRrL5xqmCr+aAaJyvmGcUFOQNAiEA6Y0kVJc/ahhcpFkQy3q0ylz1AkjO+3kFEPIHrNmRrIU=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":10301,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgaxNkCRA9TVsSAnZWagAArpgP/jq/t8EQ7ITmq636pvgn\nao9anUVJ3rxqCNeWps8lbAsIrilGni8WvskG+eMIq6z2OC4MNR+/jvWyI/Sz\nW59EG4L2Rh0WKx5btjVodXitcGhny5aJoSO9TaIoxsdFo6xQ/yHKVUUVR99f\nNCICxXlgHVg7M8mnOs5p8tepzaFrnM0vR+gLBjpBE9CwfNef3rwQc5Y3mtiu\ny0eEtFGXncNVXonE+tca+mLn0vo0OMXC8Q1jiO5PzlDWKkbZTmrMHr8C7hEx\nrJnz22b3dO4OOaez6LUe8N5x8O1VNicqwlNuvK2Op4m9xNb+jeRFyxXa3U4Z\nSFfd4IASojxR9O7Jmpo1jvjrXEfEjdebJ83lZABVdfc6P+RVRAjfRcGARzmk\nmNEF78dEU4Ij1brWh/e66UEWZNHZIhyw3vQd01uc81hy/Zbbu1zTQ3d/1Jd1\nQ5/5JPmnylZN/QBWdXottoOTIgHW5viYPC/x3rjXNkU2cTj4uQlnAV56iqkn\ne913QtpuVd1LgKfmWZUPAXtFvwVfuTkcd7bkM4b22fvwtrii5KTKDWfVpqj+\nthIgbR4uYAaqEIVsYshtjbp6LV2ir9W5S0rwZs4hICbTuegt5mRtgnyEAfeb\nLRuKgqMN3wRA9RSThq51EfXlMrLwFwBrJjqvjWSPbUnDTMkr6LQCYMXMBJai\nxIcz\r\n=0Yao\r\n-----END PGP SIGNATURE-----\r\n"},"main":"lib/loader.cjs","type":"module","engines":{"node":">=14.0.0"},"gitHead":"6ad5a7926f8e46943ff8f58dd1d8b90a268b433e","scripts":{"lint":"eslint --ignore-path .gitignore lib test --ext js,cjs","test":"nyc ava","posttest":"npm run lint"},"_npmUser":{"name":"jhnns","email":"mail@johannesewald.de"},"repository":{"url":"git+https://github.com/peerigon/inspect-loader.git","type":"git"},"_npmVersion":"6.14.11","description":"Webpack loader designed for loader testing and debugging. Calls a function with the received input.","directories":{},"_nodeVersion":"14.16.0","dependencies":{"loader-utils":"^2.0.0"},"_hasShrinkwrap":false,"devDependencies":{"ava":"^3.15.0","nyc":"^15.1.0","eslint":"^7.23.0","webpack":"^5.30.0","eslint-plugin-jsdoc":"^32.3.0","eslint-config-peerigon":"^30.0.2"},"_npmOperationalInternal":{"tmp":"tmp/inspect-loader_2.0.0_1617630051560_0.9790572802078619","host":"s3://npm-registry-packages"}}},"time":{"created":"2017-03-10T18:17:10.344Z","modified":"2026-05-26T11:05:43.606Z","1.0.0":"2017-03-10T18:17:10.344Z","2.0.0":"2021-04-05T13:40:51.714Z"},"bugs":{"url":"https://github.com/peerigon/inspect-loader/issues"},"author":{"name":"developers@peerigon.com"},"license":"Unlicense","homepage":"https://github.com/peerigon/inspect-loader#readme","keywords":["webpack","loader","test","testing","debug"],"repository":{"url":"git+https://github.com/peerigon/inspect-loader.git","type":"git"},"description":"Webpack loader designed for loader testing and debugging. Calls a function with the received input.","maintainers":[{"email":"hello@peerigon.com","name":"peeri"}],"readme":"[![npm][npm]][npm-url]\n[![node][node]][node-url]\n[![npm-stats][npm-stats]][npm-url]\n[![deps][deps]][deps-url]\n[![travis][travis]][travis-url]\n[![appveyor][appveyor]][appveyor-url]\n[![coverage][coverage]][coverage-url]\n\n<div align=\"center\">\n  <a href=\"https://github.com/webpack/webpack\">\n    <img width=\"200\" height=\"200\"\n      src=\"https://webpack.js.org/assets/icon-square-big.svg\">\n  </a>\n</div>\n\n<h1 align=\"center\">inspect-loader</h1>\n\n<p align=\"center\">Webpack loader designed for loader testing and debugging. Calls a function with the received input.</p>\n\n\n<h2 align=\"center\">Install</h2>\n\n```bash\nnpm install --save-dev inspect-loader\n```\n\n<h2 align=\"center\">Example</h2>\n\nPut the **inspect-loader** in front of the loader you want to test and pass in a callback function. The callback function will be called with useful information about the given inputs (`arguments`). It also exposes the internal loader context for further inspection:\n\n```js\nwebpack({\n    ...\n    module: {\n        rules: [{\n            test: /\\.js$/,\n            use: [{\n                loader: \"inspect-loader\",\n                options: {\n                    callback(inspect) {\n                         console.log(inspect.arguments);\n                         console.log(inspect.context);\n                         console.log(inspect.options);\n                    }\n                }\n            }, {\n                loader: \"my-loader\" // loader that you want to test/debug\n            }]\n        }]\n    }\n});\n```\n\nThe loader returns the received arguments, which means that you can place the **inspect-loader** in the middle of your loader pipeline. You can even inspect multiple loaders:\n\n```js\nwebpack({\n    ...\n            use: [{\n                loader: \"inspect-loader\",\n                options: {\n                    callback: inspectALoader\n                }\n            }, {\n                loader: \"a-loader\"\n            }, {\n                loader: \"inspect-loader\",\n                options: {\n                    callback: inspectBLoader\n                }\n            }, {\n                loader: \"b-loader\"\n            }]\n    ...\n});\n```\n\n### Raw\n\nThis package exposes also a raw version that can be used to test [raw loaders](https://webpack.js.org/api/loaders/#-raw-loader):\n\n```js\nwebpack({\n    ...\n    module: {\n        rules: [{\n            test: /\\.js$/,\n            use: [{\n                loader: \"inspect-loader/raw\",\n                options: {\n                    callback(inspect) {\n                         console.log(inspect.arguments[0] instanceof Buffer); // true\n                    }\n                }\n            }, {\n                loader: \"my-raw-loader\" // raw loader that you want to test/debug\n            }]\n        }]\n    }\n});\n```\n\n<h2 align=\"center\">Options</h2>\n\n### `callback: Function | string`\n\nCan be a `Function` (preferred) or a `string`. In case it's a string, it is treated as a string reference and will be invoked on the `inspectLoader.callbacks` object like this:\n\n```js\nconst inspectLoader = require(\"inspect-loader\");\n\ninspectLoader.callbacks.myCallback = function () { ... };\n\nwebpack({\n    ...\n                loader: \"inspect-loader\",\n                options: {\n                    callback: \"myCallback\"\n                }\n    ...\n});\n```\n\n\nThe callback passes an `inspect` object as single argument that exposes the internal loader state:\n\n```js\n{\n    arguments, // A true array that carries all the input arguments that were passed to the loader\n    context, // A reference to the loaderContext of the inspect-loader\n    options // A reference to the options object of the inspect-loader\n}\n```\n\n```js\nfunction callback(inspect) {\n    console.log(inspect.arguments); // [\"loader contents from the previous loader\"]\n    console.log(inspect.context); // { resource: \"...\", ... }\n    console.log(inspect.options); // { callback: [Function] }\n}\n```\n\n**Please note:** `context` and `options` are *not* references to the `loaderContext` of the loader you want to test. They just expose the internal state of the **inspect-loader**. This is useful if you have multiple callbacks and you want to find out which resource or loader pipeline has been invoked.\n\n<h2 align=\"center\">Usage</h2>\n\n### Assertions\n\nMost of the time, you will probably want to do assertions on the `inspect` object. It is recommended to do this *after* the webpack compilation has finished, because otherwise the assertion error will be caught by webpack and reported as `Module build error`.\n\nNot so good:\n\n```js\n    ...\n    loader: \"inspect-loader\",\n    options: {\n        callback(inspect) {\n            // assertion errors will be caught as Module build error\n            assert.deepEqual(inspect.arguments, [...])\n        }\n    }\n    ...\n```\n\nBetter:\n\n```js\nlet args;\n\nwebpack({\n    ...\n    loader: \"inspect-loader\",\n    options: {\n        callback(inspect) {\n            args = inspect.arguments;\n        }\n    }\n    ...\n}, (err, stats) => {\n    ...\n    assert.deepEqual(args, [...])\n});\n    \n```\n\n<h2 align=\"center\">License</h2>\nUnlicense\n\n<h2 align=\"center\">Sponsors</h2>\n\n[<img src=\"https://assets.peerigon.com/peerigon/logo/peerigon-logo-flat-spinat.png\" width=\"150\" />](https://peerigon.com)\n\n[npm]: https://img.shields.io/npm/v/inspect-loader.svg\n[npm-stats]: https://img.shields.io/npm/dm/inspect-loader.svg\n[npm-url]: https://npmjs.com/package/inspect-loader\n\n[node]: https://img.shields.io/node/v/inspect-loader.svg\n[node-url]: https://nodejs.org\n\n[deps]: https://david-dm.org/peerigon/inspect-loader.svg\n[deps-url]: https://david-dm.org/peerigon/inspect-loader\n\n[travis]: http://img.shields.io/travis/peerigon/inspect-loader.svg\n[travis-url]: https://travis-ci.org/peerigon/inspect-loader\n\n[appveyor-url]: https://ci.appveyor.com/project/jhnns/inspect-loader/branch/master\n[appveyor]: https://ci.appveyor.com/api/projects/status/github/peerigon/inspect-loader?svg=true\n\n[coverage]: https://img.shields.io/codecov/c/github/peerigon/inspect-loader.svg\n[coverage-url]: https://codecov.io/gh/peerigon/inspect-loader\n\n[chat]: https://badges.gitter.im/peerigon/webpack.svg\n[chat-url]: https://gitter.im/peerigon/webpack\n","readmeFilename":"README.md","users":{"nickgogan":true}}