alexanderGugel / ied

:package: Like npm, but faster - an alternative package manager for Node
http://alexandergugel.github.io/ied
MIT License
1.99k stars 53 forks source link

Start downloading sub dependencies before dependency has been completely fetched #91

Closed alexanderGugel closed 8 years ago

alexanderGugel commented 8 years ago

This was the original behavior, but it changed when we started supporting downloads.

The part in question is the recurse function:

function recurse (dir, tmpDest, pkg, cb) {
  debug('recursively installing %s@%s into %s from %s', pkg.name, pkg.version, tmpDest, dir)

  async.series([
    // Creates node_modules directory. Required before installation of
    // sub-dependencies. `tar-fs` uses `mkdirp` under the hood, but we can't
    // rely on it, since we install further sub-dependencies in parallel.
    mkdirp.bind(null, path.join(tmpDest, 'node_modules')),

    // Some packages (such as `babel-runtime`), require files from their own
    // package via `require('my_package/index.js')` instead of for example
    // `require('./index.js')`.
    linkPkg.bind(null, tmpDest, pkg),

    async.waterfall.bind(null, [
      fetch.bind(null, tmpDest, pkg.tarball, pkg.uid, pkg.shasum),

      // Read dependency information
      readPackage.bind(null, tmpDest),

      // Install further dependencies.
      installSubDeps.bind(null, tmpDest, dir)
    ])
  ], cb)
}

Instead of reading the package.json once we downloaded a dependency, we should use the package.json file (and the contained dependencies) that we get from the registry. The above logic should only be implemented for tarballs. This needs to be changed.

/cc @just-boris I'm going to have to change this back.

just-boris commented 8 years ago

Well, that gives some boost up for the most common way, when you install everything from NPM registry.

I couldn't do it in a nice way, so I did it as it is now. If you have an idea how to make it better, I will be happy to know it.

alexanderGugel commented 8 years ago

I'm currently working on a refactor as we speak. I'm going to make a "Transaction" class that basically just has an EventEmitter used for coordinating installs. I think that should make it simpler to implement.

alexanderGugel commented 8 years ago

Done.