Permalink
Browse files

Many changes. See changelog for Apr 14, 2010 for more info.

  • Loading branch information...
1 parent c97ab2d commit c29ad4fee012e80ed190c75a5e557da451907e9a @jbrantly committed Apr 14, 2010
Showing with 1,252 additions and 79 deletions.
  1. +50 −19 README
  2. +41 −0 tests/asyncA/index.html
  3. +1 −0 tests/asyncA/tests/absolute/b.js
  4. +9 −0 tests/asyncA/tests/absolute/program.js
  5. +5 −0 tests/asyncA/tests/absolute/submodule/a.js
  6. +15 −0 tests/asyncA/tests/absolute/test.js
  7. +4 −0 tests/asyncA/tests/cyclic/a.js
  8. +4 −0 tests/asyncA/tests/cyclic/b.js
  9. +12 −0 tests/asyncA/tests/cyclic/program.js
  10. +15 −0 tests/asyncA/tests/cyclic/test.js
  11. +10 −0 tests/asyncA/tests/relative/program.js
  12. +5 −0 tests/asyncA/tests/relative/submodule/a.js
  13. +2 −0 tests/asyncA/tests/relative/submodule/b.js
  14. +15 −0 tests/asyncA/tests/relative/test.js
  15. +43 −0 tests/asyncA/wrappedIndex.html
  16. +6 −0 tests/asyncA/wrappedTests/absolute/b.js
  17. +13 −0 tests/asyncA/wrappedTests/absolute/program.js
  18. +10 −0 tests/asyncA/wrappedTests/absolute/submodule/a.js
  19. +20 −0 tests/asyncA/wrappedTests/absolute/test.js
  20. +9 −0 tests/asyncA/wrappedTests/cyclic/a.js
  21. +9 −0 tests/asyncA/wrappedTests/cyclic/b.js
  22. +16 −0 tests/asyncA/wrappedTests/cyclic/program.js
  23. +20 −0 tests/asyncA/wrappedTests/cyclic/test.js
  24. +14 −0 tests/asyncA/wrappedTests/relative/program.js
  25. +9 −0 tests/asyncA/wrappedTests/relative/submodule/a.js
  26. +7 −0 tests/asyncA/wrappedTests/relative/submodule/b.js
  27. +20 −0 tests/asyncA/wrappedTests/relative/test.js
  28. +3 −0 tests/asyncA/yabbler.bat
  29. +3 −1 tests/determineShallowDependencies/modules/knownfailure.js
  30. +29 −0 tests/index.html
  31. +12 −14 tests/modules1.0/index.html
  32. +12 −14 tests/modules1.0/wrappedIndex.html
  33. +40 −0 tests/modules1.1.1/index.html
  34. +3 −0 tests/modules1.1.1/tests/main/a.js
  35. 0 tests/modules1.1.1/tests/main/b.js
  36. +11 −0 tests/modules1.1.1/tests/main/program.js
  37. +15 −0 tests/modules1.1.1/tests/main/test.js
  38. +3 −0 tests/modules1.1.1/tests/module/a.js
  39. +17 −0 tests/modules1.1.1/tests/module/program.js
  40. +3 −0 tests/modules1.1.1/tests/module/submodule/b.js
  41. +15 −0 tests/modules1.1.1/tests/module/test.js
  42. +42 −0 tests/modules1.1.1/wrappedIndex.html
  43. +7 −0 tests/modules1.1.1/wrappedTests/main/a.js
  44. +5 −0 tests/modules1.1.1/wrappedTests/main/b.js
  45. +15 −0 tests/modules1.1.1/wrappedTests/main/program.js
  46. +20 −0 tests/modules1.1.1/wrappedTests/main/test.js
  47. +7 −0 tests/modules1.1.1/wrappedTests/module/a.js
  48. +21 −0 tests/modules1.1.1/wrappedTests/module/program.js
  49. +7 −0 tests/modules1.1.1/wrappedTests/module/submodule/b.js
  50. +20 −0 tests/modules1.1.1/wrappedTests/module/test.js
  51. +2 −0 tests/modules1.1.1/yabbler.bat
  52. +8 −1 tests/print.js
  53. +43 −0 tests/transportC/index.html
  54. +26 −0 tests/transportC/tests/injects/program.js
  55. +20 −0 tests/transportC/tests/injects/test.js
  56. +20 −0 tests/transportC/tests/multipleDefines/program.js
  57. +20 −0 tests/transportC/tests/multipleDefines/test.js
  58. +7 −0 tests/transportC/tests/simple/program.js
  59. +20 −0 tests/transportC/tests/simple/test.js
  60. +45 −0 tests/transportD/index.html
  61. +34 −0 tests/transportD/tests/injects/program.js
  62. +20 −0 tests/transportD/tests/injects/test.js
  63. +21 −0 tests/transportD/tests/mixedDescriptors/program.js
  64. +20 −0 tests/transportD/tests/mixedDescriptors/test.js
  65. +24 −0 tests/transportD/tests/multipleDefines/program.js
  66. +20 −0 tests/transportD/tests/multipleDefines/test.js
  67. +17 −0 tests/transportD/tests/multipleModules/program.js
  68. +20 −0 tests/transportD/tests/multipleModules/test.js
  69. +9 −0 tests/transportD/tests/simple/program.js
  70. +20 −0 tests/transportD/tests/simple/test.js
  71. +142 −30 yabble.js
