require-copy

require() a copy of your module, so modifications don't pullute the global namespace

Usage no npm install needed!

<script type="module">
  import requireCopy from 'https://cdn.skypack.dev/require-copy';
</script>

README

require-copy

Sets up a global require hook extension that allows you to require deep copies of objects, so modifications can't pollute the global scope.

Installation

npm install require-copy

Usage

Setting up the hook (in one place at the top of your app)

require('require-copy');

Using the extension

var someData = require.extensions.copy('../some/file.json');