import-modify
Modify the source of an imported module
Install
$ npm install --save import-modify
Usage
Replace some text
// greet.jsmodule { console;};
const importModify = ; const greet = ; ;//=> 'yo'
Expose a local variable
// greet.jsconst greet = { console;};
const importModify = ; const greet = ; ;//=> 'hello'
API
importModify(moduleId, modify)
moduleId
Type: string
Same as you would use in require()
.
modify(source)
Type: function
Function where you modify the source and return the new one.
License
MIT © Sindre Sorhus