2

I am having no problem with browserification, by the way my module is super simple. Like this:

//sum.js
module.exports = function(a, b){
    return a + b;
}

So I use the command browserify -r ./sum | uglifyjs -c -m --output sum.min.js and everything is ok.

If I copy paste the results in chromes console, the only way I can retrieve the sum module is by doing var sum = require("./sum") which I believe is not that friedly.

I would be happy if I could just var sum = require("sum") (without the './' part).

Is it possible? I cant seem to find anything on browserify docs.

4

1 回答 1

4
browserify -r ./src/HelloWorld.js:hola

然后在客户端代码中简单地:

var hola = require('hola');

在文档和命令行帮助中简要介绍:

--require, -r  A module name or file to bundle.require()
               Optionally use a colon separator to set the target.
于 2013-06-02T03:30:43.467 回答