azproduction / lmd

LMD - JavaScript Module-Assembler for building better web applications :warning: Project is no longer supported :warning:
http://azproduction.ru/lmd/
MIT License
449 stars 27 forks source link

new lmd config option: automatically requires module #175

Closed RohovDmytro closed 10 years ago

RohovDmytro commented 10 years ago
{
 "third_party_module": {
         "path": "vendors/other_module.js",            
         "autoload": true,           
        }
}

Why do we need this?

In some client architectures we might need to require some modules so they will register their event handlers to specific events.

Now I have to manually require this files so when that specific event happens the events handlers will do their job.

So, It would be nice to have a feature to automatically require some modules.

Then:

require("entities/subshop");
var subshops = App.request("subshop:entities");

will be transformed to a much cleaner thing like:

var subshops = App.request("subshop:entities");

because I know: "entities/subshop" module has already been required.

And I won't have to do stuff like:

        require("entities/basket");
        require("entities/footer");
        require("entities/good");
        require("entities/category");
        // modules
        require("apps/footer/footer_app");
        require("apps/about/about_app");
        require("apps/contacts/contacts_app");
        require("apps/goods/goods_app");
        require("apps/delivery/delivery_app");
        require("apps/news/news_app");
        require("apps/basket/basket_app");
        require("apps/subshops/subshops_app");
        require("apps/categories/categories_app");
        require("apps/menu/menu_app");
azproduction commented 10 years ago

It is possible to define "multi module" for jQuery+Plugins and other stuff like that. I think this options suits for your case.

"modules": {
    "main": ["app/*/*_app.js", "your_app_launcher.js"]
}

Here is example and config example

RohovDmytro commented 10 years ago

Nice! Thanks you very much.