the state of curl and cram with unwrapped CJS

33 views
Skip to first unread message

Daniel Ji

unread,
Aug 22, 2014, 4:23:56 PM8/22/14
to cuj...@googlegroups.com
Hi,

I've been using require.js and r.js for development and was looking to switch over to curl/cram and the unwrapped CJS format.

I noticed that one of the docs from 2013 mentioned optimizing CJS modules will be coming soon.


But in the cram release notes  v0.7.5 there was mention of

  • Improve support for i18n and CommonJS modules via curl.js 0.8

So does anyone know if curl/cram and unwrapped CJS is pretty much production ready?  Or are there still some gotchas?

Speaking of gotchas, the 2013 tutorial also mentions an early exporting issue w/ using CJS in the browser.  Is this still true?  Seems like a huge paradigm shift from require/AMD where I know when a module is required in that it is initialized.  At that point, any benefits of being able to use the unwrapped CJS format is negated by having to do conditional checking if a required in module is initialized or not.

Thanks

Daniel Ji

unread,
Aug 22, 2014, 4:30:12 PM8/22/14
to cuj...@googlegroups.com
Oh so I found the other (possibly out of date article) that led me to asking the question of the 'production ready' state of curl/cram with unwrapped CJS.


But the article is from 2012.

unscriptable

unread,
Aug 22, 2014, 4:54:14 PM8/22/14
to cuj...@googlegroups.com
Hey Daniel,

The cjsm11 support was completed quite a while ago.  However, there's a hard-to-repro bug in curl.js that causes problems for *some people*.  My current suspicion is that it depends on the circular dependency pattern used in the code.  If your code relies on the semantics of sync require() and parallel factory execution (node's require() semantics), that might cause the problem.  curl.js follows the original CommonJS spec, not node's "specs" (which also handle CommonJS's semantics).   

We're focusing our modules efforts on rave these days.  Therefore, I think it's unlikely we'll fix this bug in curl.  

Rave doesn't yet handle circular dependencies, but when it does, it will use node's semantics. 

Have you looked at rave?  https://github.com/RaveJS/rave

-- John

Daniel Ji

unread,
Aug 22, 2014, 5:14:45 PM8/22/14
to cuj...@googlegroups.com
Hi John,

Thanks for the update.  I don't think I'll need the circular dependency feature of curl/cram with CJS.  I don't think circular deps is supported in AMD.  If I did need it, then I found ways around it.  So on that front I should be good.

I checked out your youtube presentation of ravejs a while ago.  It sounds super promising and I agree with what the project is trying to do.  I hope it works out.

We're focusing our modules efforts on rave these days.  

rave has it's own module loader?  What's the difference b/t rave and curl as far as module loading?  Where can I find more info on that?

Thanks.

Adam Jorgensen

unread,
Aug 23, 2014, 5:47:48 AM8/23/14
to cuj...@googlegroups.com
Circular dependencies are often a bad thing in general and indicative of design issues. Obviously, this is not always true but in many cases it is :-)


--
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/ab548332-f058-45ae-b5ee-baebf3220ebb%40googlegroups.com.

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

unscriptable

unread,
Aug 25, 2014, 9:55:09 PM8/25/14
to cuj...@googlegroups.com
Hey Daniel,

rave has it's own module loader?  What's the difference b/t rave and curl as far as module loading?  Where can I find more info on that?

Rave uses the es6-module-loader[1] project for its loader.  That loader is based off of the proposed ES6 Loader spec being developed by the TC39 team.  Coincidentally, some parts of it look a lot like what I was working on as a successor to curl.js, anyways.  

That said, I have some disagreements with the TC39 folks who are designing the official ES6 Loader spec, but hopefully they'll eventually fix the inherent performance and scalability problems it currently has.

The biggest difference is that the ES6 Loader will prefer the forthcoming ES6 module format.  The existing ES5 formats (AMD, node) can be adapted, as can future translated/transpiled languages, but must be accommodated via "loader hook overrides".  Rave comes with some essential loader hook overrides for AMD, node, and global scripts and allows easy installation of other overrides for CSS, text/html, json, etc.[2]

Another difference is size.  Rave is way bigger than curl because rave is more complex and uses es6-module-loader, which isn't very efficient and comes with a lot of baggage atm.  (Guy has actually made it possible to use parts of es6-module-loader, but we haven't taken advantage of that feature, yet.)

Once rave has a decent feature set, we can start working on its size and speed.

-- John

Reply all
Reply to author
Forward
0 new messages