Permalink
Browse files

Make work with Browserify.

This depends on 0x00A/codesurgeon#13 being accepted. Once it is, and the codesurgeon dependency is updated, the existing build script will produce a file that can be used either with <script> tag includes, or with browserify (and any other browser-based CommonJS module loaders).

Furthermore, this adds a "browserify" entry in package.json pointing to the browser-built file, so that users can just do `require("director")` instead of `require("director/build/director-1.1.3")`.
  • Loading branch information...
1 parent de03237 commit 69e23d429d432df67bd3003b2dac0d40373cdcf9 @domenic domenic committed Jul 27, 2012
Showing with 32 additions and 1 deletion.
  1. +3 −1 .gitignore
  2. +1 −0 package.json
  3. +24 −0 test/browser/browserify-harness.html
  4. +4 −0 test/browser/helpers/api.js
View
@@ -1,4 +1,6 @@
/.idea/
node_modules
npm-debug.log
-.DS_Store
+.DS_Store
+
+/test/browser/browserified-bundle.js
View
@@ -30,6 +30,7 @@
"vows": "0.6.x"
},
"ender": "./build/ender.js",
+ "browserify": "./build/director-1.1.3",
"main": "./lib/director",
"engines": {
"node": ">= 0.4.0"
@@ -0,0 +1,24 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+ <meta charset="UTF-8">
+ <title>Director Browserify Tests</title>
+ <link rel="stylesheet" href="../../node_modules/qunitjs/qunit/qunit.css">
+</head>
+<body>
+ <p>To run these tests first generate a Browserify bundle for director by running the command <kbd>browserify -r ../director -o test/browser/browserified-bundle.js</kbd> in the repo's root directory.</p>
+
+ <div id="qunit">
+ <div id="qunit-fixture"></div>
+
+ <script src="browserified-bundle.js"></script>
+ <script>
+ var HTML5TEST = false;
+ var RouterAlias = require('/director-1.1.3').Router;
+ </script>
+
+ <script src="../../node_modules/qunitjs/qunit/qunit.js"></script>
+ <script src="helpers/api.js"></script>
+ <script src="routes-test.js"></script>
+</body>
+</html>
@@ -19,6 +19,10 @@ module("Director.js", {
var shared;
function createTest(name, config, use, test, initialRoute) {
+ // We rename to `RouterAlias` for the browserify tests, since we want to be
+ // sure that no code is depending on `window.Router` being available.
+ var Router = window.Router || window.RouterAlias;
+
if (typeof use === 'function') {
test = use;
use = undefined;

0 comments on commit 69e23d4

Please sign in to comment.