runtime-required

runtime-required

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
runtime-required
161.1.02 years ago5 years agoMinified + gzip package size for runtime-required in KB

Readme

runtime-required
!travistravis.svgtravis.link !score-codeclimatescore-codeclimate.svgscore-codeclimate.link !npm-downloadsnpm-downloads.svgnpm.link !npm-versionnpm-version.svgnpm.link !dm-daviddm-david.svgdm-david.link
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-required

Usage

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 of
builtin (node's default modules) module (ones that appear inside the node_modules directory) file (from your own project... or I guess elsewhere on the filesystem)
  • id {string}: the identifier for this module. For module and file types, it will be a fully-resolved file path. For builtin types, 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}"`);
});