mixu / gluejs

Build CommonJS modules for the browser via a chainable API
http://mixu.net/gluejs/
165 stars 13 forks source link

Error: failed to require "undefined" from undefined #23

Closed jeffwillden closed 10 years ago

jeffwillden commented 10 years ago

I'm considering gluejs for a project, rendering to an express/connect response. The 2nd-to-the-last line in the resulting file has myModuleName = require('undefined'); but all the other scripts appear to concatenated in there fine. What am I missing?

app.get('/js/model.js', function(req, res) {
    new Glue()
        .basepath('./model')
        .include('./')
        .export('myModuleName')
        .render(function(err, js) {
            res.setHeader('content-type', 'application/javascript');
            res.send(js);
        });
});
mixu commented 10 years ago

You need to set the main file explicitly, for example: .main('model.js'). This is the file that's going to be the root of the package.

I noticed this was missing from the docs snippet so I'll update it, thanks for reporting!

Edit: .main('model.js')