compile order in sub-directories
Compiler seems to follow alphabetical order instead of folder hierarchy. Please consider the following example:
src/App.coffee src/view/B.coffee src/view/a/A.coffee
Where class A extends B.
Compile with this line:
coffee --join js/app.js --compile src/view/ src/App.coffee
This throws an error in the browser:
Uncaught TypeError: Cannot read property 'prototype' of undefined
If folder a is renamed to z, the error is gone and everything works fine.
Shouldn't the compiler read all files from src/view/ before it moves on to src/view/[sub-dir] ?
I had the same problem. But I think ordering by folder won't fix all the dependency problems.
for example in this case: src/errors/BigError.coffee src/errors/Error.coffee
where BigError extends Error
You will got the same error from the browser. Is there a right solution for that?
@bkris I'm having the same issue, wondering if there is a solution. ie: a way to set a preference in the compile order
+1 This is a minor problem for me, I get around it by using ugly numeric prefixes in filenames
+1 similar to what samuelgbrown does, except the ugly numeric prefixes are used to group files. 00 group files go first and among them order does not matter. The next group prefix is 10, then 20. This also allows files to be inserted between later, e.g 05 prefix for a file that should be put between 00 and 10.
I have a project that solves this problem by using Sprockets-like directives. It allows you to use things like
###
= require 'somefile'
= requireTree 'someDirectory'
= requireself
= require 'someotherfile'
###
And will compile/concat (and optionally compress) in the correct order, resolving all dependencies from included files.
Let me know if there is interest and I'll type of some examples in the README. The project is currently lacking docs but you can (see it here)[https://github.com/caseywebdev/xl8].
This can be resolved using modules, CommonJS, or tools like Gulp or Webpack or Browserify. It is out of scope for the CoffeeScript compiler.