core/refactor/common.js
function resolveModulePath(relativeToFile, modulePath) {
  if (!isLocalModule(modulePath)) {
    return modulePath;
  }

  const alias = getModuleResolverAlias();
  const matched = _.find(_.keys(alias), k => _.startsWith(modulePath, k));

  let res = null;
  if (matched) {
    const resolveTo = alias[matched];
    const relativePath = modulePath.replace(new RegExp(`^${matched}`), '').replace(/^\//, '');
    res = paths.map(resolveTo, relativePath);
    // res = utils.joinPath(utils.getProjectRoot(), resolveTo, relativePath);
  } else {
    res = paths.join(path.dirname(relativeToFile), modulePath);
  }

  let relPath = res.replace(paths.getProjectRoot(), '').replace(/^\/?/, '');
  if (vio.dirExists(relPath)) {
    // if import from a folder, then resolve to index.js
    relPath = paths.join(relPath, 'index');
  }
  return relPath;
}
function resolveModulePath(relativeToFile, modulePath) {
  if (!isLocalModule(modulePath)) {
    return modulePath;
  }

  const alias = getModuleResolverAlias();
  const matched = _.find(_.keys(alias), k => _.startsWith(modulePath, k));

  let res = null;
  if (matched) {
    const resolveTo = alias[matched];
    const relativePath = modulePath.replace(new RegExp(`^${matched}`), '').replace(/^\//, '');
    res = paths.map(resolveTo, relativePath);
    // res = utils.joinPath(utils.getProjectRoot(), resolveTo, relativePath);
  } else {
    res = paths.join(path.dirname(relativeToFile), modulePath);
  }

  let relPath = res.replace(paths.getProjectRoot(), '').replace(/^\/?/, '');
  if (vio.dirExists(relPath)) {
    // if import from a folder, then resolve to index.js
    relPath = paths.join(relPath, 'index');
  }
  return relPath;
}
function resolveModulePath ( relativeToFile , modulePath ) { if ( ! isLocalModule ( modulePath ) ) { return modulePath ; } const alias = getModuleResolverAlias ( ) ; const matched = _ . find ( _ . keys ( alias ) , k => _ . startsWith ( modulePath , k ) ) ; let res = null ; if ( matched ) { const resolveTo = alias [ matched ] ; const relativePath = modulePath . replace ( new RegExp ( ` ${ matched } ` ) , '' ) . replace ( / ^\/ / , '' ) ; res = paths . map ( resolveTo , relativePath ) ; // res = utils.joinPath(utils.getProjectRoot(), resolveTo, relativePath); } else { res = paths . join ( path . dirname ( relativeToFile ) , modulePath ) ; } let relPath = res . replace ( paths . getProjectRoot ( ) , '' ) . replace ( / ^\/? / , '' ) ; if ( vio . dirExists ( relPath ) ) { // if import from a folder, then resolve to index.js relPath = paths . join ( relPath , 'index' ) ; } return relPath ; }
Resolve the module path.
@param {string} relativeTo - Relative to which file to resolve. That is the file in which import the module.
@param {string} modulePath - The relative module path.
@alias module:common.resolveModulePath
Resolve the module path .