wycats / rake-pipeline-web-filters

MIT License
116 stars 36 forks source link

Resolve relative references in require #14

Closed raghurajah closed 12 years ago

raghurajah commented 12 years ago

Allows relative reference of modules. In ember-views/lib/system/application.js, instead of,

require("ember-views/system/event_dispatcher");
require("ember-views/views/something/something_else");

one could do,

require("./event_dispatcher");
require("../views/something/something_else");

This would help keep the code agnostic of overall package structure and naming.

Not sure if you are accepting pull requests on this repo. But, I thought I could propose things that I found useful.

dudleyf commented 12 years ago

Relative references make a module dependent on the source file's path, but minispade really doesn't care about file layout. Minispade's module id is any string you want it to be; the default module id happens to be based on the file path because that's usually what you want, but minispade itself doesn't care about where your file is. If you want something other than the default, you should modify it by passing in a :module_id_generator proc.

dudleyf commented 12 years ago

Oh, and please do propose things you find useful :)

raghurajah commented 12 years ago

Actually, relative references does not make module dependent on the source file path at all, rather relativeness here is in the context of module_id namespaces. I should have explained that better in my original post. While I agree with you that the module_id can be any random string; as a matter of practicality, there is some level of namespacing involved in any project. I am assuming a "/" separation, but it could be whatever. Maybe I can make that configurable too. The solution I have provided here uses the module_id_generator to navigate up and down the namespaced module_id, not really the source file path.

Does this not make sense?

I just find the current model of having of maintaining dependencies by keeping track of the absolute module_ids, limiting. Hence, the alternative.

raghurajah commented 12 years ago

Nevermind. Even this is better on minispade rather than as a source pre-processing filter.