Permalink
Browse files

various changes and additions

  • Loading branch information...
1 parent 4843560 commit 59139536d2ebdd369e80578b58b2c706f5ebebbe @cadorn cadorn committed Feb 23, 2012
Showing with 319 additions and 222 deletions.
  1. +9 −0 README.md
  2. 0 examples/{01-LoaderFeatureBundles → 01-CoreLoaderFeatureBundles}/main.js
  3. +1 −1 examples/{01-LoaderFeatureBundles → 01-CoreLoaderFeatureBundles}/package.json
  4. 0 examples/{02-NodeJSLoaderFeatures → 02-LoaderFeatures}/01-HelloWorld/main.js
  5. 0 examples/{02-NodeJSLoaderFeatures/13-AssignExports → 02-LoaderFeatures/01-HelloWorld}/package.json
  6. 0 examples/{02-NodeJSLoaderFeatures → 02-LoaderFeatures}/02-ReturnExports/main.js
  7. 0 examples/{02-NodeJSLoaderFeatures/12-Environment → 02-LoaderFeatures/02-ReturnExports}/package.json
  8. 0 examples/{02-NodeJSLoaderFeatures → 02-LoaderFeatures}/03-SpecifyMain/init.js
  9. 0 examples/{02-NodeJSLoaderFeatures → 02-LoaderFeatures}/03-SpecifyMain/package.json
  10. 0 examples/{02-NodeJSLoaderFeatures → 02-LoaderFeatures}/04-PackageLocalDependencies/greetings.js
  11. 0 examples/{02-NodeJSLoaderFeatures → 02-LoaderFeatures}/04-PackageLocalDependencies/main.js
  12. 0 ...NodeJSLoaderFeatures/11-CrossDomain → 02-LoaderFeatures/04-PackageLocalDependencies}/package.json
  13. 0 examples/{02-NodeJSLoaderFeatures → 02-LoaderFeatures}/04-PackageLocalDependencies/words/hello.js
  14. 0 examples/{02-NodeJSLoaderFeatures → 02-LoaderFeatures}/05-CrossPackageDependencies/main.js
  15. 0 examples/{02-NodeJSLoaderFeatures → 02-LoaderFeatures}/05-CrossPackageDependencies/package.json
  16. 0 ...eJSLoaderFeatures → 02-LoaderFeatures}/05-CrossPackageDependencies/packages/packageA/greetings.js
  17. 0 ...NodeJSLoaderFeatures → 02-LoaderFeatures}/05-CrossPackageDependencies/packages/packageA/logger.js
  18. 0 ...eJSLoaderFeatures → 02-LoaderFeatures}/05-CrossPackageDependencies/packages/packageA/package.json
  19. 0 ...eJSLoaderFeatures → 02-LoaderFeatures}/05-CrossPackageDependencies/packages/packageB/package.json
  20. 0 ...SLoaderFeatures → 02-LoaderFeatures}/05-CrossPackageDependencies/packages/packageB/words/hello.js
  21. 0 .../{02-NodeJSLoaderFeatures → 02-LoaderFeatures}/05-CrossPackageDependencies/packages/packageC/H.js
  22. 0 examples/{02-NodeJSLoaderFeatures → 02-LoaderFeatures}/06-JsonModule/main.js
  23. 0 examples/{02-NodeJSLoaderFeatures/07-TextModule → 02-LoaderFeatures/06-JsonModule}/package.json
  24. 0 examples/{02-NodeJSLoaderFeatures → 02-LoaderFeatures}/06-JsonModule/word.js
  25. 0 examples/{02-NodeJSLoaderFeatures → 02-LoaderFeatures}/07-TextModule/hello.txt
  26. 0 examples/{02-NodeJSLoaderFeatures → 02-LoaderFeatures}/07-TextModule/main.js
  27. 0 examples/{02-NodeJSLoaderFeatures/06-JsonModule → 02-LoaderFeatures/07-TextModule}/package.json
  28. 0 ...04-NodeJSPlatformFeatures/02-BundlerMiddleware/dist → 02-LoaderFeatures}/08-ResourceURI/hello.txt
  29. 0 examples/{02-NodeJSLoaderFeatures → 02-LoaderFeatures}/08-ResourceURI/main.js
  30. 0 examples/{02-NodeJSLoaderFeatures → 02-LoaderFeatures}/08-ResourceURI/package.json
  31. +1 −1 ...deJSLoaderFeatures/09-LoadBundle/ExtraBundle.js → 02-LoaderFeatures/09-LoadBundle/ExtraModule.js}
  32. +27 −0 examples/02-LoaderFeatures/09-LoadBundle/main.js
  33. +1 −1 examples/{02-NodeJSLoaderFeatures → 02-LoaderFeatures}/09-LoadBundle/package.json
  34. 0 examples/{02-NodeJSLoaderFeatures → 02-LoaderFeatures}/10-Sandbox/SandboxedExtraBundle.js
  35. 0 examples/{02-NodeJSLoaderFeatures → 02-LoaderFeatures}/10-Sandbox/main.js
  36. 0 examples/{02-NodeJSLoaderFeatures → 02-LoaderFeatures}/10-Sandbox/package.json
  37. 0 examples/{02-NodeJSLoaderFeatures → 02-LoaderFeatures}/11-CrossDomain/main.js
  38. 0 ...NodeJSLoaderFeatures/04-PackageLocalDependencies → 02-LoaderFeatures/11-CrossDomain}/package.json
  39. 0 examples/{02-NodeJSLoaderFeatures → 02-LoaderFeatures}/12-Environment/main.js
  40. 0 examples/{02-NodeJSLoaderFeatures/02-ReturnExports → 02-LoaderFeatures/12-Environment}/package.json
  41. 0 examples/{02-NodeJSLoaderFeatures → 02-LoaderFeatures}/13-AssignExports/main.js
  42. 0 examples/{02-NodeJSLoaderFeatures/01-HelloWorld → 02-LoaderFeatures/13-AssignExports}/package.json
  43. 0 examples/{02-NodeJSLoaderFeatures → 02-LoaderFeatures}/Avoid-VariableRequire/lib.js
  44. 0 examples/{02-NodeJSLoaderFeatures → 02-LoaderFeatures}/Avoid-VariableRequire/main.js
  45. 0 examples/{02-NodeJSLoaderFeatures → 02-LoaderFeatures}/Avoid-VariableRequire/package.json
  46. +0 −27 examples/02-NodeJSLoaderFeatures/09-LoadBundle/main.js
  47. 0 .../{04-NodeJSPlatformFeatures/02-BundlerMiddleware → 03-LoaderFeatureBundles}/dist/01-HelloWorld.js
  48. 0 ...4-NodeJSPlatformFeatures/02-BundlerMiddleware → 03-LoaderFeatureBundles}/dist/02-ReturnExports.js
  49. 0 ...{04-NodeJSPlatformFeatures/02-BundlerMiddleware → 03-LoaderFeatureBundles}/dist/03-SpecifyMain.js
  50. 0 ...tformFeatures/02-BundlerMiddleware → 03-LoaderFeatureBundles}/dist/04-PackageLocalDependencies.js
  51. +16 −16 ...les/{03-NodeJSLoaderFeatureBundles → 03-LoaderFeatureBundles}/dist/05-CrossPackageDependencies.js
  52. 0 .../{04-NodeJSPlatformFeatures/02-BundlerMiddleware → 03-LoaderFeatureBundles}/dist/06-JsonModule.js
  53. 0 .../{04-NodeJSPlatformFeatures/02-BundlerMiddleware → 03-LoaderFeatureBundles}/dist/07-TextModule.js
  54. 0 ...{04-NodeJSPlatformFeatures/02-BundlerMiddleware → 03-LoaderFeatureBundles}/dist/08-ResourceURI.js
  55. 0 examples/{03-NodeJSLoaderFeatureBundles → 03-LoaderFeatureBundles}/dist/08-ResourceURI/hello.txt
  56. +5 −5 .../{04-NodeJSPlatformFeatures/02-BundlerMiddleware → 03-LoaderFeatureBundles}/dist/09-LoadBundle.js
  57. 0 ...latformFeatures/02-BundlerMiddleware → 03-LoaderFeatureBundles}/dist/09-LoadBundle/ExtraBundle.js
  58. +18 −0 examples/03-LoaderFeatureBundles/dist/09-LoadBundle/ExtraModule.js
  59. 0 ...les/{04-NodeJSPlatformFeatures/02-BundlerMiddleware → 03-LoaderFeatureBundles}/dist/10-Sandbox.js
  60. 0 ...mFeatures/02-BundlerMiddleware → 03-LoaderFeatureBundles}/dist/10-Sandbox/SandboxedExtraBundle.js
  61. 0 ...{04-NodeJSPlatformFeatures/02-BundlerMiddleware → 03-LoaderFeatureBundles}/dist/11-CrossDomain.js
  62. 0 ...{04-NodeJSPlatformFeatures/02-BundlerMiddleware → 03-LoaderFeatureBundles}/dist/12-Environment.js
  63. 0 ...4-NodeJSPlatformFeatures/02-BundlerMiddleware → 03-LoaderFeatureBundles}/dist/13-AssignExports.js
  64. 0 examples/{03-NodeJSLoaderFeatureBundles → 03-LoaderFeatureBundles}/dist/Avoid-VariableRequire.js
  65. 0 examples/{03-NodeJSLoaderFeatureBundles → 03-LoaderFeatureBundles}/dist/Avoid-VariableRequire/lib.js
  66. +3 −3 examples/{03-NodeJSLoaderFeatureBundles → 03-LoaderFeatureBundles}/main.js
  67. +14 −0 examples/03-LoaderFeatureBundles/package.json
  68. +0 −14 examples/03-NodeJSLoaderFeatureBundles/package.json
  69. 0 examples/{04-NodeJSPlatformFeatures → 04-PlatformFeatures}/01-Globals/main.js
  70. +1 −1 examples/{04-NodeJSPlatformFeatures → 04-PlatformFeatures}/01-Globals/package.json
  71. 0 .../{03-NodeJSLoaderFeatureBundles → 04-PlatformFeatures/02-BundlerMiddleware}/dist/01-HelloWorld.js
  72. 0 ...3-NodeJSLoaderFeatureBundles → 04-PlatformFeatures/02-BundlerMiddleware}/dist/02-ReturnExports.js
  73. 0 ...{03-NodeJSLoaderFeatureBundles → 04-PlatformFeatures/02-BundlerMiddleware}/dist/03-SpecifyMain.js
  74. 0 ...derFeatureBundles → 04-PlatformFeatures/02-BundlerMiddleware}/dist/04-PackageLocalDependencies.js
  75. +16 −16 ...SPlatformFeatures → 04-PlatformFeatures}/02-BundlerMiddleware/dist/05-CrossPackageDependencies.js
  76. 0 .../{03-NodeJSLoaderFeatureBundles → 04-PlatformFeatures/02-BundlerMiddleware}/dist/06-JsonModule.js
  77. 0 .../{03-NodeJSLoaderFeatureBundles → 04-PlatformFeatures/02-BundlerMiddleware}/dist/07-TextModule.js
  78. 0 ...{03-NodeJSLoaderFeatureBundles → 04-PlatformFeatures/02-BundlerMiddleware}/dist/08-ResourceURI.js
  79. 0 ...02-NodeJSLoaderFeatures → 04-PlatformFeatures/02-BundlerMiddleware/dist}/08-ResourceURI/hello.txt
  80. +5 −5 .../{03-NodeJSLoaderFeatureBundles → 04-PlatformFeatures/02-BundlerMiddleware}/dist/09-LoadBundle.js
  81. 0 ...oaderFeatureBundles → 04-PlatformFeatures/02-BundlerMiddleware}/dist/09-LoadBundle/ExtraBundle.js
  82. +18 −0 examples/04-PlatformFeatures/02-BundlerMiddleware/dist/09-LoadBundle/ExtraModule.js
  83. 0 ...les/{03-NodeJSLoaderFeatureBundles → 04-PlatformFeatures/02-BundlerMiddleware}/dist/10-Sandbox.js
  84. 0 ...eatureBundles → 04-PlatformFeatures/02-BundlerMiddleware}/dist/10-Sandbox/SandboxedExtraBundle.js
  85. 0 ...{03-NodeJSLoaderFeatureBundles → 04-PlatformFeatures/02-BundlerMiddleware}/dist/11-CrossDomain.js
  86. 0 ...{03-NodeJSLoaderFeatureBundles → 04-PlatformFeatures/02-BundlerMiddleware}/dist/12-Environment.js
  87. 0 ...3-NodeJSLoaderFeatureBundles → 04-PlatformFeatures/02-BundlerMiddleware}/dist/13-AssignExports.js
  88. +1 −1 examples/{04-NodeJSPlatformFeatures → 04-PlatformFeatures}/02-BundlerMiddleware/main.js
  89. +1 −1 examples/{04-NodeJSPlatformFeatures → 04-PlatformFeatures}/02-BundlerMiddleware/package.json
  90. +1 −1 examples/{04-NodeJSPlatformFeatures → 04-PlatformFeatures}/02-BundlerMiddleware/test.js
  91. 0 examples/{04-NodeJSPlatformFeatures → 04-PlatformFeatures}/main.js
  92. +3 −2 examples/{04-NodeJSPlatformFeatures → 04-PlatformFeatures}/package.json
  93. +1 −1 examples/{05-NodeJSPlatformFeatureBundles → 05-PlatformFeatureBundles}/dist/01-Globals.js
  94. +1 −1 examples/{05-NodeJSPlatformFeatureBundles → 05-PlatformFeatureBundles}/main.js
  95. +1 −1 examples/{05-NodeJSPlatformFeatureBundles → 05-PlatformFeatureBundles}/package.json
  96. +43 −34 lib/bundler.js
  97. +5 −0 loader.js
  98. +1 −1 package.json
  99. +7 −3 tests/adapter/vows.js
  100. +113 −85 tests/examples.js
  101. +6 −1 tests/test-helper.js
