require-key

0.0.0 • Public • Published

require-key experimental

A browserify transform that inlines required values from JSON files.

Usage

require-key

browserify -t require-key index.js > bundle.js

Say you have a JSON file you want to require from your browserify bundle, but you only want to include that one value instead of the whole file as a module. With require-key you can, simply:

var version = require('./package.json').version
var through = require('./package.json').dependencies.through

Then the transform stream will replace those lines with:

var version = "0.0.0"
var through = "~2.3.4"

This works for any JSON file, with any value and any set of keys - provided you require the file and access its properties like shown above. If you try and require a malformed file or access undefined values the stream will throw - that's how Node handles the situation too :)

License

MIT. See LICENSE.md for details.

Readme

Keywords

none

Package Sidebar

Install

npm i require-key

Weekly Downloads

1

Version

0.0.0

License

MIT

Last publish

Collaborators

  • hughsk