function symlinkDependencyTreeToLocalNodeModules(dependencyName) {
  const localDependencyPath = path.join(PACKAGE_DIR, 'node_modules', dependencyName);

  console.log('\nlinking dependency tree for "%s"', dependencyName);
  console.log('%s: %s', dependencyName, localDependencyPath);

  if (!fs.existsSync(localDependencyPath)) {
    console.log('dependency does not exist!');
    const localDependencyPathDir = path.dirname(localDependencyPath);

    if (!fs.existsSync(localDependencyPathDir)) {
      console.log('dependency does not have parent directory, creating...');
      fs.mkdirSync(localDependencyPathDir);
    }

    const source = path.relative(localDependencyPathDir, path.resolve(`../../node_modules/${dependencyName}`));
    console.log('creating a symlink from "%s" to "%s"', localDependencyPath);

    fs.symlinkSync(source, localDependencyPath);
    console.log('successfully linked "%s" at "%s"!', dependencyName, localDependencyPath);
    console.log('updating symlink configuration...');
    fs.appendFileSync(SYMLINKS_LOG, `${dependencyName}\n`);
  } else {
    console.log('%s exists, skipping...', dependencyName);
  }

  const packageData = readPackageJson(localDependencyPath);
  const dependencies = Object.keys(packageData.dependencies || {});
  console.log('linking dependencies of "%s":\n', dependencyName, dependencies);
  dependencies.forEach(symlinkDependencyTreeToLocalNodeModules);
}
Goes through the whole dependency tree of a given top-level dependency
and makes sure all packages involved are accessible in the local
'node_modules' directory at least in form of symlinks.

This is useful if the project uses yarn workspaces, but wants to publish
the package with npm and uses 'bundledDependencies'. 'npm pack' is not able
to find packages if they're put into the root 'node_modules' by yarn and
wouldn't be able to bundle them.

@param {string} dependencyName Dependency tree root