Closed clmath closed 9 years ago
I submitted PR #8.
But @clmath, I'm stuck on the build. When I do a build, grunt-amd-build executes the code in each module (technically, it executes each modules' factory), and fails on https://github.com/jquery/jquery/blob/master/src/core.js because it accesses window
which isn't defined in Node.
IIRC this is why r.js doesn't actually execute the code in the modules being included into a build, but you took a different route. So, what should we do? The possibilities I can think of are:
exclude
directive so that grunt-amd-build doesn't try to roll jquery into the build. Rather, require that the app manually load jquery.js via a <script>
tag. I don't like that solution because it goes against the main goal of AMD: granular dependencies.includeShallow
directive. This is a bad solution too because the developer has to manually list which jquery modules are required.What do you think?
PS: Why is grunt-amd-build executing that factory anyway? Why not just look at the dependencies listed as the first argument to the define()
function?
There is a much simpler solution:
load: function (resource, req, onLoad, config) {
/* global jQuery */
/* global $ */
if (config.isBuild) {
onLoad();
} else if (typeof jQuery !== "undefined") {
onLoad(jQuery);
} else if (typeof $ !== "undefined") {
onLoad($);
} else {
require(getModules(resource), function ($) {
onLoad($);
});
}
}
For more information you can look at http://requirejs.org/docs/plugins.html#apiload, especially the Build considerations. (grunt-amd-build follow the same api)
Created the issue to track progress and have it in the release milestone.