Skip to content

Commit

Permalink
Use node 0.4.0 as baseline level of support, use vm modules intead of…
Browse files Browse the repository at this point in the history
… process.compile.
  • Loading branch information
jrburke committed Feb 15, 2011
1 parent a86441c commit a082a9c
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 12 deletions.
5 changes: 3 additions & 2 deletions adapt/node.js
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
7 changes: 4 additions & 3 deletions bin/x.js
Expand Up @@ -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,
Expand Down Expand Up @@ -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) {
Expand Down
8 changes: 7 additions & 1 deletion docs/download.html
Expand Up @@ -83,7 +83,11 @@ <h4 class="hbox">
<div class="subSection">
<h4><a name="node">RequireJS adapter for Node and Rhino</a></h4>

<p><strong><a href="http://requirejs.org/docs/release/0.22.0/r.js">r.js</a></strong>: use this file if you want to code to the RequireJS module format in Node. The <a href="node.html">Node instructions</a> explain how to use it. It includes all the code needed for RequireJS to function with Node.</p>
<p><strong><a href="http://requirejs.org/docs/release/0.22.0/r.js">r.js</a></strong>: use this file if you want to code to the RequireJS module format in Node or Rhino.</p>

<p><strong>Use in Node</strong></p>

<p>Requires Node 0.4.0 or higher. The <a href="node.html">Node instructions</a> explain how to use it. It includes all the code needed for RequireJS to function with Node.</p>

<p><strong><a href="http://requirejs.org/docs/release/0.22.0/node/index.js">index.js</a></strong>: 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:</p>

Expand All @@ -92,6 +96,8 @@ <h4><a name="node">RequireJS adapter for Node and Rhino</a></h4>

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

<p><strong>Use in Rhino</strong></p>

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

<pre><code>java -jar path/to/rhino/js.jar r.js main.js
Expand Down
2 changes: 1 addition & 1 deletion docs/optimization.html
Expand Up @@ -33,7 +33,7 @@ <h2>
<p>The optimization tool can be run using either Node or using Java with Rhino. The requirements for each option:<p>

<ul>
<li><strong>Node:</strong> (preferred) <a href="http://nodejs.org">Node</a> 0.2.6 or later.</li>
<li><strong>Node:</strong> (preferred) <a href="http://nodejs.org">Node</a> 0.4.0 or later.</li>
<li><strong>Java:</strong> <a href="http://java.com/">Java 1.6</a> or later.</li>
</ul>

Expand Down
5 changes: 0 additions & 5 deletions tasks.txt
Expand Up @@ -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!!!
Expand All @@ -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.

Expand Down

0 comments on commit a082a9c

Please sign in to comment.