ch

compile-hook

a tiny, dummy way to add a hook to the Module.prototype._compile method

Showing:

Popularity

Downloads/wk

1

GitHub Stars

9

Maintenance

Last Commit

5yrs ago

Contributors

2

Package

Dependencies

0

Size (min+gzip)

0.3KB

License

MIT

Type Definitions

Tree-Shakeable

No?

Categories

Readme

compile-hook Build Status

a tiny, dummy way to add a hook to the Module.prototype._compile method

#Install

$ npm i -S compile-hook

#Usage

const CompileHook = require('compile-hook');

// place the hook:
CompileHook.placeHook((content, filename, done) => {

    console.log(filename);
    done();
});

// remove the hook
CompileHook.removeHook();

// Place a hook that changes the code on the fly:
CompileHook.placeHook((content, filename, done) => {

    done(content.replace(1492, 622));
});

#GOTCHA

A module that has already been required once will not be hooked again because of the require's cache.

It is possible to remove a module from the cache (remove key in require.cache) and then require it again.

#LICENSE

MIT, see LICENSE file.

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100