Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Make sure only files that are loaded are included in the build, and t…

…hat each mapped file only gets in the build layer one time. Update snapshot of require.js
  • Loading branch information...
commit 4bbdba6fbcf3d21df498b8f465f767ab50b3b5e0 1 parent 4645ced
@jrburke authored
View
42 build/jslib/requirePatch.js
@@ -67,7 +67,7 @@ function (file, pragma, parse) {
buildPathMap: {},
buildFileToModule: {},
buildFilePaths: [],
- loadedFiles: {},
+ pathAdded: {},
modulesWithNames: {},
needsDefine: {},
existingRequireUrl: "",
@@ -233,16 +233,24 @@ function (file, pragma, parse) {
//A plugin.
if (map.prefix) {
- layer.buildFilePaths.push(fullName);
- //For plugins the real path is not knowable, use the name
- //for both module to file and file to module mappings.
- layer.buildPathMap[fullName] = fullName;
- layer.buildFileToModule[fullName] = fullName;
- layer.modulesWithNames[fullName] = true;
+ if (!layer.pathAdded[fullName]) {
+ layer.buildFilePaths.push(fullName);
+ //For plugins the real path is not knowable, use the name
+ //for both module to file and file to module mappings.
+ layer.buildPathMap[fullName] = fullName;
+ layer.buildFileToModule[fullName] = fullName;
+ layer.modulesWithNames[fullName] = true;
+ layer.pathAdded[fullName] = true;
+ }
} else if (map.url) {
- url = normalizeUrlWithBase(context, map.fullName, map.url);
- //Remember the list of dependencies for this layer.
- layer.buildFilePaths.push(url);
+ //If the url has not been added to the layer yet, and it
+ //is from an actual file that was loaded, add it now.
+ if (!layer.pathAdded[url] && layer.buildPathMap[fullName]) {
+ url = normalizeUrlWithBase(context, map.fullName, map.url);
+ //Remember the list of dependencies for this layer.
+ layer.buildFilePaths.push(url);
+ layer.pathAdded[url] = true;
+ }
}
};
@@ -254,17 +262,11 @@ function (file, pragma, parse) {
layer.needsDefine[moduleName] = true;
};
- //Marks the module as part of the loaded set, and puts
- //it in the right position for output in the build layer,
- //since require() already did the dependency checks and should have
- //called this method already for those dependencies.
+ //Marks module has having a name, and optionally executes the
+ //callback, but only if it meets certain criteria.
require.execCb = function (name, cb, args, exports) {
- var url = name && layer.buildPathMap[name];
- if (url && !layer.loadedFiles[url]) {
- layer.loadedFiles[url] = true;
- if (!layer.needsDefine[name]) {
- layer.modulesWithNames[name] = true;
- }
+ if (!layer.needsDefine[name]) {
+ layer.modulesWithNames[name] = true;
}
if (cb.__requireJsBuild || layer.context.needFullExec[name]) {
return cb.apply(exports, args);
View
5 require.js
@@ -1190,6 +1190,11 @@ var requirejs, require, define;
require: function (deps, callback, relModuleMap) {
var moduleName, fullName, moduleMap;
if (typeof deps === "string") {
+ if (isFunction(callback)) {
+ //Invalid call
+ return req.onError(makeError("requireargs", "Invalid require call"));
+ }
+
//Synchronous access to one module. If require.get is
//available (as in the Node adapter), prefer that.
//In this case deps is the moduleName and callback is
View
2  tests/node/canvasTest.js
@@ -5,7 +5,7 @@
/*jslint strict: false */
/*global require: false, console: false */
-var require = require('r');
+var require = require('../../r');
require(['canvas', 'express'], function (Canvas, express) {
var canvas = new Canvas(200, 200),
Please sign in to comment.
Something went wrong with that request. Please try again.