@blowback/contextify
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

Blowback

Contextify

Creates a contextualized copy of node require

// ./tasks/module1.js
const getContext = require('my-context-module');

module.exports = () => {
  return getContext().myContextValueABC;
};

// index.js
import { Contextify } from 'blowback';
const { prepareRequire } = new Contextify({
  contextModuleName: 'my-context-module',
});

const require = prepareRequire({
  currentDirname: __dirname + '/tasks',
  payload: { myContextValueABC: 'abc321' },
});

const contextified = require('./module1');
console.log(contextified()); // -> abc321

Package Sidebar

Install

npm i @blowback/contextify

Weekly Downloads

2

Version

1.0.2

License

MIT

Unpacked Size

14.6 kB

Total Files

8

Last publish

Collaborators

  • antonio.presto