sstephenson/sprockets — Issue #240: undefined method `dependency_paths` for `Sprockets::StaticAsset`
Author: sinisterchipmunk
Created: 2011-11-07 02:52:30+00:00
State: open

Part of a library I'm working on includes a directive processor (which inherits from `Sprockets::DirectiveProcessor` itself). What the processor does, essentially, is recursively require certain paths similarly to `require_tree`, except that it brings in matching paths regardless of where they appear (gems, Rails plugins, etc). During this process, it calls `context.depend_on` for all of the files matching a glob pattern.

The `undefined method` error is raised when the glob pattern ignores file extensions and thus all files matching the glob are marked as dependencies, regardless of their type. Thus, a javascript file (for example) can potentially depend on a `StaticAsset`.

Now, this sort of approach is probably bad form and I probably need to be more selective in terms of file extension (or at the very least, mime type).

However, I am wondering if the error it is raising isn't legitimate. It comes down to this: can a `BundledAsset` never depend upon a `StaticAsset`?

My understanding of the difference between `StaticAsset` and `BundledAsset` is basically that static assets have a file extension Sprockets doesn't have a server-side processor for. (Is this a true statement? Are there any other differences?) If this is indeed the only difference, then unilaterally assuming that a processed file can never depend upon an un-processed file seems unsafe to me, though I don't currently have a use case to back this up.