Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add fatal next-tick throw as last-ditch AMD plugin error handling. See

…#137. Update to bower 1.x for installing test deps. Update wire/debug to use newer UMD boilerplate.
  • Loading branch information...
commit 84bc2adc1ebe93c0e9f9113ffe30bf1f1e707a1a 1 parent 4a054c7
@briancavalier briancavalier authored
View
2  .gitignore
@@ -1,5 +1,5 @@
node_modules/
-components/
experiments/
.idea/
*~
+bower_components/
View
16 debug.js
@@ -78,8 +78,10 @@
* }
*/
(function(global, define) {
-define(['meld'], function(meld) {
- var timer, defaultTimeout, logger, createTracer, ownProp;
+define(function(require) {
+ var meld, timer, defaultTimeout, logger, createTracer, ownProp;
+
+ meld = require('meld');
function noop() {}
@@ -554,12 +556,6 @@ define(['meld'], function(meld) {
};
});
-})(this, typeof define == 'function'
- // use define for AMD if available
- ? define
- : function(deps, factory) {
- module.exports = factory.apply(this, deps.map(function(x) {
- return require(x);
- }));
- }
+})(this, typeof define == 'function' && define.amd
+ ? define : function(factory) { module.exports = factory(require); }
);
View
2  lib/Container.js
@@ -56,7 +56,7 @@ define(function(require) {
scopeProto._startup,
function(started) {
var self = this;
- return when(started).otherwise(function(e) {
+ return when.resolve(started).otherwise(function(e) {
return self._contextEvent('error', e).yield(started);
});
}
View
4 package.json
@@ -43,7 +43,7 @@
},
"devDependencies": {
"buster": "~0.6",
- "bower": "~0",
+ "bower": "~1",
"gent": "~0.4"
},
"main": "./wire",
@@ -51,7 +51,7 @@
"test": "test"
},
"scripts": {
- "test": "buster test -e node",
+ "test": "buster-test -e node",
"prepublish": "bower install && git submodule update --init"
}
}
View
24 test/test-config.js
@@ -25,11 +25,11 @@
loaders = {
curl: {
- script: 'components/curl/src/curl',
+ script: 'bower_components/curl/src/curl',
mixin: {
apiName: 'require',
paths: {
- jquery: 'components/jquery/jquery'
+ jquery: 'bower_components/jquery/jquery'
},
preloads: [
'poly/es5',
@@ -38,11 +38,11 @@
}
},
requirejs: {
- script: 'components/requirejs/require',
+ script: 'bower_components/requirejs/require',
mixin: {
paths: {
- jquery: 'components/jquery/jquery',
- domReady: 'components/requirejs-domready/domReady'
+ jquery: 'bower_components/jquery/jquery',
+ domReady: 'bower_components/requirejs-domready/domReady'
}
}
}
@@ -93,13 +93,13 @@
// This is needed because we're running unit tests from *within* the wire dir
addPackage({ name: 'wire', location: '.' });
- addPackage({ name: 'meld', location: 'components/meld' });
- addPackage({ name: 'when', location: 'components/when' });
- addPackage({ name: 'poly', location: 'components/poly' });
- addPackage({ name: 'sizzle', location: 'components/sizzle' });
- addPackage({ name: 'dojo', location: 'components/dojo', main: 'main' });
- addPackage({ name: 'dijit', location: 'components/dijit' });
- addPackage({ name: 'jquery', location: 'components/jquery', main: 'jquery' });
+ addPackage({ name: 'meld', location: 'bower_components/meld' });
+ addPackage({ name: 'when', location: 'bower_components/when' });
+ addPackage({ name: 'poly', location: 'bower_components/poly' });
+ addPackage({ name: 'sizzle', location: 'bower_components/sizzle' });
+ addPackage({ name: 'dojo', location: 'bower_components/dojo', main: 'main' });
+ addPackage({ name: 'dijit', location: 'bower_components/dijit' });
+ addPackage({ name: 'jquery', location: 'bower_components/jquery', main: 'jquery' });
// Other loaders may not need this
loaderConfig.paths[loaderName] = loaderPath;
View
22 wire.js
@@ -63,21 +63,25 @@ define(function(require) {
/**
* AMD Loader plugin API
* @param name {String} spec module id, or comma-separated list of module ids
- * @param require {Function} loader-provide local require function
- * @param callback {Function} callback to call when wiring is completed. May have
- * and error property that a function to call to inform the AMD loader of an error.
- * See here: https://groups.google.com/forum/?fromgroups#!topic/amd-implement/u0f161drdJA
+ * @param require {Function} loader-provided local require function
+ * @param done {Function} loader-provided callback to call when wiring
+ * is completed. May have and error property that a function to call to
+ * inform the AMD loader of an error.
+ * See here:
+ * https://groups.google.com/forum/?fromgroups#!topic/amd-implement/u0f161drdJA
*/
- wire.load = function amdLoad(name, require, callback /*, config */) {
+ wire.load = function amdLoad(name, require, done /*, config */) {
// If it's a string, try to split on ',' since it could be a comma-separated
// list of spec module ids
- var errback = callback.error || function(e) {
+ wire(name.split(','), { require: require })
+ .then(done, done.error)
+ .otherwise(crash);
+
+ function crash(e) {
// Throw uncatchable exception for loaders that don't support
// AMD error handling. This will propagate up to the host environment
setTimeout(function() { throw e; }, 0);
- };
-
- wire(name.split(','), { require: require }).then(callback, errback);
+ }
};
/**
Please sign in to comment.
Something went wrong with that request. Please try again.