Comparing version 0.13.1 to 0.13.2
@@ -8,3 +8,3 @@ | ||
*/ | ||
/*jshint node:true */ | ||
var Require = require("./require"); | ||
@@ -40,4 +40,5 @@ require("./node"); // patches Require | ||
function findPackage(directory, callback) { | ||
if (directory == PATH.dirname(directory)) | ||
if (directory === PATH.dirname(directory)) { | ||
return callback("Can't find package"); | ||
} | ||
var packageJson = PATH.join(directory, "package.json"); | ||
@@ -87,5 +88,5 @@ FS.stat(packageJson, function (error, stat) { | ||
if (require.main == module) { | ||
if (require.main === module) { | ||
bootstrap(); | ||
} | ||
@@ -33,2 +33,3 @@ (function (global) { | ||
/*jshint -W089 */ | ||
if (!global.preload) { | ||
@@ -46,3 +47,3 @@ for (var id in pending) { | ||
delete pending[id]; | ||
for (var id in pending) { | ||
for (id in pending) { | ||
// this causes the function to exit if there are any remaining | ||
@@ -58,2 +59,3 @@ // scripts loading, on the first iteration. consider it | ||
}; | ||
/*jshint +W089 */ | ||
@@ -114,3 +116,5 @@ // one module loaded for free, for use in require.js, browser.js | ||
for (name in script.dataset) { | ||
params[name] = script.dataset[name]; | ||
if (script.dataset.hasOwnProperty(name)) { | ||
params[name] = script.dataset[name]; | ||
} | ||
} | ||
@@ -120,5 +124,7 @@ } else if (script.attributes) { | ||
letterAfterDash = /-([a-z])/g, | ||
/*jshint -W083 */ | ||
upperCaseChar = function (_, c) { | ||
return c.toUpperCase(); | ||
}; | ||
/*jshint +W083 */ | ||
@@ -253,3 +259,3 @@ for (j = 0; j < script.attributes.length; j++) { | ||
}) | ||
.invoke('async', moduleId) | ||
.invoke('async', moduleId); | ||
}); | ||
@@ -256,0 +262,0 @@ |
@@ -6,3 +6,4 @@ /* <copyright> | ||
</copyright> */ | ||
/*global bootstrap */ | ||
/*global bootstrap,montageDefine:true */ | ||
/*jshint -W015, evil:true, camelcase:false */ | ||
bootstrap("require/browser", function (require) { | ||
@@ -94,6 +95,8 @@ | ||
return function(module) { | ||
if (module.factory || module.text === void 0) | ||
if (module.factory || module.text === void 0) { | ||
return module; | ||
if (config.useScriptInjection) | ||
} | ||
if (config.useScriptInjection) { | ||
throw new Error("Can't use eval."); | ||
} | ||
@@ -123,3 +126,3 @@ // Here we use a couple tricks to make debugging better in various browsers: | ||
module.factory.displayName = displayName; | ||
} | ||
}; | ||
}; | ||
@@ -183,2 +186,3 @@ | ||
.then(function (definition) { | ||
/*jshint -W089 */ | ||
delete definitions[hash][module.id]; | ||
@@ -190,2 +194,3 @@ for (var name in definition) { | ||
module.directory = URL.resolve(location, "."); | ||
/*jshint +W089 */ | ||
}); | ||
@@ -192,0 +197,0 @@ }; |
@@ -1,6 +0,10 @@ | ||
## 0.13.1 | ||
### 0.13.2 | ||
- Use `config.read` to load `package.json` if given to `loadPackage` | ||
### 0.13.1 | ||
- Fix `require.identify` to work with cyclic package dependencies | ||
# 0.13.0 | ||
## 0.13.0 | ||
@@ -12,3 +16,3 @@ - Fix bootstrap stopping if document had finished loading. | ||
## 0.12.14 | ||
### 0.12.14 | ||
@@ -19,7 +23,7 @@ - Fix bug when loading dependencies that use script-injection which are not | ||
## 0.12.13 | ||
### 0.12.13 | ||
- Fix bug in preloading, where isResolved was replaced with isPending in Q 0.9 | ||
## 0.12.12 | ||
### 0.12.12 | ||
@@ -30,3 +34,3 @@ - Fix preloading. Fixes some logic in figuring out whether to issue a script | ||
## 0.12.11 | ||
### 0.12.11 | ||
@@ -38,11 +42,11 @@ - Add injectDependency and injectMapping | ||
## 0.12.10 | ||
### 0.12.10 | ||
- Update Q from v0.9.0 to v0.9.2 | ||
## 0.12.9 | ||
### 0.12.9 | ||
- Update Q from v0.8.12 to v0.9.0 | ||
## 0.12.8 | ||
### 0.12.8 | ||
@@ -52,3 +56,3 @@ - Defer throwing load errors to execution (Fixes #14) | ||
## 0.12.7 | ||
### 0.12.7 | ||
@@ -63,3 +67,3 @@ - Support returned exports in bootstrapping | ||
## 0.12.6 | ||
### 0.12.6 | ||
@@ -66,0 +70,0 @@ - Add support for `production` mode. Currently causes Mr to ignore |
@@ -8,3 +8,3 @@ | ||
*/ | ||
/*jshint node:true */ | ||
var Require = require("./require"); | ||
@@ -104,3 +104,3 @@ var Promise = require("q"); | ||
location: location | ||
} | ||
}; | ||
}; | ||
@@ -129,4 +129,5 @@ }; | ||
Require.findPackagePath = function findPackagePath(directory) { | ||
if (directory == PATH.dirname(directory)) | ||
if (directory === PATH.dirname(directory)) { | ||
return Promise.reject(new Error("Can't find package")); | ||
} | ||
var packageJson = PATH.join(directory, "package.json"); | ||
@@ -157,3 +158,3 @@ return Promise.ninvoke(FS, "stat", packageJson) | ||
id: modulePath | ||
} | ||
}; | ||
}, function (error) { | ||
@@ -160,0 +161,0 @@ throw new Error("Can't find package: " + path); |
{ | ||
"name": "mr", | ||
"version": "0.13.1", | ||
"version": "0.13.2", | ||
"description": "A refresh-only CommonJS module system for browsers, used in Montage", | ||
@@ -15,3 +15,3 @@ "keywords": [ | ||
"scripts": { | ||
"test": "node spec/phantom.js" | ||
"test": "node spec/phantom.js && jshint ." | ||
}, | ||
@@ -35,3 +35,4 @@ "bin": { | ||
"istanbul": "~0.1.34", | ||
"q-io": "~1.6.4" | ||
"q-io": "~1.6.4", | ||
"jshint": "~2.1.4" | ||
}, | ||
@@ -38,0 +39,0 @@ "exclude": [ |
@@ -47,4 +47,5 @@ | ||
if (!this) | ||
if (!this) { | ||
throw new Error("Require does not work in strict mode."); | ||
} | ||
@@ -143,4 +144,5 @@ var globalEval = eval; // reassigning causes eval to not use lexical scope. | ||
// has this all happened before? will it happen again? | ||
if (has(loading, topId)) | ||
if (has(loading, topId)) { | ||
return; // break the cycle of violence. | ||
} | ||
loading[topId] = true; // this has happened before | ||
@@ -239,16 +241,19 @@ return load(topId, viaId) | ||
var location = config.location; | ||
if (require2.location === location) | ||
if (require2.location === location) { | ||
return id2; | ||
} | ||
var internal = !!seen; | ||
seen = seen || {}; | ||
if (has(seen, location)) | ||
if (has(seen, location)) { | ||
return null; // break the cycle of violence. | ||
} | ||
seen[location] = true; | ||
/*jshint -W089 */ | ||
for (var name in config.mappings) { | ||
var mapping = config.mappings[name]; | ||
location = mapping.location; | ||
if (!config.hasPackage(location)) | ||
if (!config.hasPackage(location)) { | ||
continue; | ||
} | ||
var candidate = config.getPackage(location); | ||
@@ -271,2 +276,3 @@ var id1 = candidate.identify(id2, require2, seen); | ||
} | ||
/*jshint +W089 */ | ||
} | ||
@@ -351,3 +357,3 @@ | ||
require.read = Require.read; | ||
require.read = config.read; | ||
@@ -390,3 +396,3 @@ return require; | ||
} | ||
descriptions[location] = Require.read(descriptionLocation) | ||
descriptions[location] = (config.read || Require.read)(descriptionLocation) | ||
.then(function (json) { | ||
@@ -396,3 +402,3 @@ try { | ||
} catch (error) { | ||
error.message = error.message + " in " + JSON.stringify(descriptionLocation) | ||
error.message = error.message + " in " + JSON.stringify(descriptionLocation); | ||
throw error; | ||
@@ -419,4 +425,5 @@ } | ||
dependency = normalizeDependency(dependency, config); | ||
if (!dependency.location) | ||
if (!dependency.location) { | ||
return false; | ||
} | ||
var location = dependency.location; | ||
@@ -505,4 +512,5 @@ return !!loadedPackages[location]; | ||
} | ||
if (!dependency.location) | ||
if (!dependency.location) { | ||
return dependency; // partially completed | ||
} | ||
// make sure the dependency location has a trailing slash so that | ||
@@ -562,2 +570,3 @@ // relative urls will resolve properly | ||
(config.overlays || Require.overlays).forEach(function (engine) { | ||
/*jshint -W089 */ | ||
if (overlay[engine]) { | ||
@@ -569,2 +578,3 @@ var layer = overlay[engine]; | ||
} | ||
/*jshint +W089 */ | ||
}); | ||
@@ -625,4 +635,5 @@ delete description.overlay; | ||
.forEach(function (dependencies) { | ||
if (!dependencies) | ||
if (!dependencies) { | ||
return; | ||
} | ||
Object.keys(dependencies).forEach(function (name) { | ||
@@ -671,2 +682,3 @@ if (!mappings[name]) { | ||
for (var i = 0, ii = source.length; i < ii; i++) { | ||
/*jshint -W035 */ | ||
var part = source[i]; | ||
@@ -681,2 +693,3 @@ if (part === "" || part === ".") { | ||
} | ||
/*jshint +W035 */ | ||
} | ||
@@ -821,2 +834,3 @@ return target.join("/"); | ||
) { | ||
/*jshint -W083 */ | ||
var mapping = mappings[prefix]; | ||
@@ -826,2 +840,3 @@ var rest = id.slice(prefix.length + 1); | ||
.then(function (mappingRequire) { | ||
/*jshint +W083 */ | ||
module.mappingRedirect = rest; | ||
@@ -828,0 +843,0 @@ module.mappingRequire = mappingRequire; |
124169
18
3094
6