You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
requirish is a tool for avoiding the ../../../ relative paths problem and includes a
browserify-transform to rewrites the require() for browser.
You can use it both for your application and also if you are writing a library that could be referenced by others as dependency!
Installation
$ npm install --save requirish
Usage
In the code, before other require() calls:
require('requirish')._(module);
...
As a browserify-transform:
$ browserify -t requirish app.js > bundle.js
Example
Developing a not trivial Node.js application/library you will face a lot of annoying relative paths in
your require() as soon as you start creating a module hierarchy under your ./lib source folder.
Your application, in this example, could have a 'jet.js' module like the following:
$ /Users/bob/my-app/lib/gui/controller/jet.js
and the relative unit-test with the following path:
Fine! We will be happy to have now a path-decoupled require() but.. browserify will stop to resolve this new smart version!
And here requirish comes again to the rescue and transforms automagically all the smart require() in the previous
../../../ long version only for the browserify processor!
So, you could run the following browserify command adding the transform: