Jam compile command doesn't work well.

17 views
Skip to first unread message

wang zzs

unread,
Feb 13, 2014, 1:40:11 AM2/13/14
to ja...@googlegroups.com
I'm not sure if I'm missing any step, but I just follow the guide from Jam Documentations.
The combined file can be generated, and I found everything is in this file. But when I browse the web page,
It still load each dependency from there own directory. (like jam/jquery/dist/main.js) 

My files are just like following:
-----------------------------------------------------------------------------------------------------------------

Make it easy to find dependencies

If you're specifying individual modules to include in jam's compiled output, you can make it easier to manage by using a single, top-level module for your application. This module should include all the other modules and top-level dependencies you need. Then, when doing jam compile you need only specify this file and Jam will find all the dependencies from there.

myapp/app.js
define('myapp/app', [
  'jquery',
  'myapp/foo'
],
function ($, foo) {

  return {
    init: function () {
      // add you app initialization code here
      // ...
    }
  };

});
index.html
<script src="jam/require.js"></script>
<script>
  require(['myapp/app'], function (app) {
    app.init();
  });
</script>

Then, to include all the immediately required files into a single download, simply do:

$ jam compile -i myapp/app -o output.js

By doing it this way, you can add that command to your build script and not have to update it when your app's dependencies or module structure changes. Instead, you just manage compiled dependencies in myapp/app.js.

John Fawcett

unread,
Feb 14, 2014, 12:43:48 PM2/14/14
to ja...@googlegroups.com
Just make sure you're loading output.js instead of jam/require.js. RequireJS will setup your module names to match the paths they had before build and instead of making an HTTP request when module some-directory/module-name is required, it will see that it already has it in cache.

Ryan Ramage

unread,
Feb 14, 2014, 1:09:31 PM2/14/14
to ja...@googlegroups.com
This is an example of how I setup my index.html page to load the minified version, and then fallback to the unminified version.

wang zzs

unread,
Mar 4, 2014, 11:16:26 PM3/4/14
to ja...@googlegroups.com
Hi sorry for reply late (since these days are so busy)

I've tried to follow your code, but the problem is still the same.

Include the require.js(minified) in the header, it should be the same as 'onload'.
<script type="text/javascript" src="require.js"></script>

And my app.js is inluded here:
  <script type="text/javascript">
    require(['javascripts/app'], function(app){
      app.init();
    });
  </script>

And I use this command to minify: (here not should why need to put public/ before require.js, but it do need)
jam compile --no-license -i javascripts/app -o public/require.js

My folder is:
Public
    jam_modules(folder)
    javascripts(folder)
    require.js

And the browser still load everything from jam_modules. you can find it from the attachment.

Thanks very much.

在 2014年2月15日星期六UTC+8上午2时09分31秒,Ryan Ramage写道:
network.jpg
Reply all
Reply to author
Forward
0 new messages