Skip to content

Commit 36810cf

Browse files
committed
Removing includeRequire, note how to include require.js using the requireLib approach.
1 parent 400db22 commit 36810cf

File tree

8 files changed

+14
-27
lines changed

8 files changed

+14
-27
lines changed

build/example.build.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,6 @@
136136
{
137137
name: "foo/bar/bop",
138138

139-
//Should the contents of require.js be included in the optimized module.
140-
//Defaults to false.
141-
includeRequire: true,
142-
143139
//For build profiles that contain more than one modules entry,
144140
//allow overrides for the properties that set for the whole build,
145141
//for example a different set of pragmas for this module.

build/jslib/build.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -445,10 +445,6 @@ function (lang, logger, file, parse, optimize, pragma,
445445
}
446446
];
447447

448-
if (config.includeRequire) {
449-
config.modules[0].includeRequire = true;
450-
}
451-
452448
//Does not have a build file, so set up some defaults.
453449
//Optimizing CSS should not be allowed, unless explicitly
454450
//asked for on command line. In that case the only task is
@@ -614,7 +610,7 @@ function (lang, logger, file, parse, optimize, pragma,
614610
var buildFileContents = "",
615611
context = layer.context,
616612
path, reqIndex, fileContents, currContents,
617-
i, moduleName, includeRequire,
613+
i, moduleName,
618614
parts, builder, writeApi;
619615

620616
//Use override settings, particularly for pragmas

build/tests/builds.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,14 @@ define(['build', 'env!env/file'], function (build, file) {
1414
return contents.replace(/[\r\n]/g, "");
1515
}
1616

17-
//Do a build of require.js to get default pragmas processed.
18-
build(["..", "name=require", "baseUrl=../..", "out=builds/require.js", "includeRequire=true", "optimize=none"]);
19-
2017
//Do a build of the text plugin to get any pragmas processed.
2118
build(["..", "name=text", "baseUrl=../..", "out=builds/text.js", "optimize=none"]);
2219

2320
//Reset build state for next run.
2421
require._buildReset();
2522

26-
var requirejs = c("builds/require.js"),
27-
requireTextContents = c("builds/text.js"),
23+
var requireTextContents = c("builds/text.js"),
2824
oneResult = [
29-
requirejs,
3025
c("../../tests/two.js"),
3126
c("../../tests/one.js"),
3227
c("../../tests/dimple.js")
@@ -51,7 +46,7 @@ define(['build', 'env!env/file'], function (build, file) {
5146
[
5247
function buildOneJsFile(t) {
5348
build(["..", "name=one", "include=dimple", "out=builds/outSingle.js",
54-
"baseUrl=../../tests", "includeRequire=true", "optimize=none"]);
49+
"baseUrl=../../tests", "optimize=none"]);
5550

5651
t.is(nol(oneResult), nol(c("builds/outSingle.js")));
5752

build/tests/simple.build.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
modules: [
88
{
99
name: "one",
10-
include: ["dimple"],
11-
includeRequire: true
10+
include: ["dimple"]
1211
}
1312
]
1413
})

docs/faq-advanced.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ <h4>2) Modify loaded files</h4>
4848
}(myGlobalRequire));
4949
</code></pre>
5050

51-
<p>Following the steps above should allow you to use the optimization tool to combine scripts together effectively. You should not use the <strong>includeRequire</strong> optimization option though. If you want your renamed require definition in the optimized script, reference your modified require.js directly in the <strong>include</strong> optimization option, or as the <strong>name</strong> option if you want to optimize that file directly.</p>
51+
<p>Following the steps above should allow you to use the optimization tool to combine scripts together effectively. If you want your renamed require definition in the optimized script, reference your modified require.js directly in the <strong>include</strong> optimization option, or as the <strong>name</strong> option if you want to optimize that file directly.</p>
5252

5353
<p>Thanks to <a href="http://alexsexton.com/">Alex Sexton</a> and <a href="http://tobielangel.com/">Tobie Langel</a> for suggesting parts of this solution.</p>
5454
</div>

docs/optimization.html

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,12 +135,14 @@ <h2>
135135

136136
<p>Normally you should <strong>not</strong> save optimized files with your pristine project source. Normally you would save them to a copy of your project, but to make this example easier it is saved with the source. Change the <strong>out=</strong> option to any directory you like, that has a copy of your source. Then, you can change the main-built.js file name to just main.js so the HTML page will load the optimized version of the file.</p>
137137

138-
<p>If you wanted to include require.js with the main.js source, you can use this command:</p>
138+
<p>It is not recommended that you bundle require.js with your main.js file. Ideally require.js should be the same file contents wherever it is used. However, if you do need to include require.js with the main.js source, you can use this command:</p>
139139

140-
<pre><code>../../requirejs/build/build.sh name=main out=main-built.js baseUrl=. includeRequire=true
140+
<pre><code>../../requirejs/build/build.sh baseUrl=. paths.requireLib=../../require name=main include=requireLib out=main-built.js
141141
</code></pre>
142142

143-
<p>Once that is done, you can then rename the main-built.js file to require.js and your optimized project will only need to make one script request!</p>
143+
<p>Since "require" is a reserved dependency name, you create a "requireLib" dependency and map it to the require.js file.</p>
144+
145+
<p>Once that optimization is done, you can then rename the main-built.js file to require.js and your optimized project will only need to make one script request.</p>
144146
</div>
145147

146148
<div class="section">
@@ -150,7 +152,7 @@ <h2><a name="shallow">Shallow exclusions for fast development</a><span class="se
150152

151153
<p>You can do this by using the <strong>excludeShallow</strong> option. Using the <a href="#example">example setup</a> above, assume you are currently building out or debugging two.js. You could use thing optimization command:</p>
152154

153-
<pre><code>../../requirejs/build/build.sh name=main excludeShallow=two out=main-built.js baseUrl=. includeRequire=true
155+
<pre><code>../../requirejs/build/build.sh name=main excludeShallow=two out=main-built.js baseUrl=.
154156
</code></pre>
155157

156158
<p>If you do not want the main-build.js file minified, pass <strong>optimize=none</strong> in the command above.</p>

tasks.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
Release Notes
22
-------------------
33
- exports and return use is stricter: if exports is in play, return value is ignored.
4+
- includeRequire is removed, use paths: {requireLib: "../../require"} to get require in it.
5+
See the optimization.html for the requireLib example.
46

57
Next release
68
--------------
79

8-
- Removal of includeRequire option? Scrub all references, mention on list.
9-
- paths: {requireLib: "../../require"} to get require in it.
10-
1110
- text plugins after a build load xdomain?
1211
- move urlFetched outside of load function and do the check before load.
1312
- replacement for modify that intercepts callbacks, holds off until another module loads them?

tests/layers/build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
../../build/build.sh baseUrl=../.. name=require includeRequire=true include=i18n,text,order, out=allplugins-require.js optimize=none
1+
../../build/build.sh baseUrl=../.. name=require include=i18n,text,order, out=allplugins-require.js optimize=none

0 commit comments

Comments
 (0)