fijimunkii / node-shim-require

Pre-process javascript files as they get required

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

shim-require

Pre-process javascript files as they get required

const shimRequire = require('shim-require');
shimRequire((content, filename) => {
  // return modified content
  return `console.log("loading ${filename}");\n${content}`;
});

require('foo'); // `loading /path/to/foo`

Can also modify json files

shimRequire(content => content.replace(/foo/g, 'bar'), 'json');
require('foo.json'); // { "a": "bar" }

About

Pre-process javascript files as they get required


Languages

Language:JavaScript 100.0%