Skip to content

"Random" include order. #86

@myrne

Description

@myrne

First of all, thanks for this two great ports, snockets and connect-assets. Given the fondness I developed for the Rails asset pipeline, your two projects have greatly contributed to enabling me to completely switch to node.js for the app that I'm developing.

Note that this is probably an Snockets issue but I only got experience using connect-assets. I haven't felt a need to try to "drive" Snockets myself.

I'm not sure this can be considered a bug, otherwise it can be read as a feature request:

When trying to deploy an app with some interdependent assets (e.g. some files contain subclasses of class defined elsewhere) to Heroku I noticed that on Heroku, the "include order" for files inside the same directory resulting from require_tree (probably #= require_dir too) is more or less random, while on OS X Lion it seems alphabetical. Adding explicit require statements inside the files (i.e. doing #= require "./abstract" before doing class Implementation extends Abstract doesn't seem to help. See issue #87.

Rather, I'd be greatly helped if files inside a directory would be included in alphabetical order. First of all this would - by happy coincidence - solve two very common names for dependencies: "abstract" and "base". Adding a file named ".coffee" to a problematic directory would help resolve any other problems, because Snockets will include all dependencies listed in the "" file before/above the "_" file, which would otherwise be the first included of that entire directory.

Other than that, having a "deterministic" include order (given a particular tree of assets) would help prevent "surprises" at deploy time. :)

I'll probably fix this myself by putting in more explicit require instructions in my main "application.coffee" file, but I'd rather keep this kind of rules inside the scope where they belong, i.e. at the file or directory-level.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions