volojs / create-template

The sample single page app project template, uses RequireJS
416 stars 364 forks source link

"modules" property #8

Open ORESoftware opened 7 years ago

ORESoftware commented 7 years ago

@jrburke

to this day, I still don't understand what the "modules" property does here:

https://github.com/volojs/create-template/blob/master/tools/build.js

what is the difference between modules produced by the optimizer and bundles produced by the optimizer?

ORESoftware commented 7 years ago

I did my HW and cloned the repo and ran the optimizer, it produces this for app.js in the www-built dir:


define("app/messages", [], function () {
    return {
        getHello: function () {
            return "Hello World"
        }
    }
}), define("print", [], function () {
    return function (e) {
        console.log(e)
    }
}), define("app/main", ["require", "./messages", "print"], function (e) {
    var n = e("./messages"), i = e("print");
    i(n.getHello())
}), requirejs.config({baseUrl: "lib", paths: {app: "../app"}}), requirejs(["app/main"]), 

    define("app", function () {
});

I love it, it's dead f-ing simple. But what I don't understand is - what is the empty app modules for:

    define("app", function () {
    });

that makes no sense to have that

and I still don't know what the modules property does vs. bundles. TMK bundles is a newer feature than modules but I am not even sure if they are comparable.