index.js
function getJsImports(importType) {
    if (cache.jsImports[importType]) {
        return cache.jsImports[importType];
    }

    var unprefixedImports = {};

    if (cache.jsImports._unprefixedImports) {
        unprefixedImports = cache.jsImports._unprefixedImports;
    } else {
        var semanticUiReactPath = getPackagePath('semantic-ui-react');
        if (!semanticUiReactPath) {
            error('Package semantic-ui-react could not be found. Install semantic-ui-react or set convertMemberImports ' +
                'to false.');
        }

        var srcDirPath = path.resolve(semanticUiReactPath, 'src');

        var searchFolders = [
            'addons',
            'behaviors',
            'collections',
            'elements',
            'modules',
            'views'
        ];

        searchFolders.forEach(function (searchFolder) {
            var searchRoot = path.resolve(srcDirPath, searchFolder);

            dirTree(searchRoot, {extensions: /\.js$/}, function (item) {
                var basename = path.basename(item.path, '.js');

                // skip files that do not start with an uppercase letter
                if (/[^A-Z]/.test(basename[0])) {
                    return;
                }

                if (unprefixedImports[basename]) {
                    error('duplicate react component name \'' + basename + '\' - probably the plugin needs an update');
                }
                unprefixedImports[basename] = item.path.substring(srcDirPath.length).replace(/\\/g, '/');
            });
        });

        cache.jsImports._unprefixedImports = unprefixedImports;
    }

    var prefix;
    if (importType === 'src') {
        prefix = '/src';
    } else {
        prefix = '/dist/' + importType;
    }

    cache.jsImports[importType] = {};
    for(var key in unprefixedImports) {
        if (unprefixedImports.hasOwnProperty(key)) {
            cache.jsImports[importType][key] = prefix + unprefixedImports[key];
        }
    }

    return cache.jsImports[importType];
}
function getJsImports(importType) {
    if (cache.jsImports[importType]) {
        return cache.jsImports[importType];
    }

    var unprefixedImports = {};

    if (cache.jsImports._unprefixedImports) {
        unprefixedImports = cache.jsImports._unprefixedImports;
    } else {
        var semanticUiReactPath = getPackagePath('semantic-ui-react');
        if (!semanticUiReactPath) {
            error('Package semantic-ui-react could not be found. Install semantic-ui-react or set convertMemberImports ' +
                'to false.');
        }

        var srcDirPath = path.resolve(semanticUiReactPath, 'src');

        var searchFolders = [
            'addons',
            'behaviors',
            'collections',
            'elements',
            'modules',
            'views'
        ];

        searchFolders.forEach(function (searchFolder) {
            var searchRoot = path.resolve(srcDirPath, searchFolder);

            dirTree(searchRoot, {extensions: /\.js$/}, function (item) {
                var basename = path.basename(item.path, '.js');

                // skip files that do not start with an uppercase letter
                if (/[^A-Z]/.test(basename[0])) {
                    return;
                }

                if (unprefixedImports[basename]) {
                    error('duplicate react component name \'' + basename + '\' - probably the plugin needs an update');
                }
                unprefixedImports[basename] = item.path.substring(srcDirPath.length).replace(/\\/g, '/');
            });
        });

        cache.jsImports._unprefixedImports = unprefixedImports;
    }

    var prefix;
    if (importType === 'src') {
        prefix = '/src';
    } else {
        prefix = '/dist/' + importType;
    }

    cache.jsImports[importType] = {};
    for(var key in unprefixedImports) {
        if (unprefixedImports.hasOwnProperty(key)) {
            cache.jsImports[importType][key] = prefix + unprefixedImports[key];
        }
    }

    return cache.jsImports[importType];
}
function getJsImports ( importType ) { if ( cache . jsImports [ importType ] ) { return cache . jsImports [ importType ] ; } var unprefixedImports = { } ; if ( cache . jsImports . _unprefixedImports ) { unprefixedImports = cache . jsImports . _unprefixedImports ; } else { var semanticUiReactPath = getPackagePath ( 'semantic-ui-react' ) ; if ( ! semanticUiReactPath ) { error ( 'Package semantic-ui-react could not be found. Install semantic-ui-react or set convertMemberImports ' + 'to false.' ) ; } var srcDirPath = path . resolve ( semanticUiReactPath , 'src' ) ; var searchFolders = [ 'addons' , 'behaviors' , 'collections' , 'elements' , 'modules' , 'views' ] ; searchFolders . forEach ( function ( searchFolder ) { var searchRoot = path . resolve ( srcDirPath , searchFolder ) ; dirTree ( searchRoot , { extensions : / \.js$ / } , function ( item ) { var basename = path . basename ( item . path , '.js' ) ; // skip files that do not start with an uppercase letter if ( / [^A-Z] / . test ( basename [ 0 ] ) ) { return ; } if ( unprefixedImports [ basename ] ) { error ( 'duplicate react component name \'' + basename + '\' - probably the plugin needs an update' ) ; } unprefixedImports [ basename ] = item . path . substring ( srcDirPath . length ) . replace ( / \\ / g , '/' ) ; } ) ; } ) ; cache . jsImports . _unprefixedImports = unprefixedImports ; } var prefix ; if ( importType === 'src' ) { prefix = '/src' ; } else { prefix = '/dist/' + importType ; } cache . jsImports [ importType ] = { } ; for ( var key in unprefixedImports ) { if ( unprefixedImports . hasOwnProperty ( key ) ) { cache . jsImports [ importType ] [ key ] = prefix + unprefixedImports [ key ] ; } } return cache . jsImports [ importType ] ; }
Gathers import paths of Semantic UI React components from semantic-ui-react package folder.
@param importType Type of the import (es, commonjs, umd or src).
@returns {*} An object where the keys are Semantic UI React component names and the values are the corresponding
import paths (relative to semantic-ui-react/dist/[import type]/ or semantic-ui-react/src/ (for importType='src').
Gathers import paths of Semantic UI React components from semantic - ui - react package folder .