tkellen / requirejs-library-skeleton

RequireJS / Jasmine / r.js / almond skeleton for javascript libraries and modules.
MIT License
85 stars 12 forks source link

failing spec - coffeescript should be automatically transpiled #4

Closed carloman closed 12 years ago

carloman commented 12 years ago

fantastic project....I've been struggling trying to get coffeescript / require.js / and jasmine to work together...this seems the cleanest solution I've seen so far--Thanks for putting this together!....I am however getting a failing spec in cs.js and I'm not really sure what kicks off the coffeescript compiler....Did I miss a step somewhere?...

full error: TypeError: Property 'coffeescript' of object # is not a function at null. (file://localhost/Users/carloman/Documents/workspace/jasmine-require-skeleton/test/spec/cs.js:8:23)

tkellen commented 12 years ago

Hey Carl! Can you tell me how you're getting this error?

If you check the project out and run servedir ./ & in the root, you should be able to run the tests by going to http://localhost:8000/test/runner.html.

The coffeescript compiler is implemented as RequireJS plugin (https://github.com/jrburke/require-cs). The standard configuration is to load your modules with the plugin prefix cs!

Does that help?

carloman commented 12 years ago

ah...servedir was the missing piece! Installed it and it works like a champ. thank you.

I really like the pattern of having the skeleton.js module/object with properties that are themselves modules....I haven't seen that before--really nice, just the one module to load.

Do you ever find mixing .coffee sources and .js in the same directory leads to any confusion or issues? I'm about to undertake a scala play application where that framework has built-in coffeescript support but puts the compiled coffeescript in a separate 'managed dependencies' directory. I'm wondering given your build script and runners if that is even a benefit, since you can test and deploy the .coffee and .js interchangeably from the same directory.....does that make sense?....ie. adding a paths property that points to the 'managed dependencies' directory with the compiled coffeescript?...or... just use the require-cs plugin and point to coffee sources directly as you've done. Would appreciate any thoughts on the matter....

cheers, Carl

tkellen commented 12 years ago

Personally, I wouldn't mix javascript and coffeescript within a single library. The inclusion of CS in this repository was mostly to show how easy RequireJS makes it to use coffeescript.

I use this skeleton for making stand-alone, general-use utilities that are built and included in my apps similarly to how you would include jQuery/Underscore in a project (ie: a built file with a specific version). That said, if you are going full-stack AMD with RequireJS optimizing your entire application, it wouldn't hurt to let RequireJS build your libraries right along with the app.