1.1.0 • Published 4 years ago
runtime-required v1.1.0
runtime-required
Haven't you ever always needed to know what files are being required by your app? Okay, maybe not always, but once? No? Just me? Fine, move along then. But in case you need it, here's how it all works:
Install
It's in npm, of course:
npm install runtime-requiredUsage
require('runtime-required') → EventEmitter
Yup, you just include it in your project and it exposes an event emitter. There is only a single file event, and it has the following properties:
type{string}: one ofbuiltin(node's default modules)module(ones that appear inside thenode_modulesdirectory)file(from your own project... or I guess elsewhere on the filesystem)
id{string}: the identifier for this module. Formoduleandfiletypes, it will be a fully-resolved file path. Forbuiltintypes, it will be the name of the module.
Example
const required = require('runtime-required');
required.on('file', data => {
console.log(`a ${data.type} module was required at "${data.id}"`);
});