Dependency management

26 views
Skip to first unread message

chriss...@gmail.com

unread,
Jun 28, 2013, 9:01:49 AM6/28/13
to ja...@googlegroups.com
Hello,

I just recently discovered jam.js and really like the whole concept. I come from the Rails world and the idea of having a tool like rubygems to manage dependencies between client-side javascript libraries is really attractive.

I've already been using requirejs for a while so I understand the basics, but I was confused to see that dependency management did not seem to work for shimmed libraries as I would have expected it to.

After installing jam via npm, I installed jquery, underscore and backbone. As expected, at this point when I inspected the require.config.js file I found the following shim:

    "shim": {
        "backbone": {
            "deps": [
                "underscore",
                "jquery"
            ],
            "exports": "Backbone"
        },
        "underscore": {
            "exports": "_"
        }
    }

So far so good, but when I then install backbone-relational, and then bootstrap, I find that the shim section of the config remains unchanged -- despite the fact that backbone-relational is clearly dependent on backbone, and bootstrap is clearly dependent on jquery (as indicated in their respective package.json files).

What I'm wondering is: if jam is clearly aware of these dependencies, why is the shim section of require.js.config (and require.js) not being updated correctly when I install them? Is this not the expected behaviour, or am I misunderstanding something here?

Any help would be much appreciated, thanks!

Chris Salzberg

chriss...@gmail.com

unread,
Jun 28, 2013, 8:25:20 PM6/28/13
to ja...@googlegroups.com
Ah, I now see the difference: backbone has a shim section in its package.json, which is copied into require.config.js and require.js.

I'm curious, why does jam not just create a default shim based on the dependencies, if a shim is necessary? This seems like unnecessary duplication.

Chris
Reply all
Reply to author
Forward
0 new messages