absolute-require-bono
v1.0.1
Published
Transform your code, and go from using slow laborious relative to using absolute paths relative to your apps root directory. makes finding dependant modules a breeze.
Downloads
3
Maintainers
Readme
absolute-require-bono
Transform your code, and go from using slow laborious relative to using absolute paths relative to your apps root directory. makes finding dependant modules a breeze.
Well i wish it was 2 lines, but getting absolute bin paths for npm was abit of struggle, that and deciding is it programattically acceptable to change babel configs not knowing where they are.
1. Install
$ npm install absolute-require-bono
$ npm install -g jscodeshift
2. Transform from Relative to Absolute paths
$ jscodeshift -t node_modules/absolute-require-bono/codeshift.js src/
where src/
is your projects javascript folder
3. are you using import
with babel?
$ npm install babel-plugin-root-import
and add the following plugin to .babelrc
plugins
"plugins": [
["babel-plugin-root-import", {
"rootPathPrefix": "#"
}]
]
4. add require line at node entry point
// app.js
require('absolute-require-bono')
Done. want to reverse back to realtive paths
$ jscodeshift -t
node_modules/absolute-require-bono/codeshift.js src/ --reverse
that and removing babel config.