View
69 README
@@ -2,41 +2,72 @@ A general purpose browser-side CommonJS module loader
Yabble is a general purpose browser-side CommonJS module loader. Other similar module loaders are available, but Yabble strives to be a flexible loader in a small package.
-** NOTE: This is an early release. See below for more information **
+To see live unit tests, visit:
+http://jbrantly.github.com/yabble/tests/index.html
+
+To see an overview of the goals, visit:
+http://blog.jbrantly.com/2010/04/introducing-yabble.html
Features:
- * Compliant with Modules 1.0
+ * Compliant with Modules 1.1.1
* Supports async XHR/eval()
- Allows the use of non-transport-wrapped module code for quick development
* Supports script tags with a Transport format
- Easier debugging, potential for file concatenation
- * Includes a tool for automatically wrapping modules in a Transport format
+ - Supports Transport/D and Transport/C
* Supports require.ensure() for lazy-loading modules
- * Small size (<500 lines, ~13kb raw, ~4kb minified, and <2kb when minified/gzipped)
+ * Passes unit tests on YUI's A-grade browsers
+ * Includes a tool for automatically wrapping modules in a Transport format
+ * Small size (<600 lines, ~15kb raw, ~5kb minified, and ~2kb when minified/gzipped)
Roadmap:
* Stability
- - Better cross-browser compliance
- - More unit tests
- - Better unit testing framework
+ - Even more cross-browser testing
+ - More unit tests for Async/A
* Features
- - Implement support for Modules 1.1(.1)
- - Complete support for Transport/D
- - Implement support for Transport/C
- - Explicit support for concatenated Transport files in loader and tooling
- * Loader
+ - Async/A error handling once its decided (maybe before)
+ - Tested support for loading from another domain (it may work now..)
+ * Documentation
+ * Tooling
+ - Currently under-developed. Not recommended to use.
- Use loader code in tooling (no copy/paste code)
+ - Explicit support for concatenated Transport files tooling (loader should already support)
- Expand supported engines for tooling (node.js)
- Better consideration for platform (line endings, encoding, etc)
-Notes on the current release:
+Usage:
+
+require.setModuleRoot(path)
+
+ Use this to configure the root path to find modules. Think of this as a
+ single entry in require.paths.
+
+require.useScriptTags()
+
+ The default behavior is to use XHR+eval() and expects unwrapped modules. Call this method
+ to configure Yabble to use script tags and expect wrapped modules.
+
+require.run(programId)
+
+ This kicks off an application using the specified module ID.
+
+require.ensure(dependencies, callback)
+
+ See Async/A for more details. Can be used to retrieve modules and run code without using
+ require.run().
+
+See unit tests for example usage.
-This is the first release and is currently unsuitable for any sort of production work. The loader has passed the Module 1.0 unit tests on IE 6/7 and FF 3. While complete cross-browser support is a short-term goal, this release does not offer it.
+Changelog:
-The tooling (yabbler.js) currently supports the Rhino javascript engine and is very under-developed. It is offered as a preview of what is to come.
+04-14-2010
+ - Now using QUnit for unit tests
+ - Added support for Modules 1.1.1 plus unit tests
+ - Finished support for Transport/D plus unit tests
+ - Added support for Transport/C plus unit tests
+ - Added unit tests for Async/A and fixed bugs
+ - Added unit tests for resolveModuleId and determineShallowDependencies
-For example usage for both the loader and the tooling, please see the Modules 1.0 unit tests.
+04-12-2010
+ - Initial commit
-To see the unit tests live, visit:
-XHR/eval - http://jbrantly.github.com/yabble/tests/modules1.0/index.html
-<script>/wrapped - http://jbrantly.github.com/yabble/tests/modules1.0/wrappedIndex.html
View
@@ -0,0 +1,41 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html>
+ <head>
+ <title></title>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+
+ <script type="text/javascript" src="../../yabble.js"></script>
+
+ <script type="text/javascript" src="../qunit.js"></script>
+ <link rel="stylesheet" href="../qunit.css" type="text/css" media="screen" />
+ <script type="text/javascript" src="../print.js"></script>
+
+ <script type="text/javascript">
+ var tests = [
+ ['absolute', 1],
+ ['cyclic', 4],
+ ['relative', 1]
+ ];
+
+ for (var i = 0, n = tests.length; i<n; i++) {
+ var testName = tests[i][0],
+ expected = tests[i][1];
+ test(testName, expected, (function(testName) {
+ return function() {
+ stop();
+ require.reset();
+ require.setModuleRoot('tests/' + testName);
+ require.run('program');
+ };
+ })(testName));
+
+ }
+ </script>
+ </head>
+ <body>
+ <h1 id="qunit-header">Yabble Async/A Unit Tests</h1>
+ <h2 id="qunit-banner"></h2>
+ <h2 id="qunit-userAgent"></h2>
+ <ol id="qunit-tests"></ol>
+ </body>
+</html>
@@ -0,0 +1 @@
+exports.foo = function() {};
@@ -0,0 +1,9 @@
+require.ensure(['test', 'submodule/a', 'b'], function(require) {
+ var test = require('test');
+ var a = require('submodule/a');
+ var b = require('b');
+ a.foo(function(bThruA) {
+ test.assert(bThruA.foo === b.foo, 'require.ensure works with absolute identifiers');
+ test.print('DONE', 'info');
+ });
+});
@@ -0,0 +1,5 @@
+exports.foo = function (cb) {
+ require.ensure(['b'], function(require) {
+ cb(require('b'));
+ });
+};
@@ -0,0 +1,15 @@
+
+exports.print = typeof print !== "undefined" ? print : function () {
+ var system = require("system");
+ var stdio = system.stdio;
+ stdio.print.apply(stdio, arguments);
+};
+
+exports.assert = function (guard, message) {
+ if (guard) {
+ exports.print('PASS ' + message, 'pass');
+ } else {
+ exports.print('FAIL ' + message, 'fail');
+ }
+};
+
@@ -0,0 +1,4 @@
+exports.a = function () {
+ return b;
+};
+var b = require('b');
@@ -0,0 +1,4 @@
+var a = require('a');
+exports.b = function () {
+ return a;
+};
@@ -0,0 +1,12 @@
+require.ensure(['test', 'a', 'b'], function(require) {
+ var test = require('test');
+ var a = require('a');
+ var b = require('b');
+
+ test.assert(a.a, 'a exists');
+ test.assert(b.b, 'b exists')
+ test.assert(a.a().b === b.b, 'a gets b');
+ test.assert(b.b().a === a.a, 'b gets a');
+
+ test.print('DONE', 'info');
+});
@@ -0,0 +1,15 @@
+
+exports.print = typeof print !== "undefined" ? print : function () {
+ var system = require("system");
+ var stdio = system.stdio;
+ stdio.print.apply(stdio, arguments);
+};
+
+exports.assert = function (guard, message) {
+ if (guard) {
+ exports.print('PASS ' + message, 'pass');
+ } else {
+ exports.print('FAIL ' + message, 'fail');
+ }
+};
+
@@ -0,0 +1,10 @@
+require.ensure(['test', 'submodule/a', 'submodule/b'], function(require) {
+ var test = require('test');
+ var a = require('submodule/a');
+ var b = require('submodule/b');
+
+ a.foo(function(bfoo) {
+ test.assert(bfoo == b.foo, 'a and b share foo through a relative require');
+ test.print('DONE', 'info');
+ });
+});
@@ -0,0 +1,5 @@
+exports.foo = function(cb) {
+ require.ensure(['./b'], function(require) {
+ cb(require('./b').foo);
+ });
+};
@@ -0,0 +1,2 @@
+exports.foo = function () {
+};
@@ -0,0 +1,15 @@
+
+exports.print = typeof print !== "undefined" ? print : function () {
+ var system = require("system");
+ var stdio = system.stdio;
+ stdio.print.apply(stdio, arguments);
+};
+
+exports.assert = function (guard, message) {
+ if (guard) {
+ exports.print('PASS ' + message, 'pass');
+ } else {
+ exports.print('FAIL ' + message, 'fail');
+ }
+};
+
@@ -0,0 +1,43 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html>
+ <head>
+ <title></title>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+
+ <script type="text/javascript" src="../../yabble.js"></script>
+
+ <script type="text/javascript" src="../qunit.js"></script>
+ <link rel="stylesheet" href="../qunit.css" type="text/css" media="screen" />
+ <script type="text/javascript" src="../print.js"></script>
+
+ <script type="text/javascript">
+ require.useScriptTags();
+
+ var tests = [
+ ['absolute', 1],
+ ['cyclic', 4],
+ ['relative', 1]
+ ];
+
+ for (var i = 0, n = tests.length; i<n; i++) {
+ var testName = tests[i][0],
+ expected = tests[i][1];
+ test(testName, expected, (function(testName) {
+ return function() {
+ stop();
+ require.reset();
+ require.setModuleRoot('wrappedTests/' + testName);
+ require.run('program');
+ };
+ })(testName));
+
+ }
+ </script>
+ </head>
+ <body>
+ <h1 id="qunit-header">Yabble Async/A Unit Tests (Wrapped Modules)</h1>
+ <h2 id="qunit-banner"></h2>
+ <h2 id="qunit-userAgent"></h2>
+ <ol id="qunit-tests"></ol>
+ </body>
+</html>
@@ -0,0 +1,6 @@
+/* This file has been generated by yabbler.js */
+require.define({
+"b": function(require, exports, module) {
+exports.foo = function() {};
+
+}}, []);
@@ -0,0 +1,13 @@
+/* This file has been generated by yabbler.js */
+require.define({
+"program": function(require, exports, module) {
+require.ensure(['test', 'submodule/a', 'b'], function(require) {
+ var test = require('test');
+ var a = require('submodule/a');
+ var b = require('b');
+ a.foo(function(bThruA) {
+ test.assert(bThruA.foo === b.foo, 'require.ensure works with absolute identifiers');
+ test.print('DONE', 'info');
+ });
+});
+}}, []);
@@ -0,0 +1,10 @@
+/* This file has been generated by yabbler.js */
+require.define({
+"submodule/a": function(require, exports, module) {
+exports.foo = function (cb) {
+ require.ensure(['b'], function(require) {
+ cb(require('b'));
+ });
+};
+
+}}, []);
@@ -0,0 +1,20 @@
+/* This file has been generated by yabbler.js */
+require.define({
+"test": function(require, exports, module) {
+
+exports.print = typeof print !== "undefined" ? print : function () {
+ var system = require("system");
+ var stdio = system.stdio;
+ stdio.print.apply(stdio, arguments);
+};
+
+exports.assert = function (guard, message) {
+ if (guard) {
+ exports.print('PASS ' + message, 'pass');
+ } else {
+ exports.print('FAIL ' + message, 'fail');
+ }
+};
+
+
+}}, ["system"]);
@@ -0,0 +1,9 @@
+/* This file has been generated by yabbler.js */
+require.define({
+"a": function(require, exports, module) {
+exports.a = function () {
+ return b;
+};
+var b = require('b');
+
+}}, ["b"]);
@@ -0,0 +1,9 @@
+/* This file has been generated by yabbler.js */
+require.define({
+"b": function(require, exports, module) {
+var a = require('a');
+exports.b = function () {
+ return a;
+};
+
+}}, ["a"]);
@@ -0,0 +1,16 @@
+/* This file has been generated by yabbler.js */
+require.define({
+"program": function(require, exports, module) {
+require.ensure(['test', 'a', 'b'], function(require) {
+ var test = require('test');
+ var a = require('a');
+ var b = require('b');
+
+ test.assert(a.a, 'a exists');
+ test.assert(b.b, 'b exists')
+ test.assert(a.a().b === b.b, 'a gets b');
+ test.assert(b.b().a === a.a, 'b gets a');
+
+ test.print('DONE', 'info');
+});
+}}, []);
Oops, something went wrong.

0 comments on commit c29ad4f

Please sign in to comment.