Permalink
Browse files

Better detection of AMD vs CommonJS format

  • Loading branch information...
1 parent 972f605 commit 7d719a3f97b26dca5d8e1bde33c00cfcc00f7735 @kriszyp committed Sep 21, 2010
Showing with 2 additions and 1 deletion.
  1. +2 −1 lib/nodules.js
View
3 lib/nodules.js
@@ -551,7 +551,8 @@ exports.load = function(uri, require){
function createFactory(uri, source){
try{
factories[uri] = compile("function(require, exports, module, __filename, __dirname, Worker, SharedWorker){" + source + "\n;return exports;}", uri);
- if(source.indexOf("require.def") > -1){
+ var indexOfExport, indexOfRequireDef = source.indexOf("require.def");
+ if(indexOfRequireDef > -1 && ((indexOfExport = source.indexOf("exports.")) == -1 || indexOfExport > indexOfRequireDef)){
// looks like it is an Aynchronous module definition module
factories[uri]({def: function(id, dependencies, factory){
if(!factory){

0 comments on commit 7d719a3

Please sign in to comment.