Skip to content

Commit

Permalink
Fixes requirejs#344, do not find obj.require calls for runtime depend…
Browse files Browse the repository at this point in the history
…ency scanning
  • Loading branch information
jrburke committed Jun 27, 2012
1 parent 31660dd commit e37fff7
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 2 deletions.
2 changes: 1 addition & 1 deletion require.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ var requirejs, require, define;

var version = '2.0.2+',
commentRegExp = /(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg,
cjsRequireRegExp = /require\s*\(\s*["']([^'"\s]+)["']\s*\)/g,
cjsRequireRegExp = /[^.]\s*require\s*\(\s*["']([^'"\s]+)["']\s*\)/g,
jsSuffixRegExp = /\.js$/,
currDirRegExp = /^\.\//,
ostring = Object.prototype.toString,
Expand Down
1 change: 1 addition & 0 deletions tests/all.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ doh.registerUrl("dataMainBaseUrl", "../dataMain/baseUrl/dataMainBaseUrl.html");
if (hasToString) {
doh.registerUrl("anonSimple", "../anon/anonSimple.html");
doh.registerUrl("cjsSpace", "../cjsSpace/cjsSpace.html");
doh.registerUrl("cjsDotRequire", "../cjsSpace/cjsDotRequire.html");
doh.registerUrl("packages", "../packages/packages.html");
}

Expand Down
9 changes: 9 additions & 0 deletions tests/cjsSpace/c.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
define(function (require) {
if (typeof obj !== 'undefined') {
obj.require('bad');
}
return {
name: 'c'
};
});

18 changes: 18 additions & 0 deletions tests/cjsSpace/cjsDotRequire-tests.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
require({
baseUrl: './'
},
['a', 'c'],
function(a, c) {
doh.register(
'cjsDotRequire',
[
function cjsDotRequire(t){
t.is('a', a.name);
t.is('b', a.b.name);
t.is('c', c.name);
}
]
);
doh.run();
}
);
16 changes: 16 additions & 0 deletions tests/cjsSpace/cjsDotRequire.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!DOCTYPE html>
<html>
<head>
<title>require.js: Skipping false obj.require('') Test</title>
<script type="text/javascript" src="../../require.js"></script>
<script type="text/javascript" src="../doh/runner.js"></script>
<script type="text/javascript" src="../doh/_browserRunner.js"></script>
<script type="text/javascript" src="cjsDotRequire-tests.js"></script>
</head>
<body>
<h1>require.js: Skipping false obj.require('') Test</h1>
<p>Test for <a href="https://github.com/jrburke/requirejs/issues/344">Issue 344</a>.
Make sure modules that have obj.require() calls do not get found as dependencies.</p>
<p>Check console for messages</p>
</body>
</html>
2 changes: 1 addition & 1 deletion updatesubs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ echo "Updating the cajon project"
cp require.js ../cajon/tools/require.js
cp ../r.js/r.js ../cajon/tools/r.js
cd ../cajon/tools
./build.sh
./build-cajon.sh
cd ../../requirejs

# The require-cs project
Expand Down

0 comments on commit e37fff7

Please sign in to comment.