CoffeeScript Compilation

23 views
Skip to first unread message

Matthew Browne

unread,
Jun 14, 2015, 7:55:58 PM6/14/15
to der...@googlegroups.com
Hi,
Could someone confirm whether I have a correct understanding of the CoffeeScript compilation in Derby? I noticed that 'coffee-script/register' is used, which I think does on-the-fly compilation. Doesn't that meant that all the CoffeeScript files have to be compiled every time you start the server? If so, is this considered OK for an app running in production?

BTW, I'm actually asking the question not because I want to use CoffeeScript but because I want to use Babel (at least for my server-only routes), and I thought it would make sense to use Derby's current conventions for CoffeeScript as a model.

Thanks,
Matt

Nate Smith

unread,
Jun 15, 2015, 6:13:48 PM6/15/15
to der...@googlegroups.com
'coffee-script/register' extends require to support loading files with the .coffee extension. It does in fact require lazy compilation at startup if used in production. This is really handy in development, but I don't recommend this strategy for production use.

At Lever, we use coffee for internal development and JavaScript ES5 for open source development. We may switch to Babel in the future, now that it supports most of the features that were our original reason for using Coffee.

In dev, we run our app with the coffee command. In production, we use docker to create an image and compile from Coffee to JS at build time, so we don't include coffee-script/register in prod.

--
You received this message because you are subscribed to the Google Groups "Derby" group.
To unsubscribe from this group and stop receiving emails from it, send an email to derbyjs+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Matthew Browne

unread,
Jun 15, 2015, 7:48:09 PM6/15/15
to der...@googlegroups.com
Thanks, that's good to know. I'm the sole developer on my Derby app so I think it might be simpler in my case to just add a "compile" script to my package.json...maybe put my sources in a 'src' directory and have it output to a 'lib' directory, like CoffeeScript in Derby 0.5. It would be nice to have that step integrated into a deployment solution; I'm evaluating this deployment tool: https://github.com/pstadler/flightplan. I'm just musing here; no need to reply unless you have an alternative suggestion.

BTW, for those interested in a possible successor to CoffeeScript with support for ES6 features (and at least one ES7 feature, async/await), check out this new language: http://breuleux.github.io/earl-grey/. Personally Babel is more my style but those who like CoffeeScript may like Earl Grey as well.

Thanks again,
Matt
You received this message because you are subscribed to a topic in the Google Groups "Derby" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/derbyjs/o1Jue19WbQ8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to derbyjs+u...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages