Skip to content

Commit 04425f6

Browse files
committed
Make sure define.amd is there for builds. Closes requirejs#35. Snapshot included.
1 parent 7023fa0 commit 04425f6

File tree

5 files changed

+9074
-10
lines changed

5 files changed

+9074
-10
lines changed

build/jslib/requirePatch.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ function (file, pragma, parse) {
112112
return oldDef.apply(require, arguments);
113113
};
114114

115+
define.amd = oldDef.amd;
116+
115117
//Add some utilities for plugins
116118
require._readFile = file.readFile;
117119
require._fileExists = function (path) {

build/jslib/x.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @license r.js 1.0.1 Copyright (c) 2010-2011, The Dojo Foundation All Rights Reserved.
2+
* @license r.js 1.0.1+ Copyright (c) 2010-2011, The Dojo Foundation All Rights Reserved.
33
* Available via the MIT or new BSD license.
44
* see: http://github.com/jrburke/requirejs for details
55
*/
@@ -20,7 +20,7 @@ var requirejs, require, define;
2020

2121
var fileName, env, fs, vm, path, exec, rhinoContext, dir, nodeRequire,
2222
nodeDefine, exists, reqMain, loadedOptimizedLib,
23-
version = '1.0.1',
23+
version = '1.0.1+',
2424
jsSuffixRegExp = /\.js$/,
2525
commandOption = '',
2626
//Used by jslib/rhino/args.js

build/tests/lib/plugins/converter.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
define(['util'], function (util) {
1+
if (typeof define === 'function' && define.amd) {
2+
define(['util'], function (util) {
23

3-
return {
4-
version: '2',
5-
convert: function (text) {
6-
return util(text);
7-
}
8-
};
9-
});
4+
return {
5+
version: '2',
6+
convert: function (text) {
7+
return util(text);
8+
}
9+
};
10+
});
11+
}

build/tests/parse.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ define(['parse'], function (parse) {
5151
good6 = 'function baz(){ var foo = { bar: function() { define("one", function(){ var two = require("two"); }); } };}',
5252
good7 = "(function (factory){\nif(typeof define === 'function' && define.amd){\ndefine(['dep'], factory);\n}else{\nfactory(this.dep);\n}\n}(function(dep){\n}));",
5353
good8 = "(function (factory){\nif(typeof define === 'function' && define.amd){\ndefine('some/name', ['dep1', 'dep2'], factory);\n}else{\nfactory(this.dep);\n}\n}(function(dep){\n}));",
54+
good9 = "define(function (require) {\n//Dependencies with no usable return value.\nrequire('plugin!some/value');\n});",
5455
emptyAnon1 = "define(function(){ return 'foo'; });";
5556

5657
t.is('define("one",["two","three"]);', parse("good1", "good1", good1));
@@ -61,6 +62,7 @@ define(['parse'], function (parse) {
6162
t.is('define("one",["two"]);', parse("good6", "good6", good6));
6263
t.is('define("good7",["dep"]);', parse("good7", "good7", good7));
6364
t.is('define("some/name",["dep1","dep2"]);', parse("good8", "good8", good8));
65+
t.is('define("good9",["require","plugin!some/value"]);', parse("good9", "good9", good9));
6466
t.is('define("foo",[]);', parse("nested1", "nested1", nested1));
6567
t.is('define("one",["me"]);', parse("bad1", "bad1", bad1));
6668
t.is(null, parse("bad2", "bad2", bad2));
@@ -70,6 +72,7 @@ define(['parse'], function (parse) {
7072
t.is(['require', 'foo'], parse.getAnonDeps("goodAnon1", goodAnon1));
7173
t.is(['require', 'exports', 'module', 'bar'], parse.getAnonDeps("goodAnon2", goodAnon2));
7274
t.is(['require', 'exports', 'module'], parse.getAnonDeps("goodAnon3", goodAnon3));
75+
t.is(['require', 'plugin!some/value'], parse.getAnonDeps("good9", good9));
7376
t.is(0, parse.getAnonDeps("emptyAnon1", emptyAnon1).length);
7477
}
7578
]

0 commit comments

Comments
 (0)