After reading dojo-build tag I've found out many problems that people have with customizing the builds, so I've thought of creating the build myself instead. But I wasn't able to find a reference for syntax used while constructing Dojo AMD layers, namely:
require({cache:{"custom/MyModule":function () {
define(["dojo/_base/lang"], function (lang) {
It looks like cache is a map where the module name is key, and the value is function which body is my module file content.
But I don't fully understand the lower part:
}, "*now":function (r) {
r(["dojo/i18n!*preload*custom/nls/all*[\"en\",\"de\",\"ROOT\"]"]);
}}});
This "*now" is also a key, but it seems to have special interprenation. Do I need it in my module? Or it is optional?
define("custom/all", [], 1);
is the last part. As I suppose, it is obligatory to do this define, even if layer module won't be directly referenced anywhere?
After some reverse engineering:
cacheobject contains map of modules, that are defined in-place. Module name is the key, the value is the function that callsdefine(so it's the content of module).*nowis a special keyword, it's absolutely not required, but once it is present, the function mapped under that key is executed with function that can be used to call additionalrequire, for example to load the NLS files.The block
prints:
Function
contextRequireis defined indojo.js.