join = (base, spec) => {
  spec = String(spec || '');
  base = String(base || '');

  const specParts = spec.split('/');
  const baseParts = base.split('/');

  if (specParts.length > 1 && specParts[0] === '') {
    throw Error(`Module specifier ${q(spec)} must not start with "/"`);
  }
  if (baseParts[0] === '.' || baseParts[0] === '..') {
    throw Error(`External module specifier ${q(base)} must be absolute`);
  }
  if (specParts[0] !== '.') {
    throw Error(`Internal module specifier ${q(spec)} must be relative`);
  }

  const solution = [];
  if (!solve(solution, specParts)) {
    throw Error(
      `Module specifier ${q(spec)} via base ${q(
        base,
      )} must not refer to a module outside of the base`,
    );
  }

  return [base, ...solution].join('/');
}
To construct a module map from a node_modules package, inter-package linkage
requires connecting a full base module specifier like "dependency-package"
to the other package's full internal module specifier like "." or
"./utility", to form a local full module specifier like "dependency-package"
or "dependency-package/utility".
This type of join may assert that the base is absolute and the referrent is
relative.

@param {string} base - the fully resolved path of a module.
@param {string} spec - the partially resolved path of another module.
@returns {string} the fully resolved path of the specified module.