cram fails on the seed project?

67 views
Skip to first unread message

Stanislaw Osinski

unread,
Jan 13, 2014, 9:31:19 AM1/13/14
to cuj...@googlegroups.com
Hi,

I was evaluating cujoJS for a new project and I don't seem to be able to get the seed project to compile with cram. Here's what I'm doing (on Windows if that matters):

npm install 
npm install cram
node node_modules\cram app/run.js --root .

warning: grokking "app/run.js": Did not inspect code inside `.then()` callback(s).
`appRoot` is inferred to be "."
`baseUrl` resolved to "e:\repositories\carrotsearch.com\labs\test/"
`output` resolved to "e:\repositories\carrotsearch.com\labs\test/.cram/linked/bundle.js"
Compiling preloads
Compiling poly/all
Compiling poly/object
Compiling poly/string
Compiling poly/date
Compiling poly/array
Compiling poly/function
Compiling poly/json
Compiling poly/xhr
Compiling poly/setImmediate
Compiling poly/lib/_base
Compiling poly/lib/_base
Compiling poly/lib/_base
Compiling poly/lib/_base
Compiling poly/lib/_base
Compiling poly/support/json3
Compiling poly/lib/_base
Compiling modules
Compiling wire/wire!app/main
cram failed:  Object function when(promiseOrValue, onFulfilled, onRejected, onProgress) {
                // Get a trusted promise for the input promiseOrValue, and then
                // register promise handlers
                return resolve(promiseOrValue).then(onFulfilled, onRejected, onProgress);
        } has no method 'promise'
TypeError: Object function when(promiseOrValue, onFulfilled, onRejected, onProgress) {
                // Get a trusted promise for the input promiseOrValue, and then
                // register promise handlers
                return resolve(promiseOrValue).then(onFulfilled, onRejected, onProgress);
        } has no method 'promise'
    at fetchNextSpec (e:\repositories\carrotsearch.com\labs\test\lib\wire\builder\cram.js:84:17)
    at e:\repositories\carrotsearch.com\labs\test\lib\when\unfold.js:28:39
    at Object.then (e:\repositories\carrotsearch.com\labs\test\node_modules\cram\amd_modules\when\when.js:207:55)
    at when (e:\repositories\carrotsearch.com\labs\test\node_modules\cram\amd_modules\when\when.js:59:34)
    at e:\repositories\carrotsearch.com\labs\test\lib\when\unfold.js:27:11
    at Object.then (e:\repositories\carrotsearch.com\labs\test\node_modules\cram\amd_modules\when\when.js:207:55)
    at when (e:\repositories\carrotsearch.com\labs\test\node_modules\cram\amd_modules\when\when.js:59:34)
    at unfold (e:\repositories\carrotsearch.com\labs\test\lib\when\unfold.js:25:10)
    at processSpec (e:\repositories\carrotsearch.com\labs\test\lib\wire\builder\cram.js:76:11)
    at e:\repositories\carrotsearch.com\labs\test\lib\wire\builder\cram.js:62:11

Am I missing anything obvious here?

Thanks,

Staszek

Stanislaw Osinski

unread,
Jan 13, 2014, 9:36:50 AM1/13/14
to cuj...@googlegroups.com
Hi,

As a follow-up, with wire downgraded to 0.9, the bundle generates fine.

Stanislaw

Stanislaw Osinski

unread,
Jan 15, 2014, 10:40:05 AM1/15/14
to cuj...@googlegroups.com
Hi,

After some digging I realized that when I did npm install -g cram, it got installed with the 1.x version of when, which is why the method was missing. Looking at cram's bower.json, it indeed declares dependency on 1.x when -- is that intentional? Bumping when to 2.x (https://github.com/cujojs/cram/issues/37) seems to solve the issue.

Staszek

Stanislaw Osinski

unread,
Jan 15, 2014, 5:19:42 PM1/15/14
to cuj...@googlegroups.com
Hi again,

I'm wading through the process of cramming the seed app and it seems I'm almost there. After fixing a typo in curl's cram/css plugin (https://github.com/cujojs/curl/issues/247), I'm getting an exception like this:

Compiling wire/lib/graph/tarjan
Compiling wire/lib/graph/formatCycles
cram failed:  Cannot read property '0' of undefined
TypeError: Cannot read property '0' of undefined
    at e:\repositories\github.com\cujo\cram\lib\compile.js:184:27
    at Array.forEach (native)
    at fixDepIds (e:\repositories\github.com\cujo\cram\lib\compile.js:179:12)
    at e:\repositories\github.com\cujo\cram\lib\compile.js:76:6
    at Promise.FulfilledPromise._when (e:\repositories\github.com\cujo\cram\amd_modules\when\when.js:439:48)
    at Array.deliver [as 0] (e:\repositories\github.com\cujo\cram\amd_modules\when\when.js:108:7)
    at runHandlers (e:\repositories\github.com\cujo\cram\amd_modules\when\when.js:368:12)
    at Array.5 (e:\repositories\github.com\cujo\cram\amd_modules\when\when.js:130:5)
    at runHandlers (e:\repositories\github.com\cujo\cram\amd_modules\when\when.js:368:12)
    at drainQueue (e:\repositories\github.com\cujo\cram\amd_modules\when\when.js:811:3)

Debugging this is probably beyond my short initial experience with cujo. When I temporarily comment out the offending statement at cram\lib\compile.js:184:27, the bundle builds and runs fine, but I don't think that's the right fix :-)

Thanks,

Staszek

unscriptable

unread,
Jan 15, 2014, 9:18:44 PM1/15/14
to cuj...@googlegroups.com
Hey Stanislaw,

We hadn't tried seed with cram, yet.  Looks like it's time we did! :)

I've found the same issues you have and have worked through them.  I'm looking into this problem now.  Will get back to you soon.

-- John

Stanislaw Osinski

unread,
Jan 16, 2014, 3:55:22 AM1/16/14
to cuj...@googlegroups.com
Hi John,

Thanks for checking this, looking forward to the fix. I think a small starter project that quickly gets the developer through the full stack (including cram) is very likely to increase the adoption among newcomers, such as myself. 

Over the coming weeks I'll be trying to reimplement some of our public demo apps in cujo, so I'll most likely be coming back with more feedback and questions :-)

Thanks,

Stanislaw

unscriptable

unread,
Jan 16, 2014, 11:41:47 AM1/16/14
to cuj...@googlegroups.com, stanisla...@carrotsearch.com
Hey Stanislaw,


On Thursday, January 16, 2014 3:55:22 AM UTC-5, Stanislaw Osinski wrote:
Thanks for checking this, looking forward to the fix. I think a small starter project that quickly gets the developer through the full stack (including cram) is very likely to increase the adoption among newcomers, such as myself. 

It's very early, but I'm working on a solution that would require no AMD configuration (like you see in run.js).  If the timing is right, would you be interested in trying it?

 

Over the coming weeks I'll be trying to reimplement some of our public demo apps in cujo, so I'll most likely be coming back with more feedback and questions :-)

Cool. Do your products export to AMD or CommonJS/node?  Or are they purely globals?

-- John

Stanislaw Osinski

unread,
Jan 16, 2014, 11:51:56 AM1/16/14
to cuj...@googlegroups.com
Hi John,

Thanks for checking this, looking forward to the fix. I think a small starter project that quickly gets the developer through the full stack (including cram) is very likely to increase the adoption among newcomers, such as myself. 

It's very early, but I'm working on a solution that would require no AMD configuration (like you see in run.js).  If the timing is right, would you be interested in trying it?

Absolutely!

 
Over the coming weeks I'll be trying to reimplement some of our public demo apps in cujo, so I'll most likely be coming back with more feedback and questions :-)

Cool. Do your products export to AMD or CommonJS/node?  Or are they purely globals?

The code is pretty dated, it's a Java Servlets + JS, with globals all over. But fortunately it's not that big. That's why I'd be re-implementing the whole thing rather than refactoring. I very much like cujo's emphasis on decomposing things into very small pieces, but then building the consolidated bundle for production is a must.

(If you're curious, the demo app is here: http://search.carrotsearch.com. It's old enough we didn't even bother upgrading the Flash-based visualizations to their HTML5 versions that have been around for a while. It's really high time for the rewrite...)

Staszek

Chris Hafey

unread,
Jan 16, 2014, 5:03:36 PM1/16/14
to cuj...@googlegroups.com, stanisla...@carrotsearch.com
+1 for this issue.  I am also building a prototype for a new project using cujojs and was making good progress until I tried to integrate cram.  Unfortunately cram is blowing up on me when it hits my usage of the css plugin (If I comment out my use of the css plugin, it builds fine).  I am still trying to figure out cram and a small project (like seed) with step by step directions to get it working would be really helpful.   Let me know if there is anything I can do to help and I will - thanks!

Stanislaw Osinski

unread,
Jan 16, 2014, 5:20:56 PM1/16/14
to cuj...@googlegroups.com
Hi Chris,

What error messages are you getting?

Staszek




--
You received this message because you are subscribed to the Google Groups "cujojs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cujojs+un...@googlegroups.com.
To post to this group, send email to cuj...@googlegroups.com.
Visit this group at http://groups.google.com/group/cujojs.
To view this discussion on the web visit https://groups.google.com/d/msgid/cujojs/b31a530d-48f4-48fb-b297-51056ef0960b%40googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.

Chris Hafey

unread,
Jan 16, 2014, 7:23:51 PM1/16/14
to cuj...@googlegroups.com, stanisla...@carrotsearch.com

Here is the dummy module:

define([

    'css!app/app' // comment this out and cram doesn't fail

],function() {

    console.log('Hello World');

})


This is the error from cram:

Compiling modules

Compiling app/main

Compiling curl/plugin/css!app/app

Compiling curl/plugin/style

Compiling curl/plugin/style!app/app

Compiling curl/plugin/style

cram failed:  Cannot read property '0' of undefined

TypeError: Cannot read property '0' of undefined

    at /usr/local/lib/node_modules/cram/lib/compile.js:184:27

Chris Hafey

unread,
Jan 16, 2014, 8:24:27 PM1/16/14
to cuj...@googlegroups.com, stanisla...@carrotsearch.com
Yes so I commented out line 184 of compile.js and the error went away :).  Any idea what the real fix is or what I should do differently?  I also had to apply your GH-36 hack/patch to get it past the baseUrl undefined issue.   

unscriptable

unread,
Jan 16, 2014, 8:49:33 PM1/16/14
to cuj...@googlegroups.com, stanisla...@carrotsearch.com
Hey guys,

I hope to have a fix pushed to master very soon.  Here's the hotfix to line 184 if you can't wait for me! :)


-- John

unscriptable

unread,
Jan 17, 2014, 2:56:11 PM1/17/14
to cuj...@googlegroups.com, stanisla...@carrotsearch.com
As part of the next version of seed, I'm thinking that we should stop fighting bower and just let it install in a folder named "bower_components".  This means the next version will install into a different location.  Just FYI.

Stanislaw Osinski

unread,
Jan 20, 2014, 7:59:08 AM1/20/14
to cuj...@googlegroups.com

As part of the next version of seed, I'm thinking that we should stop fighting bower and just let it install in a folder named "bower_components".  This means the next version will install into a different location.  Just FYI.

Sounds good to me, it should make the layout more familiar for newcomers. Personally, I liked the lib/ alias, so I'll probably stick with it in my code.

Staszek

Reply all
Reply to author
Forward
0 new messages