Permalink
Browse files

RequireJS minimal hoist example

  • Loading branch information...
1 parent 1c3b75b commit 8e14c359c4e2bd71f631074a14f88e13f61df89c @cadorn cadorn committed Mar 11, 2012
@@ -0,0 +1 @@
+/.sourcemint/
@@ -0,0 +1,12 @@
+
+require('http').createServer(function (req, res) {
+ if (req.url === "/") {
+ res.end('<script type="text/javascript" src="/ui.js"></script>');
+ }
+ else if (/^\/ui(\.js$|\/)/.test(req.url)) {
+ req.params = [ req.url.match(/^\/ui(?:\.js)?(\/.*)?$/)[1] ];
+ require("sourcemint-platform-nodejs/lib/bundler").hoist(__dirname + "/ui", {
+ bundleLoader: true
+ })(req, res);
+ }
+}).listen(1337, '127.0.0.1');
@@ -0,0 +1,11 @@
+{
+ "private": true,
+ "name": "sourcemint-examples-js-03-RequireJSMinimalHoist",
+ "version": "0.1.0",
+ "engines": {
+ "nodejs": "0.x"
+ },
+ "dependencies": {
+ "sourcemint-platform-nodejs": "0.x"
+ }
+}
@@ -0,0 +1,8 @@
+
+define(function(require, exports, module)
+{
+ exports.getGreeting = function()
+ {
+ return "Hello from 03-RequireJSMinimalHoist UI";
+ }
+});
@@ -0,0 +1,8 @@
+
+define(function(require, exports, module)
+{
+ exports.main = function()
+ {
+ console.log(require("./greetings").getGreeting());
+ }
+});
@@ -0,0 +1,8 @@
+{
+ "main": "./main.js",
+ "config": {
+ "github.com/sourcemint/bundler-js/0/-meta/config/0": {
+ "adapter": "github.com/sourcemint/sdk-requirejs/0"
+ }
+ }
+}
View
@@ -25,7 +25,8 @@ if (require.main === module) {
{
var exampleBasePath = basePath + "/" + filename;
- if (PATH.existsSync(exampleBasePath + "/package.json"))
+ if (PATH.existsSync(exampleBasePath + "/package.json") &&
+ PATH.existsSync(exampleBasePath + "/test.js"))
{
done = Q.when(done, function()
{

0 comments on commit 8e14c35

Please sign in to comment.