About data-curl-run

83 views
Skip to first unread message

Johan Chouquet

unread,
Jan 15, 2014, 9:41:24 AM1/15/14
to cuj...@googlegroups.com
Hi again,

I have another question : 

2. I read there https://github.com/cujojs/curl/wiki/Bootstrapping that doing like so worked well :
<script src="lib/curl/src/curl.js" data-curl-run="bundle.js,run.js"></script>
It makes it possible to use bundle.js in PRODUCTION, whereas run.js is used in DEV.

But my need is a little different :
- on my localhost : use run.js (where config for curl would be)
- on tests environnements : use bundle.js (where config for curl would be and app's modules)
- on production : use bundle.min.js
Does that make sense ?

So, I wonder if the following is possible with curl :
<script src="lib/curl/src/curl.js" data-curl-run="bundle.min.js,bundle.js,run.js"></script>
and specify, in the run.js in configuration options :
var cfg = {
local: run,
testEnv: bundle,
prod: {
min: true, // if false, the bundle.js is taken, default = true
}
}
Also, cram.js allows to build the bundle. But how is it that cram and curl can work together ?

Again, thank you very much for the help guys.

Regards,
Johan Chouquet

unscriptable

unread,
Jan 16, 2014, 12:15:22 PM1/16/14
to cuj...@googlegroups.com
Unfortunately, data-curl-run only supports one or two comma-separated files at this point.

Is it possible to name the minified bundle the same as the un-minified bundle?  I've seen people do something like this when there files need to be copied into the production environment.  

A note on Q/A versus Production: some might think it wise to have at least one round of testing with a minified bundle.  Minification tools *often* add bugs!

A note on cram and minification: cram.js does not do minification.  You should use UglifyJS or Closure Compiler after bundling.

Here's a script I use:

#!/bin/sh

# compile.sh
# run a file through google closure compiler

curl
\
   
--data-urlencode "js_code@$1" \
   
-d compilation_level=$2 \
   
-d output_info=compiled_code \
   
-d output_format=text \
    http
://closure-compiler.appspot.com/compile



Also, cram.js allows to build the bundle. But how is it that cram and curl can work together ?

You can `npm install -g cram` (or just `npm install cram` from your project's javascript root, or install it manually from github).  curl.js already comes with cram.js plugins that help it embed things into the bundle.  If you have configured a path or package to curl in your AMD config, cram will find it.  In some cases, you can just do this:

cram index.html

and cram will know what to do.  Of course, that doesn't work all of the time.  :(  cram has some command-line help: `cram --help` that might give you some ideas of other things you can do with it.

-- John

Johan Chouquet

unread,
Jan 21, 2014, 5:54:05 AM1/21/14
to cuj...@googlegroups.com
Hello John,

Thanks for your answer. I'll try cram very soon I think, and will also try your script.

For the bundle, I can have the same name for the minified and un-minified bundle,

About cram, what are the main differences with grunt-concat for example (I use that for the moment) ?

Regards
Johan

unscriptable

unread,
Jan 21, 2014, 2:42:22 PM1/21/14
to cuj...@googlegroups.com
Hello John,

I've never used grunt-concat.  I googled a bit, but found too many things that look like grunt-concat, so I don't know which one you use.  

The question in my mind is: does grunt-concat knows how to create AMD bundles?  If not, you're likely to get errors when trying to use it.

-- John

Johan Chouquet

unread,
Jan 21, 2014, 7:39:07 PM1/21/14
to cuj...@googlegroups.com
Grunt-concat, as I know it, allows to concatenate some files (JS or CSS). It's a plugin for grunt, used before grunt-uglify, for minification. They are grunt tasks, that you can add to your gruntfile, for automating a lot of stuff in your development. I'm not an expert of grunt although.

So, to answer you, grunt-concat doesn't allow you to create modules at all. In my mind, cram.js allowed to do just that. But it seems that it's more than that. I'll look at the docs of the project as soon as I can because I'm very curious about it.

Thanks John for your answer.

Regards,
Johan
Reply all
Reply to author
Forward
0 new messages