Your first bit of code should actually be
define(['a', 'b'], function(a, b) { } );
and the second bit as
define(function(require, exports, module) {
var a = require('a');
var b = require('b');
});
When you use the second bit of code requirejs has to parse the function.toString() to find the require statements and add them as a dependency.