namespaceify
v1.0.5
Published
namespace local directories for easy and portable requires
Downloads
11
Maintainers
Readme
namespaceify
Browserify transform to namespace local directories for cleaner requires
usage
Use it as a browserify transform and give it a list of namespaces to transform into local requires!
"transform": [
["namespaceify", {"namespaces": {"components": "./lib/components"}}]
]
options
namespaces
(required) an object mapping "module names" to local directories.aliases
(optional) an array specifying aliases forrequire
to also transform, defaults to['require']
.extensions
(optional) an array specifying extensions to parse, defaults to['js']
.dir
(optional) a directory to consider the "root", defaults to CWD
example
consider the above example mapping "components" to "./lib/components". this allows you to turn:
// lib/pages/reports/user-reports.js
const calendarComponent = require('../../components/calendar')
...into:
const calendarComponent = require('components/calendar')
much cleaner! and far more portable!
alternatives
if namespaceify doesn't tickle your fancy, or you just simply don't need all of the flexibility it provides, here are some other great options for doing something similar:
license
MIT