Skip to content

hughsk/require-key

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

A browserify transform that inlines required values from JSON files.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published