1.0.1 • Published 6 years ago

absolute-require-bono v1.0.1

Weekly downloads
7
License
MIT
Repository
github
Last release
6 years ago

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.