I have a CoffeeScript project (called jAddressParser) that I am hoping to turn into reusable module. Unfortunately I am not overly familiar with how to modularize CoffeeScript for such a purpose, while maintaining sensible interoperability with an existing project.
The project in question parses address strings - no short order, to be sure. However for the purpose of the project I am working on, this strategy should work and it is possible someone else may benefit from it and perhaps others may make some useful contributions. Everybody wins!
So what I have is code laid out in a directory like this:
/
  README.md
  LICENSE
  package.json
  /src
    main.js
    main.coffee
    canada.coffee
    iso3166.js
  /test
  /build
In an ideal world, my workflow would be like this:
Test the above javascript from the command line. I would think Node.js is the most suitable way.
Compile the files in
/srcto a/build/jAddressParser.jsfile. I would think r.js would work well for this.When all is ready, copy the
jAddressParser.jsfrom the/buildto my web project.Include the jAddressParser in my web project with the appropriate
requirejscall (i.e. it would be AMD-ready) e.g.require(['jAddressParser'], -> ...)
Since it seems I have to include the dependencies (lodash, requirejs, require-cs, XRegExp, CoffeeScript) I expect I will do this by putting specific versions in the /lib directory or by using git submodules (though submodules seems to be a bit of overkill for such a small project).
I have never created a reusable CoffeeScript module, and I was essentially unable to find a good reference on how to perform the same for a web-module (there seem to be some decent examples for projects that are node.js-only - thought I would certainly love to see a list of more). I would be quite grateful for any thoughts or references that may shed light on the viability of the proposal above, or how you yourself might go about organizing such a project?