New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Specify Ruby files order through magic comments #3748
base: master
Are you sure you want to change the base?
Conversation
I agree that this is an annoying problem. I actually fall several times over this. Yet I don't like the magic comment. The load specific config file on the other side I like. |
Well, you can already use conf.rbfiles = Dir["#{conf.dir}/mrblib/utils/**/*.rb"] + Dir["#{conf.dir}/mrblib/zzz.rb"] in the gemspec. As long as your files are still placed in the mrblib/ folder this should make sure that the files are loaded in the given order. I had a similar problem with my gem where I did this. |
I prefer magic comment. I care about maintainability. |
Ok. If we are going with magic comments, how they should work? Current implementation ideologically works similar to MRI magic comments (at least, Not sure what to add/remove/improve. |
01ce44b
to
5cf70f4
Compare
e41ee66
to
936babb
Compare
936babb
to
4daa4ae
Compare
Update:
|
馃啓 Hey everyone! Are we still interested in this feature? Maybe it's time to re-visit it? |
Disclaimer
I marked this PR as Experimental to emphasize that it's the main purpose is to discuss the problem (or this is not a problem at all?).
The problem
Currently, Ruby files are loaded and compiled in lexicographical order. Thus we have to use such tricks as using file prefixes just to control this (even in mruby core). And that's an example from my lib (which inspired me to write this).
So, there is no way (other then naming hacks) to specify dependencies (usually we need it when using modules with shared logic).
The Idea
I was thinking of how to tell the builder to compile Ruby files in the specified order and came up with the following idea: let's use magic comments to declare dependencies:
Looks like Sprockets 馃槒
Pros: easy to use/read, backward-compatible.
Cons: that differs from Ruby.
Other ideas
Another option I see is to specify the build order hints somewhere in config:
Pros: no language changes.
Cons: harder to maintain (maybe, that's OK for mRuby libs, 'cause they're usually not too big).