diff --git a/adapt/node.js b/adapt/node.js index 7d98f805..55feefa3 100644 --- a/adapt/node.js +++ b/adapt/node.js @@ -16,7 +16,8 @@ (function () { var req = nodeRequire, fs = req('fs'), - path = req('path'); + path = req('path'), + vm = req('vm'); //Clear out the global set by x.js nodeRequire = null; @@ -63,7 +64,7 @@ if (path.existsSync(url)) { contents = fs.readFileSync(url, 'utf8'); - process.compile(contents, url); + vm.runInThisContext(contents, url); } else { define(function () { return req(moduleName); diff --git a/bin/x.js b/bin/x.js index 892cb248..bd438001 100644 --- a/bin/x.js +++ b/bin/x.js @@ -17,7 +17,7 @@ var console; (function (args, readFileFunc) { - var fileName, env, fs, exec, rhinoContext, + var fileName, env, fs, vm, exec, rhinoContext, requireBuildPath = '', jsSuffixRegExp = /\.js$/, //This flag is turned to false by the distribution script, @@ -57,15 +57,16 @@ var console; //Get the fs module via Node's require before it //gets replaced. Used in require/node.js fs = require('fs'); + vm = require('vm'); this.nodeRequire = require; require = null; readFile = function (path) { - return process.compile(fs.readFileSync(path, 'utf8'), path); + return fs.readFileSync(path, 'utf8'); }; exec = function (string, name) { - return process.compile(string, name); + return vm.runInThisContext(string, name); }; if (useRequireBuildPath) { diff --git a/docs/download.html b/docs/download.html index 0667e868..075022c8 100644 --- a/docs/download.html +++ b/docs/download.html @@ -83,7 +83,11 @@

RequireJS adapter for Node and Rhino

-

r.js: use this file if you want to code to the RequireJS module format in Node. The Node instructions explain how to use it. It includes all the code needed for RequireJS to function with Node.

+

r.js: use this file if you want to code to the RequireJS module format in Node or Rhino.

+ +

Use in Node

+ +

Requires Node 0.4.0 or higher. The Node instructions explain how to use it. It includes all the code needed for RequireJS to function with Node.

index.js: the standard HTTP server-based Hello World app for Node, but coded to work with the r.js adapter. Download it in the same directory as r.js and then run this command:

@@ -92,6 +96,8 @@

RequireJS adapter for Node and Rhino

Then you can go to http://127.0.0.1:8000/ and see "Hello World" printed after about 2 seconds.

+

Use in Rhino

+

The r.js adapter also runs under Rhino. Use it like so, where main.js is your application's top level file:

java -jar path/to/rhino/js.jar r.js main.js
diff --git a/docs/optimization.html b/docs/optimization.html
index 7bc4fd6f..4ed2932f 100644
--- a/docs/optimization.html
+++ b/docs/optimization.html
@@ -33,7 +33,7 @@ 

The optimization tool can be run using either Node or using Java with Rhino. The requirements for each option:

    -
  • Node: (preferred) Node 0.2.6 or later.
  • +
  • Node: (preferred) Node 0.4.0 or later.
  • Java: Java 1.6 or later.
diff --git a/tasks.txt b/tasks.txt index 26aaaece..622123d6 100644 --- a/tasks.txt +++ b/tasks.txt @@ -29,12 +29,8 @@ flag was set to false when calling ast_squeeze. If I left this flag set to true Bugs to work on ------------------ -- Test on Node 0.3, adjust optimization docs if special considerations. - - Test build scripts on windows. -- "dojo with requirejs": https://github.com/neonstalwart/dojo-requirejs-template - - plugins in excludeShallow do not work, are not excluded. For example text! one. - "libs/static.lib.02", //kaaahhhhnnnn!!! @@ -45,7 +41,6 @@ Bugs to work on - replacement for modify that intercepts callbacks, holds off until another module loads them? - - coffeescript plugin - Support Node's "extensions" mechanism.