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.
Currently, the organization of the
~/.atom/packagesdirectory makes it impossible to dedupe dependencies, potentially causing a lot of bloat.Specifically, in the case of Nuclide, we have our
nuclide-installerpackage 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-installerworks is that it starts up and then runsapm installfor each package in thatconfig.jsonfile. On my machine (where~/.npmwas already populated with all of the dependencies used by these packages), it tooknuclide-installer6 minutes to install all 17 Atom packages and the resulting~/.atom/packagesdirectory was 903M! That's enormous! This is bad for several reasons:~/.atom/packagesis 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-installercreate a special directory structure under itself. Maybe something like: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_modulesif a different version were required.Once everything was in place,
nuclide-installerwould runapm linkfor 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:
This way,
nuclide-installercould 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.