View
9 README.md
@@ -12,6 +12,7 @@ Everything needed to use the [Sourcemint](http://sourcemint.com/) Ecosystem
* Sponsor: [Sourcemint](http://sourcemint.com/)
* Mailing list: [groups.google.com/group/sourcemint](http://groups.google.com/group/sourcemint)
+
Usage
=====
@@ -20,4 +21,12 @@ Usage
npm install
npm test
+
+Examples
+========
+
+There are various examples that double as unit tests in `./examples`.
+
+For end-user examples of common use-cases see [github.com/sourcemint/examples-js](http://github.com/sourcemint/examples-js/).
+
More examples and documentation will be available in time.
View
0 examples/01-LoaderFeatureBundles/main.js → examples/01-CoreLoaderFeatureBundles/main.js
File renamed without changes.
View
2 ...ples/01-LoaderFeatureBundles/package.json → .../01-CoreLoaderFeatureBundles/package.json
@@ -1,5 +1,5 @@
{
- "name": "sourcemint-platform-nodejs-examples-01-LoaderFeatureBundles",
+ "name": "sourcemint-platform-nodejs-examples-01-CoreLoaderFeatureBundles",
"version": "0.1.0",
"engines": {
"nodejs": "0.x"
View
0 ...odeJSLoaderFeatures/01-HelloWorld/main.js → ...s/02-LoaderFeatures/01-HelloWorld/main.js
File renamed without changes.
View
0 ...derFeatures/13-AssignExports/package.json → ...LoaderFeatures/01-HelloWorld/package.json
File renamed without changes.
View
0 ...JSLoaderFeatures/02-ReturnExports/main.js → ...2-LoaderFeatures/02-ReturnExports/main.js
File renamed without changes.
View
0 ...oaderFeatures/12-Environment/package.json → ...derFeatures/02-ReturnExports/package.json
File renamed without changes.
View
0 ...deJSLoaderFeatures/03-SpecifyMain/init.js → .../02-LoaderFeatures/03-SpecifyMain/init.js
File renamed without changes.
View
0 ...oaderFeatures/03-SpecifyMain/package.json → ...oaderFeatures/03-SpecifyMain/package.json
File renamed without changes.
View
0 .../04-PackageLocalDependencies/greetings.js → .../04-PackageLocalDependencies/greetings.js
File renamed without changes.
View
0 ...tures/04-PackageLocalDependencies/main.js → ...tures/04-PackageLocalDependencies/main.js
File renamed without changes.
View
0 ...oaderFeatures/11-CrossDomain/package.json → .../04-PackageLocalDependencies/package.json
File renamed without changes.
View
0 ...4-PackageLocalDependencies/words/hello.js → ...4-PackageLocalDependencies/words/hello.js
File renamed without changes.
View
0 ...tures/05-CrossPackageDependencies/main.js → ...tures/05-CrossPackageDependencies/main.js
File renamed without changes.
View
0 .../05-CrossPackageDependencies/package.json → .../05-CrossPackageDependencies/package.json
File renamed without changes.
View
0 ...pendencies/packages/packageA/greetings.js → ...pendencies/packages/packageA/greetings.js
File renamed without changes.
View
0 ...eDependencies/packages/packageA/logger.js → ...eDependencies/packages/packageA/logger.js
File renamed without changes.
View
0 ...pendencies/packages/packageA/package.json → ...pendencies/packages/packageA/package.json
File renamed without changes.
View
0 ...pendencies/packages/packageB/package.json → ...pendencies/packages/packageB/package.json
File renamed without changes.
View
0 ...ndencies/packages/packageB/words/hello.js → ...ndencies/packages/packageB/words/hello.js
File renamed without changes.
View
0 ...ackageDependencies/packages/packageC/H.js → ...ackageDependencies/packages/packageC/H.js
File renamed without changes.
View
0 ...odeJSLoaderFeatures/06-JsonModule/main.js → ...s/02-LoaderFeatures/06-JsonModule/main.js
File renamed without changes.
View
0 ...LoaderFeatures/07-TextModule/package.json → ...LoaderFeatures/06-JsonModule/package.json
File renamed without changes.
View
0 ...odeJSLoaderFeatures/06-JsonModule/word.js → ...s/02-LoaderFeatures/06-JsonModule/word.js
File renamed without changes.
View
0 ...eJSLoaderFeatures/07-TextModule/hello.txt → ...02-LoaderFeatures/07-TextModule/hello.txt
File renamed without changes.
View
0 ...odeJSLoaderFeatures/07-TextModule/main.js → ...s/02-LoaderFeatures/07-TextModule/main.js
File renamed without changes.
View
0 ...LoaderFeatures/06-JsonModule/package.json → ...LoaderFeatures/07-TextModule/package.json
File renamed without changes.
View
0 ...rMiddleware/dist/08-ResourceURI/hello.txt → ...2-LoaderFeatures/08-ResourceURI/hello.txt
File renamed without changes.
View
0 ...deJSLoaderFeatures/08-ResourceURI/main.js → .../02-LoaderFeatures/08-ResourceURI/main.js
File renamed without changes.
View
0 ...oaderFeatures/08-ResourceURI/package.json → ...oaderFeatures/08-ResourceURI/package.json
File renamed without changes.
View
2 ...aderFeatures/09-LoadBundle/ExtraBundle.js → ...aderFeatures/09-LoadBundle/ExtraModule.js
@@ -3,5 +3,5 @@ var MAIN = require("./main.js");
exports.init = function()
{
- module.log(MAIN.getExtraBundleGreeting());
+ module.log(MAIN.getExtraModuleGreeting());
}
View
27 examples/02-LoaderFeatures/09-LoadBundle/main.js
@@ -0,0 +1,27 @@
+
+var Q;
+
+exports.main = function(options)
+{
+ Q = require.API.Q;
+
+ var result = Q.defer();
+
+ module.log("Hello from 09-LoadBundle!");
+
+ var extraModuleID = "./ExtraModule";
+
+ require.async(extraModuleID, function(EXTRA_MODULE)
+ {
+ EXTRA_MODULE.init();
+
+ result.resolve();
+ });
+
+ return result.promise;
+}
+
+exports.getExtraModuleGreeting = function()
+{
+ return "Hello from 09-LoadBundle/ExtraModule!";
+}
View
2 ...LoaderFeatures/09-LoadBundle/package.json → ...LoaderFeatures/09-LoadBundle/package.json
@@ -5,7 +5,7 @@
"adapter": "github.com/sourcemint/platform-nodejs/0",
"resolvers": {
"/main.js": [
- "./ExtraBundle.js"
+ "./ExtraModule.js"
]
}
}
View
0 ...atures/10-Sandbox/SandboxedExtraBundle.js → ...atures/10-Sandbox/SandboxedExtraBundle.js
File renamed without changes.
View
0 ...2-NodeJSLoaderFeatures/10-Sandbox/main.js → ...ples/02-LoaderFeatures/10-Sandbox/main.js
File renamed without changes.
View
0 ...eJSLoaderFeatures/10-Sandbox/package.json → ...02-LoaderFeatures/10-Sandbox/package.json
File renamed without changes.
View
0 ...deJSLoaderFeatures/11-CrossDomain/main.js → .../02-LoaderFeatures/11-CrossDomain/main.js
File renamed without changes.
View
0 .../04-PackageLocalDependencies/package.json → ...oaderFeatures/11-CrossDomain/package.json
File renamed without changes.
View
0 ...deJSLoaderFeatures/12-Environment/main.js → .../02-LoaderFeatures/12-Environment/main.js
File renamed without changes.
View
0 ...derFeatures/02-ReturnExports/package.json → ...oaderFeatures/12-Environment/package.json
File renamed without changes.
View
0 ...JSLoaderFeatures/13-AssignExports/main.js → ...2-LoaderFeatures/13-AssignExports/main.js
File renamed without changes.
View
0 ...LoaderFeatures/01-HelloWorld/package.json → ...derFeatures/13-AssignExports/package.json
File renamed without changes.
View
0 ...aderFeatures/Avoid-VariableRequire/lib.js → ...aderFeatures/Avoid-VariableRequire/lib.js
File renamed without changes.
View
0 ...derFeatures/Avoid-VariableRequire/main.js → ...derFeatures/Avoid-VariableRequire/main.js
File renamed without changes.
View
0 ...atures/Avoid-VariableRequire/package.json → ...atures/Avoid-VariableRequire/package.json
File renamed without changes.
View
27 examples/02-NodeJSLoaderFeatures/09-LoadBundle/main.js
@@ -1,27 +0,0 @@
-
-var Q;
-
-exports.main = function(options)
-{
- Q = require.API.Q;
-
- var result = Q.defer();
-
- module.log("Hello from 09-LoadBundle!");
-
- var extraBundleID = "./ExtraBundle";
-
- require.async(extraBundleID, function(EXTRA_BUNDLE)
- {
- EXTRA_BUNDLE.init();
-
- result.resolve();
- });
-
- return result.promise;
-}
-
-exports.getExtraBundleGreeting = function()
-{
- return "Hello from 09-LoadBundle/ExtraBundle!";
-}
View
0 ...2-BundlerMiddleware/dist/01-HelloWorld.js → ...oaderFeatureBundles/dist/01-HelloWorld.js
File renamed without changes.
View
0 ...undlerMiddleware/dist/02-ReturnExports.js → ...erFeatureBundles/dist/02-ReturnExports.js
File renamed without changes.
View
0 ...-BundlerMiddleware/dist/03-SpecifyMain.js → ...aderFeatureBundles/dist/03-SpecifyMain.js
File renamed without changes.
View
0 ...eware/dist/04-PackageLocalDependencies.js → ...ndles/dist/04-PackageLocalDependencies.js
File renamed without changes.
View
32 ...ndles/dist/05-CrossPackageDependencies.js → ...ndles/dist/05-CrossPackageDependencies.js
@@ -16,10 +16,10 @@ require.bundle("", function(require)
}
});
- require.memoize("7560b93e78b4e2a0c520988986f530a1c49b5229/greetings.js", function(require, exports, module)
+ require.memoize("c8fdbfb58ba344e241f350f4db644a5ca402b3bb/greetings.js", function(require, exports, module)
{
- var __filename = require.sandbox.id + "7560b93e78b4e2a0c520988986f530a1c49b5229/greetings.js";
- var __dirname = require.sandbox.id + "/7560b93e78b4e2a0c520988986f530a1c49b5229";
+ var __filename = require.sandbox.id + "c8fdbfb58ba344e241f350f4db644a5ca402b3bb/greetings.js";
+ var __dirname = require.sandbox.id + "/c8fdbfb58ba344e241f350f4db644a5ca402b3bb";
var HELLO = require("package/hello");
@@ -34,21 +34,21 @@ require.bundle("", function(require)
}
});
- require.memoize("7560b93e78b4e2a0c520988986f530a1c49b5229/logger.js", function(require, exports, module)
+ require.memoize("c8fdbfb58ba344e241f350f4db644a5ca402b3bb/logger.js", function(require, exports, module)
{
- var __filename = require.sandbox.id + "7560b93e78b4e2a0c520988986f530a1c49b5229/logger.js";
- var __dirname = require.sandbox.id + "/7560b93e78b4e2a0c520988986f530a1c49b5229";
+ var __filename = require.sandbox.id + "c8fdbfb58ba344e241f350f4db644a5ca402b3bb/logger.js";
+ var __dirname = require.sandbox.id + "/c8fdbfb58ba344e241f350f4db644a5ca402b3bb";
exports.log = function(message)
{
module.log(message);
}
});
- require.memoize("19819d780486f6050197ad891f5e90ba86dbd38f/words/hello.js", function(require, exports, module)
+ require.memoize("8006e010fb60da2be1a5ad691d389c8a3146127e/words/hello.js", function(require, exports, module)
{
- var __filename = require.sandbox.id + "19819d780486f6050197ad891f5e90ba86dbd38f/words/hello.js";
- var __dirname = require.sandbox.id + "/19819d780486f6050197ad891f5e90ba86dbd38f/words";
+ var __filename = require.sandbox.id + "8006e010fb60da2be1a5ad691d389c8a3146127e/words/hello.js";
+ var __dirname = require.sandbox.id + "/8006e010fb60da2be1a5ad691d389c8a3146127e/words";
var GREETINGS = require("package/greetings");
@@ -63,19 +63,19 @@ require.bundle("", function(require)
}
});
- require.memoize("5390a08ebb853e94c69c041a471086f0d3e7d61f/H.js", function(require, exports, module)
+ require.memoize("91dc444cfecc833c728374ac4dc405a612d304f0/H.js", function(require, exports, module)
{
- var __filename = require.sandbox.id + "5390a08ebb853e94c69c041a471086f0d3e7d61f/H.js";
- var __dirname = require.sandbox.id + "/5390a08ebb853e94c69c041a471086f0d3e7d61f";
+ var __filename = require.sandbox.id + "91dc444cfecc833c728374ac4dc405a612d304f0/H.js";
+ var __dirname = require.sandbox.id + "/91dc444cfecc833c728374ac4dc405a612d304f0";
exports.getLetter = function()
{
return "H";
}
});
- require.memoize("/package.json", {"main":"/main.js","mappings":{"helpers":"7560b93e78b4e2a0c520988986f530a1c49b5229"},"directories":{"lib":""}});
- require.memoize("7560b93e78b4e2a0c520988986f530a1c49b5229/package.json", {"mappings":{"package":"19819d780486f6050197ad891f5e90ba86dbd38f"},"directories":{"lib":""}});
- require.memoize("19819d780486f6050197ad891f5e90ba86dbd38f/package.json", {"mappings":{"package":"7560b93e78b4e2a0c520988986f530a1c49b5229","letters":"5390a08ebb853e94c69c041a471086f0d3e7d61f"},"directories":{"lib":"words"}});
- require.memoize("5390a08ebb853e94c69c041a471086f0d3e7d61f/package.json", {"directories":{"lib":""},"mappings":{}});
+ require.memoize("/package.json", {"main":"/main.js","mappings":{"helpers":"c8fdbfb58ba344e241f350f4db644a5ca402b3bb"},"directories":{"lib":""}});
+ require.memoize("c8fdbfb58ba344e241f350f4db644a5ca402b3bb/package.json", {"mappings":{"package":"8006e010fb60da2be1a5ad691d389c8a3146127e"},"directories":{"lib":""}});
+ require.memoize("8006e010fb60da2be1a5ad691d389c8a3146127e/package.json", {"mappings":{"package":"c8fdbfb58ba344e241f350f4db644a5ca402b3bb","letters":"91dc444cfecc833c728374ac4dc405a612d304f0"},"directories":{"lib":"words"}});
+ require.memoize("91dc444cfecc833c728374ac4dc405a612d304f0/package.json", {"directories":{"lib":""},"mappings":{}});
});
View
0 ...2-BundlerMiddleware/dist/06-JsonModule.js → ...oaderFeatureBundles/dist/06-JsonModule.js
File renamed without changes.
View
0 ...2-BundlerMiddleware/dist/07-TextModule.js → ...oaderFeatureBundles/dist/07-TextModule.js
File renamed without changes.
View
0 ...-BundlerMiddleware/dist/08-ResourceURI.js → ...aderFeatureBundles/dist/08-ResourceURI.js
File renamed without changes.
View
0 ...tureBundles/dist/08-ResourceURI/hello.txt → ...tureBundles/dist/08-ResourceURI/hello.txt
File renamed without changes.
View
10 ...2-BundlerMiddleware/dist/09-LoadBundle.js → ...oaderFeatureBundles/dist/09-LoadBundle.js
@@ -16,21 +16,21 @@ require.bundle("", function(require)
module.log("Hello from 09-LoadBundle!");
- var extraBundleID = "./ExtraBundle";
+ var extraModuleID = "./ExtraModule";
- require.async(extraBundleID, function(EXTRA_BUNDLE)
+ require.async(extraModuleID, function(EXTRA_MODULE)
{
- EXTRA_BUNDLE.init();
+ EXTRA_MODULE.init();
result.resolve();
});
return result.promise;
}
- exports.getExtraBundleGreeting = function()
+ exports.getExtraModuleGreeting = function()
{
- return "Hello from 09-LoadBundle/ExtraBundle!";
+ return "Hello from 09-LoadBundle/ExtraModule!";
}
});
View
0 ...dleware/dist/09-LoadBundle/ExtraBundle.js → ...Bundles/dist/09-LoadBundle/ExtraBundle.js
File renamed without changes.
View
18 examples/03-LoaderFeatureBundles/dist/09-LoadBundle/ExtraModule.js
@@ -0,0 +1,18 @@
+require.bundle("", function(require)
+{
+
+ require.memoize("/ExtraModule.js", function(require, exports, module)
+ {
+ var __filename = require.sandbox.id + "/ExtraModule.js";
+ var __dirname = require.sandbox.id + "";
+
+ var MAIN = require("./main.js");
+
+ exports.init = function()
+ {
+ module.log(MAIN.getExtraModuleGreeting());
+ }
+
+ });
+ require.memoize("/package.json", {"main":"/ExtraModule.js","directories":{"lib":""},"mappings":{}});
+});
View
0 ...s/02-BundlerMiddleware/dist/10-Sandbox.js → ...3-LoaderFeatureBundles/dist/10-Sandbox.js
File renamed without changes.
View
0 ...e/dist/10-Sandbox/SandboxedExtraBundle.js → ...s/dist/10-Sandbox/SandboxedExtraBundle.js
File renamed without changes.
View
0 ...-BundlerMiddleware/dist/11-CrossDomain.js → ...aderFeatureBundles/dist/11-CrossDomain.js
File renamed without changes.
View
0 ...-BundlerMiddleware/dist/12-Environment.js → ...aderFeatureBundles/dist/12-Environment.js
File renamed without changes.
View
0 ...undlerMiddleware/dist/13-AssignExports.js → ...erFeatureBundles/dist/13-AssignExports.js
File renamed without changes.
View
0 ...tureBundles/dist/Avoid-VariableRequire.js → ...tureBundles/dist/Avoid-VariableRequire.js
File renamed without changes.
View
0 ...Bundles/dist/Avoid-VariableRequire/lib.js → ...Bundles/dist/Avoid-VariableRequire/lib.js
File renamed without changes.
View
6 ...les/03-NodeJSLoaderFeatureBundles/main.js → examples/03-LoaderFeatureBundles/main.js
@@ -1,7 +1,7 @@
-var LOADER = require("sourcemint-platform-nodejs/lib/loader"),
+var LOADER = require("sourcemint-platform-nodejs/loader"),
ERROR = require("sourcemint-platform-nodejs/lib/util/error"),
- BUNDLER = require("sourcemint-bundler-js/lib/bundler"),
+ BUNDLER = require("sourcemint-platform-nodejs/lib/bundler"),
EXAMPLES = require("sourcemint-loader-js/tests/examples"),
PATH = require("path"),
FS = require("fs");
@@ -11,7 +11,7 @@ exports.main = function()
{
var done = Q.ref();
- var basePath = __dirname + "/../02-NodeJSLoaderFeatures";
+ var basePath = __dirname + "/../02-LoaderFeatures";
FS.readdirSync(basePath).forEach(function(filename)
{
View
14 examples/03-LoaderFeatureBundles/package.json
@@ -0,0 +1,14 @@
+{
+ "name": "sourcemint-platform-nodejs-examples-03-LoaderFeatureBundles",
+ "version": "0.1.0",
+ "engines": {
+ "nodejs": "0.x"
+ },
+ "dependencies": {
+ "sourcemint-loader-js": "0.x",
+ "sourcemint-platform-nodejs": "0.x"
+ },
+ "scripts": {
+ "test": "node main"
+ }
+}
View
14 examples/03-NodeJSLoaderFeatureBundles/package.json
@@ -1,14 +0,0 @@
-{
- "name": "sourcemint-platform-nodejs-examples-03-NodeJSLoaderFeatureBundles",
- "version": "0.1.0",
- "engines": {
- "nodejs": "0.x"
- },
- "dependencies": {
- "sourcemint-platform-nodejs": "0.x",
- "sourcemint-bundler-js": "0.x"
- },
- "scripts": {
- "test": "node main"
- }
-}
View
0 ...NodeJSPlatformFeatures/01-Globals/main.js → ...es/04-PlatformFeatures/01-Globals/main.js
File renamed without changes.
View
2 ...SPlatformFeatures/01-Globals/package.json → ...-PlatformFeatures/01-Globals/package.json
@@ -1,5 +1,5 @@
{
- "name": "sourcemint-platform-nodejs-examples-04-NodeJSPlatformFeatures-01-Globals",
+ "name": "sourcemint-platform-nodejs-examples-04-PlatformFeatures-01-Globals",
"version": "0.1.0",
"engines": {
"nodejs": "0.x"
View
0 ...oaderFeatureBundles/dist/01-HelloWorld.js → ...2-BundlerMiddleware/dist/01-HelloWorld.js
File renamed without changes.
View
0 ...erFeatureBundles/dist/02-ReturnExports.js → ...undlerMiddleware/dist/02-ReturnExports.js
File renamed without changes.
View
0 ...aderFeatureBundles/dist/03-SpecifyMain.js → ...-BundlerMiddleware/dist/03-SpecifyMain.js
File renamed without changes.
View
0 ...ndles/dist/04-PackageLocalDependencies.js → ...eware/dist/04-PackageLocalDependencies.js
File renamed without changes.
View
32 ...eware/dist/05-CrossPackageDependencies.js → ...eware/dist/05-CrossPackageDependencies.js
@@ -16,10 +16,10 @@ require.bundle("", function(require)
}
});
- require.memoize("32ab0c28393c3fbb23863556150045f2e480923f/greetings.js", function(require, exports, module)
+ require.memoize("9600bb1b572fba81a38e7d3c0eb638268e6a9d8d/greetings.js", function(require, exports, module)
{
- var __filename = require.sandbox.id + "32ab0c28393c3fbb23863556150045f2e480923f/greetings.js";
- var __dirname = require.sandbox.id + "/32ab0c28393c3fbb23863556150045f2e480923f";
+ var __filename = require.sandbox.id + "9600bb1b572fba81a38e7d3c0eb638268e6a9d8d/greetings.js";
+ var __dirname = require.sandbox.id + "/9600bb1b572fba81a38e7d3c0eb638268e6a9d8d";
var HELLO = require("package/hello");
@@ -34,21 +34,21 @@ require.bundle("", function(require)
}
});
- require.memoize("32ab0c28393c3fbb23863556150045f2e480923f/logger.js", function(require, exports, module)
+ require.memoize("9600bb1b572fba81a38e7d3c0eb638268e6a9d8d/logger.js", function(require, exports, module)
{
- var __filename = require.sandbox.id + "32ab0c28393c3fbb23863556150045f2e480923f/logger.js";
- var __dirname = require.sandbox.id + "/32ab0c28393c3fbb23863556150045f2e480923f";
+ var __filename = require.sandbox.id + "9600bb1b572fba81a38e7d3c0eb638268e6a9d8d/logger.js";
+ var __dirname = require.sandbox.id + "/9600bb1b572fba81a38e7d3c0eb638268e6a9d8d";
exports.log = function(message)
{
module.log(message);
}
});
- require.memoize("981e9adad3c1288b46d8ca93853deddb17e4d55d/words/hello.js", function(require, exports, module)
+ require.memoize("80b6bcb59fc2b65675648d0e052b75b4620764ee/words/hello.js", function(require, exports, module)
{
- var __filename = require.sandbox.id + "981e9adad3c1288b46d8ca93853deddb17e4d55d/words/hello.js";
- var __dirname = require.sandbox.id + "/981e9adad3c1288b46d8ca93853deddb17e4d55d/words";
+ var __filename = require.sandbox.id + "80b6bcb59fc2b65675648d0e052b75b4620764ee/words/hello.js";
+ var __dirname = require.sandbox.id + "/80b6bcb59fc2b65675648d0e052b75b4620764ee/words";
var GREETINGS = require("package/greetings");
@@ -63,19 +63,19 @@ require.bundle("", function(require)
}
});
- require.memoize("bc674b2edd42208f9c5e2bae8e66aa32b6eda600/H.js", function(require, exports, module)
+ require.memoize("aa0b8cfbcfff960996a8692caee6ae43f33d6a67/H.js", function(require, exports, module)
{
- var __filename = require.sandbox.id + "bc674b2edd42208f9c5e2bae8e66aa32b6eda600/H.js";
- var __dirname = require.sandbox.id + "/bc674b2edd42208f9c5e2bae8e66aa32b6eda600";
+ var __filename = require.sandbox.id + "aa0b8cfbcfff960996a8692caee6ae43f33d6a67/H.js";
+ var __dirname = require.sandbox.id + "/aa0b8cfbcfff960996a8692caee6ae43f33d6a67";
exports.getLetter = function()
{
return "H";
}
});
- require.memoize("/package.json", {"main":"/main.js","mappings":{"helpers":"32ab0c28393c3fbb23863556150045f2e480923f"},"directories":{"lib":""}});
- require.memoize("32ab0c28393c3fbb23863556150045f2e480923f/package.json", {"mappings":{"package":"981e9adad3c1288b46d8ca93853deddb17e4d55d"},"directories":{"lib":""}});
- require.memoize("981e9adad3c1288b46d8ca93853deddb17e4d55d/package.json", {"mappings":{"package":"32ab0c28393c3fbb23863556150045f2e480923f","letters":"bc674b2edd42208f9c5e2bae8e66aa32b6eda600"},"directories":{"lib":"words"}});
- require.memoize("bc674b2edd42208f9c5e2bae8e66aa32b6eda600/package.json", {"directories":{"lib":""},"mappings":{}});
+ require.memoize("/package.json", {"main":"/main.js","mappings":{"helpers":"9600bb1b572fba81a38e7d3c0eb638268e6a9d8d"},"directories":{"lib":""}});
+ require.memoize("9600bb1b572fba81a38e7d3c0eb638268e6a9d8d/package.json", {"mappings":{"package":"80b6bcb59fc2b65675648d0e052b75b4620764ee"},"directories":{"lib":""}});
+ require.memoize("80b6bcb59fc2b65675648d0e052b75b4620764ee/package.json", {"mappings":{"package":"9600bb1b572fba81a38e7d3c0eb638268e6a9d8d","letters":"aa0b8cfbcfff960996a8692caee6ae43f33d6a67"},"directories":{"lib":"words"}});
+ require.memoize("aa0b8cfbcfff960996a8692caee6ae43f33d6a67/package.json", {"directories":{"lib":""},"mappings":{}});
});
View
0 ...oaderFeatureBundles/dist/06-JsonModule.js → ...2-BundlerMiddleware/dist/06-JsonModule.js
File renamed without changes.
View
0 ...oaderFeatureBundles/dist/07-TextModule.js → ...2-BundlerMiddleware/dist/07-TextModule.js
File renamed without changes.
View
0 ...aderFeatureBundles/dist/08-ResourceURI.js → ...-BundlerMiddleware/dist/08-ResourceURI.js
File renamed without changes.
View
0 ...JSLoaderFeatures/08-ResourceURI/hello.txt → ...rMiddleware/dist/08-ResourceURI/hello.txt
File renamed without changes.
View
10 ...oaderFeatureBundles/dist/09-LoadBundle.js → ...2-BundlerMiddleware/dist/09-LoadBundle.js
@@ -16,21 +16,21 @@ require.bundle("", function(require)
module.log("Hello from 09-LoadBundle!");
- var extraBundleID = "./ExtraBundle";
+ var extraModuleID = "./ExtraModule";
- require.async(extraBundleID, function(EXTRA_BUNDLE)
+ require.async(extraModuleID, function(EXTRA_MODULE)
{
- EXTRA_BUNDLE.init();
+ EXTRA_MODULE.init();
result.resolve();
});
return result.promise;
}
- exports.getExtraBundleGreeting = function()
+ exports.getExtraModuleGreeting = function()
{
- return "Hello from 09-LoadBundle/ExtraBundle!";
+ return "Hello from 09-LoadBundle/ExtraModule!";
}
});
View
0 ...Bundles/dist/09-LoadBundle/ExtraBundle.js → ...dleware/dist/09-LoadBundle/ExtraBundle.js
File renamed without changes.
View
18 examples/04-PlatformFeatures/02-BundlerMiddleware/dist/09-LoadBundle/ExtraModule.js
@@ -0,0 +1,18 @@
+require.bundle("", function(require)
+{
+
+ require.memoize("/ExtraModule.js", function(require, exports, module)
+ {
+ var __filename = require.sandbox.id + "/ExtraModule.js";
+ var __dirname = require.sandbox.id + "";
+
+ var MAIN = require("./main.js");
+
+ exports.init = function()
+ {
+ module.log(MAIN.getExtraModuleGreeting());
+ }
+
+ });
+ require.memoize("/package.json", {"main":"/ExtraModule.js","directories":{"lib":""},"mappings":{}});
+});
View
0 ...JSLoaderFeatureBundles/dist/10-Sandbox.js → ...s/02-BundlerMiddleware/dist/10-Sandbox.js
File renamed without changes.
View
0 ...s/dist/10-Sandbox/SandboxedExtraBundle.js → ...e/dist/10-Sandbox/SandboxedExtraBundle.js
File renamed without changes.
View
0 ...aderFeatureBundles/dist/11-CrossDomain.js → ...-BundlerMiddleware/dist/11-CrossDomain.js
File renamed without changes.
View
0 ...aderFeatureBundles/dist/12-Environment.js → ...-BundlerMiddleware/dist/12-Environment.js
File renamed without changes.
View
0 ...erFeatureBundles/dist/13-AssignExports.js → ...undlerMiddleware/dist/13-AssignExports.js
File renamed without changes.
View
2 ...formFeatures/02-BundlerMiddleware/main.js → ...formFeatures/02-BundlerMiddleware/main.js
@@ -4,7 +4,7 @@ var PATH = require("path"),
BUNDLER = require("sourcemint-platform-nodejs/lib/bundler");
-var EXAMPLES_BASE_PATH = __dirname + "/../../02-NodeJSLoaderFeatures",
+var EXAMPLES_BASE_PATH = __dirname + "/../../02-LoaderFeatures",
LOADER_BASE_PATH = PATH.dirname(PATH.dirname(PATH.dirname(require.resolve("sourcemint-loader-js/workspace/www/index.html"))));
View
2 ...eatures/02-BundlerMiddleware/package.json → ...eatures/02-BundlerMiddleware/package.json
@@ -1,5 +1,5 @@
{
- "name": "sourcemint-platform-nodejs-examples-04-NodeJSPlatformFeatures-02-BundlerMiddleware",
+ "name": "sourcemint-platform-nodejs-examples-04-PlatformFeatures-02-BundlerMiddleware",
"version": "0.1.0",
"engines": {
"nodejs": "0.x"
View
2 ...formFeatures/02-BundlerMiddleware/test.js → ...formFeatures/02-BundlerMiddleware/test.js
@@ -1,5 +1,5 @@
-var HELPER = require("../../../tests/test-helper"),
+var HELPER = require("sourcemint-platform-nodejs/tests/test-helper"),
ASSERT = require("assert"),
BROWSER = require("zombie");
View
0 examples/04-NodeJSPlatformFeatures/main.js → examples/04-PlatformFeatures/main.js
File renamed without changes.
View
5 ...es/04-NodeJSPlatformFeatures/package.json → examples/04-PlatformFeatures/package.json
@@ -1,11 +1,12 @@
{
- "name": "sourcemint-platform-nodejs-examples-04-NodeJSPlatformFeatures",
+ "name": "sourcemint-platform-nodejs-examples-04-PlatformFeatures",
"version": "0.1.0",
"engines": {
"nodejs": "0.x"
},
"dependencies": {
- "q": "0.x"
+ "q": "0.x",
+ "sourcemint-platform-nodejs": "0.x"
},
"scripts": {
"test": "node main"
View
2 ...PlatformFeatureBundles/dist/01-Globals.js → ...PlatformFeatureBundles/dist/01-Globals.js
@@ -88,5 +88,5 @@ require.bundle("", function(require)
}
});
- require.memoize("/package.json", {"name":"sourcemint-platform-nodejs-examples-04-NodeJSPlatformFeatures-01-Globals","version":"0.1.0","engines":{"nodejs":"0.x"},"scripts":{"test":"node main"},"main":"/main.js","directories":{"lib":""},"mappings":{}});
+ require.memoize("/package.json", {"name":"sourcemint-platform-nodejs-examples-04-PlatformFeatures-01-Globals","version":"0.1.0","engines":{"nodejs":"0.x"},"scripts":{"test":"node main"},"main":"/main.js","directories":{"lib":""},"mappings":{}});
});
View
2 ...s/05-NodeJSPlatformFeatureBundles/main.js → examples/05-PlatformFeatureBundles/main.js
@@ -11,7 +11,7 @@ exports.main = function()
{
var done = Q.ref();
- var basePath = __dirname + "/../04-NodeJSPlatformFeatures";
+ var basePath = __dirname + "/../04-PlatformFeatures";
FS.readdirSync(basePath).forEach(function(filename)
{
View
2 ...NodeJSPlatformFeatureBundles/package.json → ...es/05-PlatformFeatureBundles/package.json
@@ -1,5 +1,5 @@
{
- "name": "sourcemint-platform-nodejs-examples-05-NodeJSPlatformFeatureBundles",
+ "name": "sourcemint-platform-nodejs-examples-05-PlatformFeatureBundles",
"version": "0.1.0",
"engines": {
"nodejs": "0.x"
View
77 lib/bundler.js
@@ -14,42 +14,49 @@ var FS = require("fs"),
// TODO: Use helper function from bundler where possible.
// TODO: Use AST to detect require statements.
+exports.bundle = BUNDLER.bundle;
+
+
+
exports.parseModule = function(path, options)
{
var deferred = Q.defer();
Q.call(function()
{
var report = {};
-
- var code = FS.readFileSync(path).toString();
-
- report.staticLinks = {};
- report.dynamicLinks = {};
-
- // NOTE: We wrap the module code in a function to ensure we don't fail on top-level `return`s.
- var matches = DETECTIVE.find("((function(){" + code + "})());");
- matches.strings.forEach(function(id)
+ if (/\.js$/.test(path))
{
- report.staticLinks[id] = adjustStaticLink(path, id, options);
- });
-
- if (matches.expressions.length > 0)
- {
- // TODO: Ensure there are `` defined in the package descriptor of the package.
- // TODO: Throw in struct mode.
- // throw new Error("Found variable argument to require statement 'require(" + id + ")' in module '" + path + "'. 'require()' only accepts a string literal. Use 'require.async(" + id + ", function(EXPORTS) {})' instead.");
+ var code = FS.readFileSync(path).toString();
+
+ report.staticLinks = {};
+ report.dynamicLinks = {};
+
+ // NOTE: We wrap the module code in a function to ensure we don't fail on top-level `return`s.
+ var matches = DETECTIVE.find("((function(){" + code + "})());");
+
+ matches.strings.forEach(function(id)
+ {
+ report.staticLinks[id] = adjustStaticLink(path, id, options);
+ });
+
+ if (matches.expressions.length > 0)
+ {
+ // TODO: Ensure there are `` defined in the package descriptor of the package.
+ // TODO: Throw in struct mode.
+ // throw new Error("Found variable argument to require statement 'require(" + id + ")' in module '" + path + "'. 'require()' only accepts a string literal. Use 'require.async(" + id + ", function(EXPORTS) {})' instead.");
+ }
+
+ // TODO: Use `detective` to find.
+ scrapeAsyncRequires(code).forEach(function(name)
+ {
+ report.dynamicLinks[name] = name;
+ });
+
+ // TODO: Look for `require.resolve("<str>")` and `require.id("<str>")`.
}
- // TODO: Use `detective` to find.
- scrapeAsyncRequires(code).forEach(function(name)
- {
- report.dynamicLinks[name] = name;
- });
-
- // TODO: Look for `require.resolve("<str>")` and `require.id("<str>")`.
-
deferred.resolve(report);
}).fail(function(err)
{
@@ -177,15 +184,15 @@ exports.resolveUri = function(uri)
{
return Q.call(function()
{
- if (PATH.existsSync(uri))
- {
- return FS.realpathSync(uri);
- }
+ if (PATH.existsSync(uri + ".js"))
+ {
+ return FS.realpathSync(uri + ".js");
+ }
else
- if (PATH.existsSync(uri + ".js"))
- {
- return FS.realpathSync(uri + ".js");
- }
+ if (PATH.existsSync(uri))
+ {
+ return FS.realpathSync(uri);
+ }
else
if (/^nodejs\.org\/0\//.test(uri))
{
@@ -292,7 +299,9 @@ var Middleware = exports.Middleware = function(packagePath, distributionPath, op
if (middlewareInstances[key])
{
- return middlewareInstances[key];
+ if (options.rebuild !== true) {
+ return middlewareInstances[key];
+ }
}
return middlewareInstances[key] = new Middleware(packagePath, distributionPath, options);
View
5 loader.js
@@ -0,0 +1,5 @@
+
+var LOADER = require("./lib/loader");
+
+for (var name in LOADER)
+ exports[name] = LOADER[name];
View
2 package.json
@@ -4,12 +4,12 @@
"dependencies": {
"q": "0.x",
"sourcemint-loader-js": "0.x",
+ "sourcemint-bundler-js": "0.x",
"detective": "0.x",
"connect": "1.x"
},
"devDependencies": {
"vows": "0.x",
- "sourcemint-bundler-js": "0.x",
"n-util": "0.x",
"zombie": "0.x"
},
View
10 tests/adapter/vows.js
@@ -1,6 +1,7 @@
var VOWS = require("vows"),
- ASSERT = require("assert");
+ ASSERT = require("assert"),
+ EXAMPLES = require("../examples");
VOWS.describe("Tests").addBatch(
@@ -10,14 +11,17 @@ VOWS.describe("Tests").addBatch(
topic: function()
{
var self = this;
- require("../examples").main().then(function() {
+ EXAMPLES.main({
+ packageBasePath: __dirname + "/../..",
+ extraExamples: EXAMPLES.extraExamples
+ }).then(function() {
self.callback(true);
}, function(err) {
// NOTE: If this fires and `err` instanceof Error `vows` will fail this test.
self.callback(err);
});
},
- "all examples passed": function(status)
+ "all examples worked": function(status)
{
ASSERT.equal(status, true);
}
View
198 tests/examples.js
@@ -3,12 +3,23 @@ var Q = require("q"),
PATH = require("path"),
FS = require("fs"),
EXEC = require("child_process").exec,
- UTIL = require("n-util");
-
-const EXAMPLES_BASE_PATH = __dirname + "/../examples";
+ UTIL = require("n-util"),
+ ERROR = require("../lib/util/error");
exports.main = function(options)
{
+ const PACKAGE_BASE_PATH = FS.realpathSync(options.packageBasePath);
+ const EXAMPLES_BASE_PATH = PACKAGE_BASE_PATH + ((typeof options.examplesPath !== "undefined")?options.examplesPath:"/examples");
+
+ var RELATIVE_PATH = "/..";
+ if (typeof options.examplesPath !== "undefined") {
+ if (options.examplesPath === "") {
+ RELATIVE_PATH = "";
+ } else {
+ throw new Error("NYI");
+ }
+ }
+
return linkPackages().then(function(packages)
{
var done = Q.ref();
@@ -19,100 +30,117 @@ exports.main = function(options)
{
return installMissingDependencies(EXAMPLES_BASE_PATH + "/" + packageName).then(function()
{
- console.log("Running example: " + EXAMPLES_BASE_PATH + "/" + packageName);
-
- return require(EXAMPLES_BASE_PATH + "/" + packageName + "/main.js").main();
+ if (options.run === false) return;
+
+ console.log("Running example: " + EXAMPLES_BASE_PATH + "/" + packageName);
+
+ return require(EXAMPLES_BASE_PATH + "/" + packageName + "/main.js").main().fail(function(err) {
+ ERROR.logError(err);
+ throw err;
+ });
});
});
});
return done;
});
-}
-
-
-function installMissingDependencies(packageRootPath)
-{
- var deferred = Q.defer();
-
- EXEC("npm install", {
- cwd: packageRootPath
- }, function(err, stdout, stderr)
- {
- if (err) deferred.reject(err);
- else if (stderr) deferred.reject(stderr)
- else {
- process.stdout.write(stdout);
- deferred.resolve();
- }
- });
-
- return deferred.promise;
-}
-
-
-function linkPackages()
-{
- var packages = [];
- if (!PATH.existsSync(__dirname + "/../node_modules"))
+ function installMissingDependencies(packageRootPath)
{
- FS.mkdirSync(__dirname + "/../node_modules", 0775);
- }
- try {
- // TODO: Find a symlink test that does not throw if it does not exist.
- FS.lstatSync(__dirname + "/../node_modules/sourcemint-platform-nodejs");
- } catch(e) {
- FS.symlinkSync("..", __dirname + "/../node_modules/sourcemint-platform-nodejs");
+ var deferred = Q.defer();
+
+ EXEC("npm install", {
+ cwd: packageRootPath
+ }, function(err, stdout, stderr)
+ {
+ if (err) deferred.reject(err);
+ else if (stderr) deferred.reject(stderr)
+ else {
+ process.stdout.write(stdout);
+ deferred.resolve();
+ }
+ });
+
+ return deferred.promise;
}
- var ourDescriptor = JSON.parse(FS.readFileSync(__dirname + "/../package.json"));
-
- FS.readdirSync(EXAMPLES_BASE_PATH).concat([
- "04-NodeJSPlatformFeatures/02-BundlerMiddleware"
- ]).forEach(function(filename)
+ function linkPackages()
{
- var basePath = EXAMPLES_BASE_PATH + "/" + filename;
-
- if (PATH.existsSync(basePath + "/package.json"))
- {
- if (filename.split("/").length === 1) {
- packages.push(filename);
- }
-
- var descriptor = JSON.parse(FS.readFileSync(basePath + "/package.json"));
-
- if (!PATH.existsSync(basePath + "/node_modules"))
- {
- FS.mkdirSync(basePath + "/node_modules", 0775);
- }
-
- var deps = descriptor.devDependencies || {};
- UTIL.update(deps, descriptor.dependencies || {});
- Object.keys(deps).forEach(function(name)
- {
- if (name === "sourcemint-platform-nodejs" ||
- ourDescriptor.dependencies[name] === descriptor.dependencies[name] ||
- ourDescriptor.devDependencies[name] === descriptor.dependencies[name]
- ) {
- try {
- // TODO: Find a symlink test that does not throw if it does not exist.
- FS.lstatSync(basePath + "/node_modules/" + name);
- } catch(e) {
- FS.symlinkSync(filename.replace(/[^\/]+/g, "..") + "/../../node_modules/" + name, basePath + "/node_modules/" + name);
- }
- }
- });
- }
- });
-
- return Q.call(function() {
- return packages;
- });
+ var packages = [];
+
+ if (!PATH.existsSync(PACKAGE_BASE_PATH + "/node_modules"))
+ {
+ FS.mkdirSync(PACKAGE_BASE_PATH + "/node_modules", 0775);
+ }
+
+ var ourDescriptor = JSON.parse(FS.readFileSync(PACKAGE_BASE_PATH + "/package.json"));
+
+ if (ourDescriptor.name === "sourcemint-platform-nodejs") {
+ try {
+ // TODO: Find a symlink test that does not throw if it does not exist.
+ FS.lstatSync(PACKAGE_BASE_PATH + "/node_modules/sourcemint-platform-nodejs");
+ } catch(e) {
+ FS.symlinkSync("..", PACKAGE_BASE_PATH + "/node_modules/sourcemint-platform-nodejs");
+ }
+ } else
+ if (ourDescriptor.name === "sourcemint-sdk-requirejs") {
+ try {
+ // TODO: Find a symlink test that does not throw if it does not exist.
+ FS.lstatSync(PACKAGE_BASE_PATH + "/node_modules/sourcemint-sdk-requirejs");
+ } catch(e) {
+ FS.symlinkSync("..", PACKAGE_BASE_PATH + "/node_modules/sourcemint-sdk-requirejs");
+ }
+ }
+
+ FS.readdirSync(EXAMPLES_BASE_PATH).concat(options.extraExamples || []).forEach(function(filename)
+ {
+ var basePath = EXAMPLES_BASE_PATH + "/" + filename;
+
+ if (PATH.existsSync(basePath + "/package.json"))
+ {
+ if (filename.split("/").length === 1) {
+ packages.push(filename);
+ }
+
+ var descriptor = JSON.parse(FS.readFileSync(basePath + "/package.json"));
+
+ if (!PATH.existsSync(basePath + "/node_modules"))
+ {
+ FS.mkdirSync(basePath + "/node_modules", 0775);
+ }
+
+ var deps = descriptor.devDependencies || {};
+ UTIL.update(deps, descriptor.dependencies || {});
+ Object.keys(deps).forEach(function(name)
+ {
+ if (name === ourDescriptor.name ||
+ (ourDescriptor.dependencies && ourDescriptor.dependencies[name] === deps[name]) ||
+ (ourDescriptor.devDependencies && ourDescriptor.devDependencies[name] === deps[name])
+ ) {
+ try {
+ // TODO: Find a symlink test that does not throw if it does not exist.
+ FS.lstatSync(basePath + "/node_modules/" + name);
+ } catch(e) {
+ FS.symlinkSync(filename.replace(/[^\/]+/g, "..") + RELATIVE_PATH + "/../node_modules/" + name, basePath + "/node_modules/" + name);
+ }
+ }
+ });
+ }
+ });
+
+ return Q.call(function() {
+ return packages;
+ });
+ }
}
+exports.extraExamples = [
+ "04-PlatformFeatures/02-BundlerMiddleware"
+];
-if (require.main === module)
-{
- exports.main();
+if (require.main === module) {
+ exports.main({
+ packageBasePath: __dirname + "/..",
+ extraExamples: exports.extraExamples
+ });
}
View
7 tests/test-helper.js
@@ -44,7 +44,12 @@ exports.makeTest = function(REQUIRE, EXPORTS, MODULE, testCallback)
}
if (REQUIRE.main === MODULE) {
- EXPORTS.main().fail(ERROR.logError);
+ EXPORTS.main().fail(function(err) {
+ ERROR.logError(err);
+
+ // TODO: Get rid of this once we know why the event loop sometimes hangs on error.
+ process.exit(0);
+ });
}
}

0 comments on commit 5913953

Please sign in to comment.