You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<p>Where main.js has contents that look like this:</p>
908
-
909
-
<pre><code>//Set up any config values, baseUrl is required so module names
910
-
//will map correctly to paths.
911
-
require({
912
-
baseUrl: 'path/to/scripts'
913
-
});
914
-
915
-
//Now load the top level script.
916
-
require(['startingscript']);
917
-
</code></pre>
918
-
919
-
<p>You can see an example of RequireJS working in Rhino by looking at <ahref="http://github.com/jrburke/requirejs/blob/master/adapt/tests/all.js">adapt/tests/all.js</a>.</p>
902
+
<p>RequireJS can be used in Rhino via the <ahref="download.html#rjs">r.js adapter</a>.
903
+
See <ahref="https://github.com/jrburke/r.js/blob/master/README.md">the r.js README</a> for more information.</p>
<liclass="hbox"><ahref="#rjs">r.js: Optimizer and Node and Rhino adapter</a><spanclass="spacer boxFlex"></span><spanclass="sect">§ 1.3</span></li>
<p><ahref="api.html#text">Load text files and treat them as dependencies</a>. Great for loading templates. The text strings can be inlined in an optimized build when the optimizer is used.</p>
<p><ahref="api.html#order">Load script in the order specified in the dependency array</a>. Useful for existing scripts that have implied dependencies instead of calling define() to create modular code.</p>
<p><ahref="api.html#i18n">Load string bundles</a> used in internationalization (i18n) that are made up of separate country/language/locale-specific bundles.</p>
<p>The awesome part: the optimizer is now just one JS file! It also doubles as a bootstrap script that supports the full capability of AMD modules and loader plugins in Node and in Rhino.</p>
115
+
116
+
<p>To use the optimizer, pass the "-o" option to r.js:</p>
117
+
118
+
<pre> node r.js -o app.build.js</pre>
119
+
120
+
<p>To run your AMD-based project via the adapter (assuming server.js is your top-level AMD module):</p>
121
+
122
+
<pre> node r.js server.js</pre>
123
+
124
+
<p>There is more information about <ahref="http://requirejs.org/docs/node.html">running AMD modules in Node</a>. The <ahref="http://requirejs.org/docs/optimization.html">optimizer docs</a> have been updated to the new optimizer syntax, and the r.js script has <ahref="https://github.com/jrburke/r.js">its own project now</a>, to allow releases that are decoupled from require.js.</p>
125
+
126
+
<p>Other highlights:</p>
127
+
128
+
<ul><li>The loader plugin API changed to allow plugins to create cross-domain-accessible re
F438
sources. The main use case: you use the text plugin to dynamically load text resources, but you want to deploy those scripts to a CDN. See the <ahref="http://requirejs.org/docs/download.html#text">text plugin</a>'s implementation of writeFile() as an example.
129
+
</li><li>There is now a global <spanstyle="font-weight: bold;">requirejs()</span> function object that is the same as the old global <spanstyle="font-weight: bold;">require()</span> function object. This should allow RequireJS to work better in environments like <ahref="http://mozillalabs.com/chromeless/">Mozilla Chromeless</a>, which already have a built-in require() function that does not have full AMD/loader plugin capabilities.
130
+
</li><li>It is now possible to <ahref="http://requirejs.org/docs/api.html#config-jQuery">specify the precise version of jQuery</a> to allow in a RequireJS context. This is useful if you know of other scripts that load different versions of jQuery on a page.</li></ul>
131
+
132
+
<p>Some changes in the name of compatibility with other AMD module loaders and Node:</p>
133
+
134
+
135
+
<ul><li>The "lib" directory configuration in package support was removed. It was always very awkward to support, and Node no longer supports it, so it was enough justification to remove it.</li><li>Relative module IDs are now relative to the related module ID, not the related module ID path.</li><li>includeRequire in the optimizer config was removed, Use a paths config to include require.js instead. See the Optimization docs for more details.</li></ul>
136
+
137
+
<p>A small change to the context-specific require() passed to <ahref="http://requirejs.org/docs/plugins.html#apiload">a loader plugin's load() call</a>: require.isDefined() is now require.defined() and there is require. specified().</p>
138
+
111
139
<h3>0.24.0</h3>
112
140
113
141
<ul>
@@ -146,104 +174,4 @@ <h3>0.22.0</h3>
146
174
<li>Support for <ahref="optimization.html#hasjs">has.js optimizations</a> in the optimizer, including dead code branch removal via Closure Compiler.</a>
147
175
<li><ahref="https://github.com/jrburke/requirejs/commits/">Bug Fixes from 2010-12-21 through 2011-01-05</a>.</li>
148
176
</ul>
149
-
150
-
<h3>0.2.1 (should have been 0.21.0)</h3>
151
-
152
-
<ul>
153
-
<li>[Bug Fixes from 2010-12-16 through 2010-12-19](https://github.com/jrburke/requirejs/commits/)</li>
154
-
</ul>
155
-
156
-
<h3>0.2.0 (should have been 0.20.0)</h3>
157
-
158
-
<ul>
159
-
<li>Refactored core.</li>
160
-
<li>New loader plugin API support.</li>
161
-
<li>Improved Rhino and Node adapters</li>
162
-
<li>Bug fixes around loader plugins and the optimizer.</li>
163
-
<li>require.modify removed.</li>
164
-
<li>Removed Transport D files.</li>
165
-
</ul>
166
-
167
-
<h3>0.15.0</h3>
168
-
169
-
<ul>
170
-
<li>The bundled jQuery options now use jQuery 1.4.4.</li>
171
-
<li>The jQuery sample project now includes the ability to use RequireJS plugins.</li>
172
-
<li>The jsonp! plugin has been removed, since, thanks to work by Kris Zyp, the core loader now supports loading JSONP dependencies by default. The <ahref="http://requirejs.org/docs/api.html#jsonp">JSONP docs</a> have been updated accordingly.</li>
173
-
<li>The optimizer can now be run from any directory, not just the directory with the build profile.</li>
174
-
<li>r.js Node adapter is more robust, and it can handle using more Node-written modules by default now. Thanks to Francois Laberge for a great test case application that lead to improving the robustness of r.js.</li>
175
-
<li>Initial support for PS3 Netfront browser. Thanks to Chris Warren for investigating the load behavior of the browser. Not all tests pass, but the basic ones do.</li>
176
-
<li>Miscellaneous fixes, some listed in <ahref="https://github.com/jrburke/requirejs/issues/closed#sort=updated">the issue tracker</a>.</li>
177
-
</ul>
178
-
179
-
<h3>0.14.5</h3>
180
-
181
-
<ul>
182
-
<li><ahref="http://github.com/jrburke/requirejs/commit/88847fe53ab2e97e7ba7ec8f2afc056fb29b0a70">Fix bug</a> where scripts were not loaded from the correct path. Did not affect RequireJS+jQuery builds, but affected other builds. If you do not use a RequireJS+jQuery build, then it is strongly recommended that you upgrade from 0.14.4 to 0.14.5.</li>
183
-
<li>Added an urlArgs <ahref="http://requirejs.org/docs/api.html#config">config option</a> to allow for cache busting when servers/browser misbehave during development.</li>
184
-
</ul>
185
-
186
-
<h3>0.14.4</h3>
187
-
188
-
<ul>
189
-
<li>Support jQuery 1.4.3. The bundled RequireJS+jQuery bundle now uses RequireJS 1.4.3, and it is now possible to load jQuery directly from a CDN.</li>
190
-
<li>Remove the Transport D pre-built option from the download page. The Transport D adapter is still in the source bundler though.</li>
191
-
</ul>
192
-
193
-
<h3>0.14.3</h3>
194
-
195
-
<ul>
196
-
<li>Support for <strong>define()</strong>. It works the same as <strong>require.def()</strong>. It is supported in order to conform with the <ahref="http://wiki.commonjs.org/wiki/Modules/AsynchronousDefinition">Asynchronous Module Proposal</a>. require.def will continue to work, but you are encouraged to gradually migrate to define() for better compatibly with other Async Module loaders.</li>
197
-
<li>text! plugin now works in Node.</li>
198
-
<li><em>_dirname and _</em>filename support in the r.js Node adapter.</li>
199
-
<li><ahref="http://github.com/jrburke/requirejs/commit/79188c726f90aefa34a16435e929a7bb98098358">Bug fix for priority option</a>.</li>
200
-
<li>GPL license option removed: project is now just MIT and new BSD dual-licensed, since the new BSD license is compatible with the GPL.</li>
201
-
</ul>
202
-
203
-
<h3>0.14.2</h3>
204
-
205
-
<ul>
206
-
<li>Bug fixes:
207
-
<ul>
208
-
<li><ahref="http://github.com/jrburke/requirejs/commit/079e8b1e0abd4b77f0cd898c4bd77f24581942f5">Fix issue with "module" dependency</a> not correctly assigning exported value if it is <em>not</em> listed as the last dependency.</li>
209
-
<li><ahref="http://github.com/jrburke/requirejs/commit/e89c6c1523ac59e7303407d506f8e2ce75cdeb31">Fix "packages" config option</<
AE9B
/span>a>. Its behavior was fixed to match the docs.</li>
210
-
<li><ahref="http://github.com/jrburke/requirejs/commit/416f24a6f556c0d96f9fd9d4146a9ecfcd337668">Fix module-to-name resolution</a> to account for package mappings.</li>
<li><ahref="api.html#packages">Loading modules from CommonJS packages</a>.</li>
230
-
<li><ahref="http://github.com/jrburke/requirejs/commits/master">Bug fixes</a> (see commits starting from (see commits starting from 2010-09-15 through 2010-09-26))</li>
231
-
</ul>
232
-
233
-
<h3>0.13.0</h3>
234
-
235
-
<ul>
236
-
<li>module.setExports and module.exports are now supported for converted CommonJS modules.</li>
237
-
<li><ahref="http://github.com/jrburke/requirejs/commits/master">Bug fixes</a> (see commits starting from 2010-07-05 through 2010-09-10), in particular <ahref="http://github.com/jrburke/requirejs/commit/d12935bac803bcd5981652584102282b69fdd7b1">a fix to throw when a timeout for a script occurs</a>. That fix should make debugging issues much easier.</li>
238
-
</ul>
239
-
240
-
<h3>0.12.0</h3>
241
-
242
-
<ul>
243
-
<li>A new plugin: <ahref="api.html#order">order</a> -- it ensures that scripts are fetched asynchronously and in parallel, but executed in the order specified in the call to require(). Ideal for traditional browser scripts that do not participate in modules defined via calls to require.def().</li>
244
-
<li><ahref="api.html#webworker">Web Worker support</a>. RequireJS can be used in a web worker.</li>
245
-
<li>Multiple module names can now be mapped via the <strong>paths</strong> config option to the same URL, and that URL will only be fetched once.</li>
246
-
<li>Added Firefox 2 to supported browsers. Safari 3.2 also works with require().</li>
247
-
<li><ahref="http://github.com/jrburke/requirejs/commits/master">Bug fixes</a> (see commits starting from 2010-05-25 through 2010-07-04), in particular <ahref="http://github.com/jrburke/requirejs/commit/c3ae5e96f0aadd549f30a4019fe021c057e76f50">a fix for the priority config</a>, and <ahref="http://github.com/jrburke/requirejs/commit/98d418fe4e4503575cca18b73260c0ab74f365fc">improved support in IE with a bad base tag</a>.</li>
Copy file name to clipboardExpand all lines: docs/node.html
+3Lines changed: 3 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -22,6 +22,9 @@ <h2>
22
22
</h2>
23
23
24
24
<p>Yes <ahref="http://nodejs.org">Node</a> does. That loader uses the CommonJS module format. The CommonJS module format is <ahref="why.html">non-optimal for the browser</a>, and I do not agree with <ahref="http://tagneto.blogspot.com/2010/03/commonjs-module-trade-offs.html">some of the trade-offs made in the CommonJS module format</a>. 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.</p>
25
+
26
+
<p>The situation has improved a bit in Node 0.5.0 and later, which supports the <ahref="commonjs.html#manualconversion">"simplified CommonJS wrapper" version of define()</a>. While this is helpful for some base library purposes, it does not include support for <ahref="api.html#defdep">dependency arrays in define()</a> or <ahref="plugins.html">loader plugins</a>. So using the r.js RequireJS adapter is useful for making sure your code will run as you expect across browser and Node environments.</p>
0 commit comments