build/amd2common.js
function parse(raw) {
    var output = '';
    var ast = esprima.parse(raw, {
        range: true,
        raw: true
    });

    var defines = ast.body.filter(isDefine);

    if (defines.length > 1) {
        throw new Error('Each file can have only a single define call. Found "' + defines.length + '"');
    }
    else if (!defines.length) {
        return raw;
    }

    var def = defines[0];
    var args = def.expression['arguments'];
    var factory = getFactory(args);
    var useStrict = getUseStrict(factory);

    // do replacements in-place to avoid modifying the code more than needed
    if (useStrict) {
        output += useStrict.expression.raw + ';\n';
    }
    output += raw.substring(0, def.range[0]); // anything before define
    output += getRequires(args, factory); // add requires
    output += getBody(raw, factory.body, useStrict); // module body

    output += raw.substring(def.range[1], raw.length); // anything after define

    return output;
}
function parse(raw) {
    var output = '';
    var ast = esprima.parse(raw, {
        range: true,
        raw: true
    });

    var defines = ast.body.filter(isDefine);

    if (defines.length > 1) {
        throw new Error('Each file can have only a single define call. Found "' + defines.length + '"');
    }
    else if (!defines.length) {
        return raw;
    }

    var def = defines[0];
    var args = def.expression['arguments'];
    var factory = getFactory(args);
    var useStrict = getUseStrict(factory);

    // do replacements in-place to avoid modifying the code more than needed
    if (useStrict) {
        output += useStrict.expression.raw + ';\n';
    }
    output += raw.substring(0, def.range[0]); // anything before define
    output += getRequires(args, factory); // add requires
    output += getBody(raw, factory.body, useStrict); // module body

    output += raw.substring(def.range[1], raw.length); // anything after define

    return output;
}
function parse ( raw ) { var output = '' ; var ast = esprima . parse ( raw , { range : true , raw : true } ) ; var defines = ast . body . filter ( isDefine ) ; if ( defines . length > 1 ) { throw new Error ( 'Each file can have only a single define call. Found "' + defines . length + '"' ) ; } else if ( ! defines . length ) { return raw ; } var def = defines [ 0 ] ; var args = def . expression [ 'arguments' ] ; var factory = getFactory ( args ) ; var useStrict = getUseStrict ( factory ) ; // do replacements in-place to avoid modifying the code more than needed if ( useStrict ) { output += useStrict . expression . raw + ';\n' ; } output += raw . substring ( 0 , def . range [ 0 ] ) ; // anything before define output += getRequires ( args , factory ) ; // add requires output += getBody ( raw , factory . body , useStrict ) ; // module body output += raw . substring ( def . range [ 1 ] , raw . length ) ; // anything after define return output ; }
Convert AMD-style JavaScript string into node.js compatible module
Convert AMD - style JavaScript string into node . js compatible module