packages/roc-package-webpack-dev/src/webpack/utils/rocExportWebpackPlugin.js
function createGetAlias(aliases) {
    if (isPlainObject(aliases) && !Array.isArray(aliases)) {
        aliases = Object.keys(aliases).map((key) => { // eslint-disable-line
            let onlyModule = false;
            let obj = aliases[key];
            if (/\$$/.test(key)) {
                onlyModule = true;
                key = key.substr(0, key.length - 1); // eslint-disable-line
            }
            if (isString(obj)) {
                obj = {
                    alias: obj,
                };
            }
            return {
                name: key,
                onlyModule,
                ...obj,
            };
        });
    }

    return (request) => {
        for (const alias of aliases) {
            if ((!alias.onlyModule && request.indexOf(`${alias.name}/`) === 0) || request === alias.name) {
                if (request.indexOf(`${alias.alias}/`) !== 0 && request !== alias.alias) {
                    return alias.alias + request.substr(alias.name.length);
                }
            }
        }
        return request;
    };
}
function createGetAlias(aliases) {
    if (isPlainObject(aliases) && !Array.isArray(aliases)) {
        aliases = Object.keys(aliases).map((key) => { // eslint-disable-line
            let onlyModule = false;
            let obj = aliases[key];
            if (/\$$/.test(key)) {
                onlyModule = true;
                key = key.substr(0, key.length - 1); // eslint-disable-line
            }
            if (isString(obj)) {
                obj = {
                    alias: obj,
                };
            }
            return {
                name: key,
                onlyModule,
                ...obj,
            };
        });
    }

    return (request) => {
        for (const alias of aliases) {
            if ((!alias.onlyModule && request.indexOf(`${alias.name}/`) === 0) || request === alias.name) {
                if (request.indexOf(`${alias.alias}/`) !== 0 && request !== alias.alias) {
                    return alias.alias + request.substr(alias.name.length);
                }
            }
        }
        return request;
    };
}
function createGetAlias ( aliases ) { if ( isPlainObject ( aliases ) && ! Array . isArray ( aliases ) ) { aliases = Object . keys ( aliases ) . map ( ( key ) => { // eslint-disable-line let onlyModule = false ; let obj = aliases [ key ] ; if ( / \$$ / . test ( key ) ) { onlyModule = true ; key = key . substr ( 0 , key . length - 1 ) ; // eslint-disable-line } if ( isString ( obj ) ) { obj = { alias : obj , } ; } return { name : key , onlyModule , ... obj , } ; } ) ; } return ( request ) => { for ( const alias of aliases ) { if ( ( ! alias . onlyModule && request . indexOf ( ` ${ alias . name } ` ) === 0 ) || request === alias . name ) { if ( request . indexOf ( ` ${ alias . alias } ` ) !== 0 && request !== alias . alias ) { return alias . alias + request . substr ( alias . name . length ) ; } } } return request ; } ; }
Based on code from enhanced-resolve
Based on code from enhanced - resolve