Package "Bundles" #87
mauricioszabo
started this conversation in
Core Application & Packages
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
One idea we had was to make a package bundle. Basically, this might open the doors to be able to load the editor faster, while also minimizing the size (a recent experiment showed that almost 50% of the binaries' size is taken by the core packages)
So, an idea could be to change
package-manager.js
to allow "package bundle" or "meta package" - the idea of a single package that bundles multiple other functionality. I tried to study this possibility, with mixed results - currently, there's no way to make this work, but we can simulate this as shown by this experiment of mine: a meta package called star-ring. A simple TL;DR; of the idea is: I bundled everything inside~/.pulsar/packages/star-ring
, and each sub-package is inside~/.pulsar/packages/<package-name>
. So, I have for example~/.pulsar/packages/star-ring/main.js
and there I export some JS functions likelsp_activate
, and then inside~/.pulsar/packages/generic-lsp/index.js
I basically addmodule.exports.activate = require('../star-ring/main').lsp_activate
.But we can have a better way. Things that I though:
Alternative (1) feels more polished, but alternative (2) is easier to implement. By a huge amount and that's why:
How package loading works?
Currently, Pulsar registers some directories where it'll load packages, and then it scans subdirectories by their
package.json
files, and checks if theatom
engine is present. So far so good.The problem is - if it finds the package.json, it'll register it as a package and then require the main module. To change that we need to either move meta-packages to a different directory and then add the concept of meta-package, and somehow refactor the package loading into a situation where it does not need to require the main module; then, add some code to check if at least one package inside the meta-package is active, and if so, require the meta-package and register the commands/grammars/extension points of each active package inside that meta-package.
Also, PPM - we need to update PPM to understand that meta-packages are now a thing, must be installed somewhere, and add each sub-package inside the package manager, but disallows the instalation of these "individual" packages otherwise we'll uninstall the whole meta-package.
Finally, settings-view needs to be updated to inform, on the Packages tab, if some specific package is a meta-package (with some easy to follow link to go to the meta-package's tab) and add a new tab for meta-packages, allowing to install and uninstall them
How alternative (2) could work?
Instead of fundamentally changing ALL the package-manager to understand the concept of meta-packages and everything, we could just add some new subdirectory like
~/.pulsar/meta-packages
and then if a directory exists inside this subdir, we treat it as a meta-package and simply add the subdir as part of package resolution. For example, I could have~/.pulsar/meta-packages/star-ring
. On boot, Pulsar would scan this directory and basically add, without thinking,~/.pulsar/meta-packages/star-ring
to the package resolution; now, every sub directory inside~/.pulsar/meta-packages/star-ring
will be treated as a package, and we don't need to change anything.All the other things (make PPM understand meta-packages, and settings-view changes) will need to be done anyway, but we can "hack around" right now without adding these supports - for example, if someone wants to generate a meta-package, he would just clone it inside
~/.pulsar/meta-packages
and everything will work.Another idea
We could even implement Alternative (2) for now, then as soon as we make Alternative (1) available we can mark it as deprecated (and maybe offer some script to migrate this to the newer format).
If possible, we could even automate the bundling of multiple packages in a single one, making all metadata and etc, inside Pulsar itself (or on PPM). We also need to be aware that individual packages may need some special babel rules, and we need to resolve conflicting dependencies too, but maybe it's doable in some way?
Beta Was this translation helpful? Give feedback.
All reactions