src/main/javascript/webpack/resolvers.js
function resolvePath (moduleName, relativePath)
{
  if (! moduleName) {
    return null;
  }

  if (! relativePath) {
    return null;
  }

  const mainPath = require.resolve(moduleName);
  if (! mainPath) {
    return null;
  }

  const rootLocations = [];
  const dirs = mainPath.split(path.sep);
  let lastSegment = dirs.pop();
  while (lastSegment) {
    const location = dirs.concat(['package.json']).join(path.sep);
    rootLocations.push(location);
    lastSegment = dirs.pop();
  }

  for(const location of rootLocations) {
    if (fs.existsSync(location)) {
      const cli = path.resolve(path.dirname(location), relativePath);
      if (fs.existsSync(cli)) {
        return cli;
      }
    }
  }

  return null;
}
function resolvePath (moduleName, relativePath)
{
  if (! moduleName) {
    return null;
  }

  if (! relativePath) {
    return null;
  }

  const mainPath = require.resolve(moduleName);
  if (! mainPath) {
    return null;
  }

  const rootLocations = [];
  const dirs = mainPath.split(path.sep);
  let lastSegment = dirs.pop();
  while (lastSegment) {
    const location = dirs.concat(['package.json']).join(path.sep);
    rootLocations.push(location);
    lastSegment = dirs.pop();
  }

  for(const location of rootLocations) {
    if (fs.existsSync(location)) {
      const cli = path.resolve(path.dirname(location), relativePath);
      if (fs.existsSync(cli)) {
        return cli;
      }
    }
  }

  return null;
}
function resolvePath ( moduleName , relativePath ) { if ( ! moduleName ) { return null ; } if ( ! relativePath ) { return null ; } const mainPath = require . resolve ( moduleName ) ; if ( ! mainPath ) { return null ; } const rootLocations = [ ] ; const dirs = mainPath . split ( path . sep ) ; let lastSegment = dirs . pop ( ) ; while ( lastSegment ) { const location = dirs . concat ( [ 'package.json' ] ) . join ( path . sep ) ; rootLocations . push ( location ) ; lastSegment = dirs . pop ( ) ; } for ( const location of rootLocations ) { if ( fs . existsSync ( location ) ) { const cli = path . resolve ( path . dirname ( location ) , relativePath ) ; if ( fs . existsSync ( cli ) ) { return cli ; } } } return null ; }
Resolves a relative path in the context of a module into an absolute path

@param {string} moduleName
@param {string} relativePath the relative path inside the module
@returns {string|null}
Resolves a relative path in the context of a module into an absolute path