cloverfield-tools / universal-react-boilerplate

A simple boilerplate Node app.
MIT License
904 stars 97 forks source link

rootrequire + browserify? #18

Closed serapath closed 9 years ago

serapath commented 9 years ago

rootrequire would not work with browserify, right?

What about a special app/node_modules/config.js module, that deals with everything that has to be required using a relative paths?

// app/node_modules/lib/config.js
module.exports = {
    package: require('../../package.json'),
    // add other stuff if necessary
};

Then use a browserify transform like require-key in order to save some bits and bytes in case not all the content of config.js is used inside the app. If I need information from package.json my file might include:

var version = require('lib/config').package.version;
// ...

Using that technique, "rootrequire" might not be necessary anymore and could be removed in readme.md and as a dependency from the project.

nkbt commented 9 years ago

Won't be relevant with #10