Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

4 Commits

Repository files navigation

module-map

Transform module source at require-time.

Installation

> npm install --save module-map

Usage

// ./some/module.jsmodule.exports=function(){return'Hello World'}
// index.jsvarModuleMap=require('module-map')(__dirname)ModuleMap(function(content,filename){// modify the source code!returncontent.replace('Hello World','HELLO WORLD')})// functions are applied in orderModuleMap(function(content,filename){returncontent.replace('HELLO WORLD','HELLO WORLD!')})// elsewhere...varhello=require('./some/module')console.log(hello())// HELLO WORLD!

Caveats

  • Does not work with .json files, or any custom require extension that produces JSON output e.g. require-yaml

License

MIT

About

Chain require-time module source transforms.

Resources

Stars

1 star

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages