Permalink
Browse files

Doc updates, cleanup, and prepping for 0.10.0 release.

  • Loading branch information...
1 parent a228f54 commit d821f9a6c9fc30229f4b692c89a61b66b0340494 @jrburke jrburke committed Apr 23, 2010
Showing with 80 additions and 37 deletions.
  1. +3 −3 README.md
  2. +6 −1 build/convert/node/dist.js
  3. +11 −2 dist/dist-build.sh
  4. +1 −1 dist/main.css
  5. +4 −1 dist/pre.html
  6. +38 −22 docs/download.md
  7. +16 −6 docs/node.md
  8. +1 −1 require.js
View
6 README.md
@@ -1,6 +1,6 @@
# RequireJS
-RequireJS loads plain JavaScript files as well as more defined modules. It is optimized for in-browser use, but it can be used in other JavaScript environments, like Rhino. It implements the [CommonJS Transport/C proposal](http://wiki.commonjs.org/wiki/Modules/Transport/C) API.
+RequireJS loads plain JavaScript files as well as more defined modules. It is optimized for in-browser use, but it can be used in other JavaScript environments, like Rhino and [Node](requirejs/tree/master/docs/node.md). It implements the [CommonJS Transport/C proposal](http://wiki.commonjs.org/wiki/Modules/Transport/C) API.
RequireJS uses plain script tags to load modules/files, so it should allow for easy debugging. It can be used [simply to load existing JavaScript files](requirejs/tree/master/docs/api.md#jsfiles), so you can add it to your existing project without having to re-write your JavaScript files.
@@ -10,11 +10,11 @@ If the JavaScript file defines a JavaScript module via [require.def()](requirejs
RequireJS does not have any dependencies on a JavaScript framework. It is tri-licensed -- BSD, MIT, and GPL.
-The core require.js file around 3.5KB when minified via Closure Compiler and gzipped. require.js can also be built without some features, with the smallest option (just dependency tracking and simple module loading) weighing in at 2.5KB minified, gzipped.
+The standard require.js file is around 3.7KB when minified via Closure Compiler and gzipped. require.js can be built without some features, with the smallest option (just dependency tracking and simple module loading) weighing in at 2.6KB minified, gzipped.
The unit tests work in IE 6+, Firefox 3.0+, Safari 4+, Chrome 3+, and Opera 10+.
-Latest Release: [0.9.0](http://requirejs.org/docs/download.html)
+Latest Release: [0.10.0](http://requirejs.org/docs/download.html)
* [Start](requirejs/tree/master/docs/start.md)
* [Using it with jQuery](requirejs/tree/master/docs/jquery.md)
View
7 build/convert/node/dist.js
@@ -39,7 +39,12 @@ var injected = [
fileUtil.readFile("../../jslib/commonJs.js")
].join("\n"),
- requirejs = fileUtil.readFile("../../../require.js"),
+ requirejs = [
+ fileUtil.readFile("../../../require.js"),
+ fileUtil.readFile("../../../require/i18n.js"),
+ fileUtil.readFile("../../../require/text.js")
+ ].join("\n");
+
adapter = fileUtil.readFile("requireAdapter.js"),
r = fileUtil.readFile("r-source.js");
View
13 dist/dist-build.sh
@@ -49,8 +49,17 @@ cd docs/jquery-require-sample
./dist.sh
cp dist/jquery-require-sample.zip ../../../$version
-# Minify any of the JS files
-cd ../../../$version/comments
+# Create node integration layer
+cd ../../
+cd build/convert/node
+java -jar ../../lib/rhino/js.jar dist.js
+mkdir ../../../../$version/node
+cp r.js ../../../../$version/node
+cp index.js ../../../../$version/node
+cd ../../../
+
+# Minify any of the browser-based JS files
+cd ../$version/comments
java -jar ../../requirejs-$version/build/lib/closure/compiler.jar --js require.js --js_output_file ../minified/require.js
java -jar ../../requirejs-$version/build/lib/closure/compiler.jar --js allplugins-require.js --js_output_file ../minified/allplugins-require.js
java -jar ../../requirejs-$version/build/lib/closure/compiler.jar --js require-$jqueryName --js_output_file ../minified/require-$jqueryName
View
2 dist/main.css
@@ -41,7 +41,7 @@ pre {
}
#nav li.section {
- margin-top: 15px;
+ margin-top: 30px;
}
#nav a {
View
5 dist/pre.html
@@ -31,6 +31,9 @@
<li><a class="local" href="api.html">API</a></li>
<li><a class="local" href="optimization.html">Optimization</a></li>
+ <li class="section"><a class="local" href="jquery.html">Use with jQuery</a></li>
+ <li><a class="local" href="node.html">Use with Node</a></li>
+
<!-- li class="section"><a class="local" href="faq.html">FAQs</a></li -->
<li class="section"><a class="local" href="why.html">Why</a></li>
@@ -44,6 +47,6 @@
<li class="section"><a href="http://github.com/jrburke/requirejs">GitHub</a></li>
<li><a class="local" href="contributing.html">Contributing</a></li>
- <li class="section">0.9.0 Docs</li>
+ <li class="section">0.10.0 Docs</li>
</ul>
<div id="content">
View
60 docs/download.md
@@ -1,32 +1,21 @@
# Download RequireJS
-## Releases
+### Latest Release: 0.10.0
-### 0.9.0
+* [RequireJS works in Node](node.md).
+* [Optimization tool enhancements](optimization.md):
+ * For a given module, you can now use **exclude** to exclude some modules and their nested dependencies.
+ * Use **excludeShallow** to just exclude a specific module, but still include its nested dependencies. This is particularly useful during development. You can do an optimized build, but just excludeShallow the current module you are developing/debugging to get fast dev load times, but still allow easy debugging and development.
-* **Optimization tool refactored and improved**
- * Basic CSS optimizations are in! @import urls are inlined (with url() paths properly adjusted), and comments are removed.
- * Robust nested dependency tracing by use of an AST. As a result, the build option execModules is false by default now. This is what most people need, so it is no long necessary to include execModules: false in your build profile.
- * Now possible to build just one JS file or one CSS file at a time, no need for a build profile! See the [Optimization docs](optimization.md) for full details.
- * **Backwards incompatible change**: the format of build profiles has changed. It no longer uses require() calls but it is a completely declarative format. This should be more robust for the future, and it allowed for a cleaner refactoring of the optimization tool.
-* **Support for relative module names in require.def dependencies**
- * require.def("my/project/module", ["./dependency1"], function(){}); will now load my/project/dependency1.js. This should help cut down the amount of typing for larger projects.
- * The first argument to require.def, which gives the name of the module being defined, still needs to be a full name. It cannot be a relative name (cannot start with a . or ..).
- * require.nameToUrl() does not accept relative names.
-* **Backwards incompatible change**: text! plugin URLs now use . instead of ! for the file extension. So, instead of "text!some/module/sample!html" it is now "text!some/module/sample.html". Please update your code, the old !html will no longer work.
-* Bug fixes
-
-This release has a couple backwards incompatible changes. These kinds of changes will be generally avoided, and more notice via the RequireJS mailing list will be given if it needs to happen again. RequireJS has not reached 1.0, so these kinds of changes may still happen. However, there should be less of a need for a backwards incompatiable change now, and as of today, none are forecasted.
-
-#### <a name="requirejs">require.js</a> [Minified](http://requirejs.org/docs/release/0.9.0/minified/require.js) | [With Comments](http://requirejs.org/docs/release/0.9.0/comments/require.js)
+#### <a name="requirejs">require.js</a> [Minified](http://requirejs.org/docs/release/0.10.0/minified/require.js) | [With Comments](http://requirejs.org/docs/release/0.10.0/comments/require.js)
All you need to start using require.js. Does not include i18n, text plugins or rhino support.
-#### <a name="requirejsplugins">require.js with plugins</a> [Minified](http://requirejs.org/docs/release/0.9.0/minified/allplugins-require.js) | [With Comments](http://requirejs.org/docs/release/0.9.0/comments/allplugins-require.js)
+#### <a name="requirejsplugins">require.js with plugins</a> [Minified](http://requirejs.org/docs/release/0.10.0/minified/allplugins-require.js) | [With Comments](http://requirejs.org/docs/release/0.10.0/comments/allplugins-require.js)
require.js with the i18n and text plugins included.
-#### <a name="jqueryrequirejs">jQuery 1.4.2 with require()</a> [Minified](http://requirejs.org/docs/release/0.9.0/minified/require-jquery-1.4.2.js) | [With Comments](http://requirejs.org/docs/release/0.9.0/comments/require-jquery-1.4.2.js)
+#### <a name="jqueryrequirejs">jQuery 1.4.2 with require()</a> [Minified](http://requirejs.org/docs/release/0.10.0/minified/require-jquery-1.4.2.js) | [With Comments](http://requirejs.org/docs/release/0.10.0/comments/require-jquery-1.4.2.js)
A build of jQuery with integrated require() support. Just includes the basic RequireJS, does not have the following features:
@@ -35,7 +24,7 @@ A build of jQuery with integrated require() support. Just includes the basic Req
* page load support (it is assumed you will use jQuery's methods)
* require.modify() support
-#### <a name="jqueryrequirejsplugins">jQuery 1.4.2 with require() and plugins</a> [Minified](http://requirejs.org/docs/release/0.9.0/minified/requireplugins-jquery-1.4.2.js) | [With Comments](http://requirejs.org/docs/release/0.9.0/comments/requireplugins-jquery-1.4.2.js)
+#### <a name="jqueryrequirejsplugins">jQuery 1.4.2 with require() and plugins</a> [Minified](http://requirejs.org/docs/release/0.10.0/minified/requireplugins-jquery-1.4.2.js) | [With Comments](http://requirejs.org/docs/release/0.10.0/comments/requireplugins-jquery-1.4.2.js)
A build of jQuery with integrated require() support and the i18n and text plugins. Does not include these other RequireJS features:
@@ -47,7 +36,7 @@ The integrated builds with jQuery contain the changes in [this jQuery fork](http
<hr>
-#### <a name="samplejquery">Sample jQuery 1.4.2 project with require()</a> [Download](http://requirejs.org/docs/release/0.9.0/jquery-require-sample.zip)
+#### <a name="samplejquery">Sample jQuery 1.4.2 project with require()</a> [Download](http://requirejs.org/docs/release/0.10.0/jquery-require-sample.zip)
A zip file containing a build of jQuery with integrated require() support, with an sample project included to show how it can be used when using jQuery. Does not include these features in RequireJS:
@@ -58,7 +47,19 @@ A zip file containing a build of jQuery with integrated require() support, with
<hr>
-#### <a name="optimizationtool">Optimization Tool / Full Source</a> [Download](http://requirejs.org/docs/release/0.9.0/requirejs-0.9.0.zip)
+#### <a name="node">RequireJS adapter for Node</a>
+
+**[r.js](http://requirejs.org/docs/release/0.10.0/node/r.js)**: use this file if you want to code to the RequireJS module format in Node. The [Node instructions](node.md) explain how to use it. It includes all the code needed for RequireJS to function with Node.
+
+**[index.js](http://requirejs.org/docs/release/0.10.0/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:
+
+ node r.js index.js
+
+Then you can go to http://127.0.0.1:8000/ and see "Hello World" printed after about 2 seconds.
+
+<hr>
+
+#### <a name="optimizationtool">Optimization Tool / Full Source</a> [Download](http://requirejs.org/docs/release/0.10.0/requirejs-0.10.0.zip)
A zip file that is the optimization tool for RequireJS. It also includes the full source for require.js and its plugins.
@@ -70,6 +71,21 @@ If you want to use RequireJS in Rhino, you should use this download.
### Previous releases
+### 0.9.0
+
+* **Optimization tool refactored and improved**
+ * Basic CSS optimizations are in! @import urls are inlined (with url() paths properly adjusted), and comments are removed.
+ * Robust nested dependency tracing by use of an AST. As a result, the build option execModules is false by default now. This is what most people need, so it is no long necessary to include execModules: false in your build profile.
+ * Now possible to build just one JS file or one CSS file at a time, no need for a build profile! See the [Optimization docs](optimization.md) for full details.
+ * **Backwards incompatible change**: the format of build profiles has changed. It no longer uses require() calls but it is a completely declarative format. This should be more robust for the future, and it allowed for a cleaner refactoring of the optimization tool.
+* **Support for relative module names in require.def dependencies**
+ * require.def("my/project/module", ["./dependency1"], function(){}); will now load my/project/dependency1.js. This should help cut down the amount of typing for larger projects.
+ * The first argument to require.def, which gives the name of the module being defined, still needs to be a full name. It cannot be a relative name (cannot start with a . or ..).
+ * require.nameToUrl() does not accept relative names.
+* **Backwards incompatible change**: text! plugin URLs now use . instead of ! for the file extension. So, instead of "text!some/module/sample!html" it is now "text!some/module/sample.html". Please update your code, the old !html will no longer work.
+* Bug fixes
+
+This release has a couple backwards incompatible changes. These kinds of changes will be generally avoided, and more notice via the RequireJS mailing list will be given if it needs to happen again. RequireJS has not reached 1.0, so these kinds of changes may still happen. However, there should be less of a need for a backwards incompatiable change now, and as of today, none are forecasted.
### 0.8.0
View
22 docs/node.md
@@ -1,36 +1,46 @@
# RequireJS in Node
-There is some preliminary support for RequireJS for use in [Node](http://nodejs.org).
+You can use RequireJS in [Node](http://nodejs.org).
## Doesn't Node already have a module loader?
Yes it does. That loader uses the CommonJS module format. The CommonJS module format is [non-optimal for the browser](why.md), and I do not prefer [some of the trade-offs made in the CommonJS module format](http://tagneto.blogspot.com/2010/03/commonjs-module-trade-offs.html). By using RequireJS on the server, you can use one format for all your modules, whether they are running server side or in the browser. That way you can preserve the speed benefits and easy debugging you get with RequireJS in the browser, and not have to worry about extra translation costs for moving between two formats.
## Can I use server modules already written in the CommonJS module format?
-Yes! The Node adapter for RequireJS, called r.js, automatically converts CommonJS modules to the RequireJS format on the fly, as they are loaded, so you can use your existing modules without modifying them.
+Yes! The Node adapter for RequireJS, called r.js, automatically converts CommonJS modules to the RequireJS format on the fly, as they are loaded, so you can use your existing modules without having to hand-modify them.
-However, RequireJS does not use search paths for modules. It only does the following:
+However, the top most app file, the one you pass to Node on startup, needs to be coded to the RequireJS API. That file is evaluated as-is, no automatic format conversion.
+
+Notes on the automatic format conversion:
+
+RequireJS does not use search paths for modules. It only does the following:
* If the module ID is one of the modules that Node contains within itself (the ones in the Node's lib directory in its source distribution), it will be used.
-* Otherwise the module is assumed to be relative to the file that is given to node to start your app.
+* Otherwise the module is assumed to be relative to the file that is given to Node to start your app.
You can always use the [Configuration Options](api.md#config) for RequireJS in your top level app file to configure paths and even a different baseUrl for your modules.
-Also, even though RequireJS is an asynchronous loader in the browser, the RequireJS Node adapter loads modules synchronously in the Node environment. This was done to make the adapter easier to code. The adapter could be made asynchronous, but the primary benefit of RequireJS integration with Node is to allow you to write modules in the same format on the server and for the browser that work well in both environments.
+RequireJS does not support require.main and the module free variable only contains an **id** property. It dose not define a require.async method, since require() in RequireJS can accept roughly equivalent arguments.
+
+Even though RequireJS is an asynchronous loader in the browser, the RequireJS Node adapter loads modules synchronously in the Node environment. This was done to make the adapter easier to code. The adapter could be made asynchronous, but the primary benefit of RequireJS integration with Node is to allow you to write modules in the same format on the server and for the browser.
Finally, RequireJS in Node can only load modules that are on the local disk -- fetching modules across http, for instance, is not supported at this time.
+For RequireJS features: the text plugin does not work in Node at the moment, but that should be fixed by the next RequireJS release.
+
## How do I use it?
Download r.js from the [the download page](download.md#node) and place it on your disk somewhere. Then run this command:
node path/to/r.js myNodeApp.js
-This assumes you are in the directory that contains myNodeApp.js, your top-level node application file.
+This assumes you are in the directory that contains myNodeApp.js, your top-level Node application file.
That is it!
+If you want to try a sample app that works with r.js, see the index.js Hello World app on [the download page](download.md#node).
+
The on-the-fly CommonJS module conversion could hit edge cases where it may not work. If you need to get get some visibility into where it failed, you can pass **debug** after r.js to get some printout on the converstion process and any problems during module execution:
node path/to/r.js debug myNodeApp.js
View
2 require.js
@@ -16,7 +16,7 @@ setInterval: false */
var require;
(function () {
//Change this version number for each release.
- var version = "0.9.0",
+ var version = "0.10.0",
empty = {}, s,
i, defContextName = "_", contextLoads = [],
scripts, script, rePkg, src, m, cfg, setReadyState,

0 comments on commit d821f9a

Please sign in to comment.