lib/amd.js
function moduleSize(id, paths) {
    var path = id;
    var extension = '.js';
    // Use `paths:` to resolve an alias.
    if (paths[id]) {
        path = paths[id];
    }
    // Does the dependency reference a plugin?
    if (path.indexOf('!') !== -1) {
        // Split into plugin and path.
        var pathParts = path.split('!');
        // Often, the plugin maps to the extension it handles.
        extension = '.' + pathParts[0];
        path = pathParts[1];
    }
    // Try to get the file at the path.
    var stats;
    try {
        stats = fs.statSync(path);
        return stats['size'];
    }
    catch(e) {}

    // Didn't find it? Let's try again with the extension added.
    if (path.slice(-extension.length) !== extension) {
        path = path + extension;
    }
    try {
        stats = fs.statSync(path);
        return stats['size'];
    }
    catch(e) {}

    // Still didn't find the file.
    return null;
}
function moduleSize(id, paths) {
    var path = id;
    var extension = '.js';
    // Use `paths:` to resolve an alias.
    if (paths[id]) {
        path = paths[id];
    }
    // Does the dependency reference a plugin?
    if (path.indexOf('!') !== -1) {
        // Split into plugin and path.
        var pathParts = path.split('!');
        // Often, the plugin maps to the extension it handles.
        extension = '.' + pathParts[0];
        path = pathParts[1];
    }
    // Try to get the file at the path.
    var stats;
    try {
        stats = fs.statSync(path);
        return stats['size'];
    }
    catch(e) {}

    // Didn't find it? Let's try again with the extension added.
    if (path.slice(-extension.length) !== extension) {
        path = path + extension;
    }
    try {
        stats = fs.statSync(path);
        return stats['size'];
    }
    catch(e) {}

    // Still didn't find the file.
    return null;
}
function moduleSize ( id , paths ) { var path = id ; var extension = '.js' ; // Use `paths:` to resolve an alias. if ( paths [ id ] ) { path = paths [ id ] ; } // Does the dependency reference a plugin? if ( path . indexOf ( '!' ) !== - 1 ) { // Split into plugin and path. var pathParts = path . split ( '!' ) ; // Often, the plugin maps to the extension it handles. extension = '.' + pathParts [ 0 ] ; path = pathParts [ 1 ] ; } // Try to get the file at the path. var stats ; try { stats = fs . statSync ( path ) ; return stats [ 'size' ] ; } catch ( e ) { } // Didn't find it? Let's try again with the extension added. if ( path . slice ( - extension . length ) !== extension ) { path = path + extension ; } try { stats = fs . statSync ( path ) ; return stats [ 'size' ] ; } catch ( e ) { } // Still didn't find the file. return null ; }
Returns the size of a module given its ID.
At best this can be considered an estimate because it will return the
size before compression, and doesn't take into consideration the effect
of plugins.
If the module cannot be resolved to a file, returns null.
Returns the size of a module given its ID . At best this can be considered an estimate because it will return the size before compression and doesn t take into consideration the effect of plugins . If the module cannot be resolved to a file returns null .