oberhamsi/gamejs — Issue #37: yabble - remove comments before searching for require()
Author: oberhamsi
Created: 2011-11-04 09:42:41+00:00
State: open
Labels: im_too_young_to_die

see sea.js or requirejs

// http://lifesinger.github.com/lab/2011/remove-comments-safely/
function removeComments(code) {
return code
.replace(/(?:^|\n|\r)\s*\/\*[\s\S]*?\*\/\s*(?:\r|\n|$)/g, '\n')
.replace(/(?:^|\n|\r)\s*\/\/.*(?:\r|\n|$)/g, '\n');
}

https://github.com/seajs/seajs/blob/master/src/fn-define.js