Skip to content
This repository was archived by the owner on Mar 3, 2023. It is now read-only.
This repository was archived by the owner on Mar 3, 2023. It is now read-only.

Introduce scheme to npm dedupe npm dependencies of Atom packages #8217

Description

@bolinfest

Currently, the organization of the ~/.atom/packages directory makes it impossible to dedupe dependencies, potentially causing a lot of bloat.

Specifically, in the case of Nuclide, we have our nuclide-installer package that is used to install our collection of Nuclide packages. In the most recent release of Nuclide (v0.0.26), there are 17 such packages to install: https://github.com/facebooknuclideapm/nuclide-installer/blob/v0.0.26/lib/config.json.

The way nuclide-installer works is that it starts up and then runs apm install for each package in that config.json file. On my machine (where ~/.npm was already populated with all of the dependencies used by these packages), it took nuclide-installer 6 minutes to install all 17 Atom packages and the resulting ~/.atom/packages directory was 903M! That's enormous! This is bad for several reasons:

  • 903M is an order of magnitude more disk space than is necessary if dependencies could be de-duped.
  • The installation process is much slower than it has to be.
  • Much more JavaScript code has to be loaded at runtime.
  • I suspect that the JavaScript in ~/.atom/packages is not loaded as efficiently as the JavaScript in /Applications/Atom.app/Contents/Resources/app.asar, putting third-party code at even more of a disadvantage.

I suspect that the only thing I can do right now without any changes to Atom is have ~/.atom/nuclide-installer create a special directory structure under itself. Maybe something like:

~/.atom/nuclide-installer/node_modules/
~/.atom/nuclide-installer/node_modules/atom_packages/

where npm packages common to multiple Nuclide Atom packages would be written to ~/.atom/nuclide-installer/node_modules/ (obviously there could only be one version per common dependency) and then each Atom package would be in its own directory under ~/.atom/nuclide-installer/node_modules/atom_packages/. Under that scheme, only an npm dependency that already had an entry under ~/.atom/nuclide-installer/node_modules/ would also have to exist under ~/.atom/nuclide-installer/node_modules/atom_packages/<ATOM PACKAGE>/node_modules if a different version were required.

Once everything was in place, nuclide-installer would run apm link for each entry in ~/.atom/nuclide-installer/node_modules/atom_packages.

While I'm rubber ducking, I would probably add another directory of indirection so that the directory structure would be parameterized by version number:

~/.atom/nuclide-installer/v0.0.26/node_modules/
~/.atom/nuclide-installer/v0.0.26/node_modules/atom_packages/

This way, nuclide-installer could be writing out v0.0.27 and would not switch over until all of the files were in place.

This is really important for Nuclide, so I'm willing to hack this into nuclide-installer, but it would be nice if there were a way for Atom to support this natively so that others could also provide package bundles efficiently for Atom.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions