This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
It is possible to include in coffeescript file other .coffee files? I think this would increase modularity for large applications? Something like db = require 'baseapp'
I see examples on the web (node.js or rails I think) but it seems not to work in WW. If is not already implemented do you think it would be difficult to include that for the Web Workbench? I know there are javascript modules that permit the same fonctionality at runtime (like require.js) but I'd like to include everything in one file without the runtime dependency. Obvuously a minification after save would be a huge a plus. Thanks |
|
|
I'm not sure whether that's possible. All Web Workbench does is run the CoffeeScript compiler. As far as I know, the CoffeeScript compiler doesn't provide special handling for the require function, so even in Node.js (which is what implements require), the import of the other file would happen at run time, not at compile time. If I'm missing something, let me know -- this certainly would be a nice feature to have. |
|
|
I think that having this feature would be fantastic with the advantage of not having the dependency on node.js. I do not know how Web Workbench is done and and the language used (I imagine c# or f#) but as I understand it parses a file on saving in Visual Studio and calls a built in coffeescript compiler. I think it would not be difficult to parse the .coffee file before calling the compiler. # this is a normal coffescript comment, the comment below is an include directive # include 'foo.coffee" In the coffeescript you could verify if some comments have some kind of special commands like 'include', 'require', or if you want to be more explicit 'webworkbench.include', and then merge the various files before passing it to the compiler.
|
|
|
Interesting suggestion. We'd want to talk to Jeremy Ashkenas before implementing something like this, because it would mean you could create a file that compiled differently under Web Workbench than under the normal CoffeeScript compiler. You're right that it would be a preprocessor rather than a fork to the language itself, but it would still be a difference, and we don't want to be seen as splintering the community. We'll look into it though! |
|
|
+1 for this. I just love the way my .scss files and partials get minified automatically now with Web Workbench. It would be the icing on a bakewell tart if I could do the same for my CoffeeScript files. |
|
|
Hey, I just googled for the exact same functionality as described in this post. Have you guys looked into it yet, any answers? |
|
|
No we have not looked into this as we were hoping this would get included into CoffeeScript directly. I have had it on my list to have a look at integrating something like this though: https://github.com/fairfieldt/coffeescript-concat , so I will try and have a look at that soon. Will let you know once we have an update on this.
|
|
|
We do this already. We are using Spine (Spinejs.com) and it includes Hem and if you do "Hem build" it compiles all the coffescript files etc into a single application.js. This uses node and npm. It's configurable to a certain extent. By default the earlier releases/downloads did not work too well with windows, however the required patches etc are up on github. I have not updated to the latest releases yet. Myles. |
|
|
We do this already. We are using Spine (Spinejs.com) and it includes Hem and if you do "Hem build" it compiles all the coffescript files etc into a single application.js. This uses node and npm. It's configurable to a certain extent. By default the earlier releases/downloads did not work too well with windows, however the required patches etc are up on github. I have not updated to the latest releases yet. Myles. |
|